@fuel-ts/account 0.0.0-rc-1764-20240404125616 → 0.0.0-rc-1832-20240404143349
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @fuel-ts/account might be problematic. Click here for more details.
- package/README.md +1 -1
- package/dist/account.d.ts +4 -5
- package/dist/account.d.ts.map +1 -1
- package/dist/configs.d.ts.map +1 -1
- package/dist/configs.global.js +1 -1
- package/dist/configs.global.js.map +1 -1
- package/dist/configs.js +1 -1
- package/dist/configs.js.map +1 -1
- package/dist/configs.mjs +1 -1
- package/dist/configs.mjs.map +1 -1
- package/dist/index.global.js +558 -772
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +511 -764
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +392 -644
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +2 -10
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +305 -824
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/coin-quantity.d.ts +1 -1
- package/dist/providers/coin-quantity.d.ts.map +1 -1
- package/dist/providers/coin.d.ts +2 -4
- package/dist/providers/coin.d.ts.map +1 -1
- package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
- package/dist/providers/message.d.ts +0 -3
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +24 -44
- 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 +25 -8
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/utils.d.ts +0 -3
- package/dist/providers/transaction-request/utils.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +0 -2
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +2 -3
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
- package/dist/providers/utils/gas.d.ts +2 -8
- package/dist/providers/utils/gas.d.ts.map +1 -1
- package/dist/test-utils.global.js +551 -729
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +490 -705
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +379 -594
- 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 max2(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 clone(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(clone(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 ? clone(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.49.3",
|
31918
|
+
FUEL_CORE: "0.22.1",
|
31919
31919
|
FUELS: "0.79.0"
|
31920
31920
|
};
|
31921
31921
|
}
|
@@ -32709,7 +32709,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32709
32709
|
var defaultConsensusKey = "0xa449b1ffee0e2205fa924c6740cc48b3b473aa28587df6dab12abc245d1f5298";
|
32710
32710
|
|
32711
32711
|
// ../crypto/dist/index.mjs
|
32712
|
-
var
|
32712
|
+
var import_crypto8 = __toESM(__require("crypto"), 1);
|
32713
32713
|
|
32714
32714
|
// ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/_version.js
|
32715
32715
|
var version = "6.7.1";
|
@@ -33781,27 +33781,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33781
33781
|
};
|
33782
33782
|
Object.freeze(pbkdf22);
|
33783
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
|
-
|
33805
33784
|
// ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/address/address.js
|
33806
33785
|
var BN_03 = BigInt(0);
|
33807
33786
|
var BN_36 = BigInt(36);
|
@@ -34386,8 +34365,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34386
34365
|
}
|
34387
34366
|
|
34388
34367
|
// ../crypto/dist/index.mjs
|
34368
|
+
var import_crypto9 = __toESM(__require("crypto"), 1);
|
34389
34369
|
var import_crypto10 = __toESM(__require("crypto"), 1);
|
34390
|
-
var import_crypto11 = __toESM(__require("crypto"), 1);
|
34391
34370
|
var scrypt3 = (params) => {
|
34392
34371
|
const { password, salt, n, p, r, dklen } = params;
|
34393
34372
|
const derivedKey = scrypt(password, salt, { N: n, r, p, dkLen: dklen });
|
@@ -34396,7 +34375,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34396
34375
|
var keccak2562 = (data) => keccak_256(data);
|
34397
34376
|
var bufferFromString = (string, encoding = "base64") => Uint8Array.from(Buffer.from(string, encoding));
|
34398
34377
|
var randomBytes4 = (length) => {
|
34399
|
-
const randomValues = Uint8Array.from(
|
34378
|
+
const randomValues = Uint8Array.from(import_crypto9.default.randomBytes(length));
|
34400
34379
|
return randomValues;
|
34401
34380
|
};
|
34402
34381
|
var stringFromBuffer = (buffer, encoding = "base64") => Buffer.from(buffer).toString(encoding);
|
@@ -34411,7 +34390,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34411
34390
|
const salt = randomBytes4(32);
|
34412
34391
|
const secret = keyFromPassword(password, salt);
|
34413
34392
|
const dataBuffer = Uint8Array.from(Buffer.from(JSON.stringify(data), "utf-8"));
|
34414
|
-
const cipher = await
|
34393
|
+
const cipher = await import_crypto8.default.createCipheriv(ALGORITHM, secret, iv);
|
34415
34394
|
let cipherData = cipher.update(dataBuffer);
|
34416
34395
|
cipherData = Buffer.concat([cipherData, cipher.final()]);
|
34417
34396
|
return {
|
@@ -34425,7 +34404,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34425
34404
|
const salt = bufferFromString(keystore.salt);
|
34426
34405
|
const secret = keyFromPassword(password, salt);
|
34427
34406
|
const encryptedText = bufferFromString(keystore.data);
|
34428
|
-
const decipher = await
|
34407
|
+
const decipher = await import_crypto8.default.createDecipheriv(ALGORITHM, secret, iv);
|
34429
34408
|
const decrypted = decipher.update(encryptedText);
|
34430
34409
|
const deBuff = Buffer.concat([decrypted, decipher.final()]);
|
34431
34410
|
const decryptedData = Buffer.from(deBuff).toString("utf-8");
|
@@ -34436,12 +34415,12 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34436
34415
|
}
|
34437
34416
|
};
|
34438
34417
|
async function encryptJsonWalletData(data, key, iv) {
|
34439
|
-
const cipher = await
|
34418
|
+
const cipher = await import_crypto10.default.createCipheriv("aes-128-ctr", key.subarray(0, 16), iv);
|
34440
34419
|
const encrypted = Buffer.concat([cipher.update(data), cipher.final()]);
|
34441
34420
|
return new Uint8Array(encrypted);
|
34442
34421
|
}
|
34443
34422
|
async function decryptJsonWalletData(data, key, iv) {
|
34444
|
-
const decipher =
|
34423
|
+
const decipher = import_crypto10.default.createDecipheriv("aes-128-ctr", key.subarray(0, 16), iv);
|
34445
34424
|
const decrypted = await Buffer.concat([decipher.update(data), decipher.final()]);
|
34446
34425
|
return new Uint8Array(decrypted);
|
34447
34426
|
}
|
@@ -34998,182 +34977,32 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34998
34977
|
function toBytes3(value, bytesPadding) {
|
34999
34978
|
return bn(value).toBytes(bytesPadding);
|
35000
34979
|
}
|
35001
|
-
|
35002
|
-
|
35003
|
-
function _isPlaceholder(a) {
|
35004
|
-
return a != null && typeof a === "object" && a["@@functional/placeholder"] === true;
|
34980
|
+
function max(...numbers) {
|
34981
|
+
return numbers.reduce((prev, cur) => bn(cur).gt(prev) ? bn(cur) : prev, bn(0));
|
35005
34982
|
}
|
35006
34983
|
|
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";
|
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";
|
35154
|
-
|
35155
34984
|
// src/providers/coin-quantity.ts
|
35156
34985
|
var coinQuantityfy = (coinQuantityLike) => {
|
35157
34986
|
let assetId;
|
35158
34987
|
let amount;
|
35159
|
-
let
|
34988
|
+
let max2;
|
35160
34989
|
if (Array.isArray(coinQuantityLike)) {
|
35161
34990
|
amount = coinQuantityLike[0];
|
35162
34991
|
assetId = coinQuantityLike[1] ?? BaseAssetId;
|
35163
|
-
|
34992
|
+
max2 = coinQuantityLike[2] ?? void 0;
|
35164
34993
|
} else {
|
35165
34994
|
amount = coinQuantityLike.amount;
|
35166
34995
|
assetId = coinQuantityLike.assetId ?? BaseAssetId;
|
35167
|
-
|
34996
|
+
max2 = coinQuantityLike.max ?? void 0;
|
35168
34997
|
}
|
35169
34998
|
const bnAmount = bn(amount);
|
35170
34999
|
return {
|
35171
35000
|
assetId: hexlify(assetId),
|
35172
35001
|
amount: bnAmount.lt(1) ? bn(1) : bnAmount,
|
35173
|
-
max:
|
35002
|
+
max: max2 ? bn(max2) : void 0
|
35174
35003
|
};
|
35175
35004
|
};
|
35176
|
-
var
|
35005
|
+
var addAmountToAsset = (params) => {
|
35177
35006
|
const { amount, assetId } = params;
|
35178
35007
|
const coinQuantities = [...params.coinQuantities];
|
35179
35008
|
const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
|
@@ -35267,6 +35096,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
35267
35096
|
ASSET_ID_LEN + // Asset id
|
35268
35097
|
TX_POINTER_LEN + // TxPointer
|
35269
35098
|
WORD_SIZE + // Witnesses index
|
35099
|
+
WORD_SIZE + // Maturity
|
35270
35100
|
WORD_SIZE + // Predicate size
|
35271
35101
|
WORD_SIZE + // Predicate data size
|
35272
35102
|
WORD_SIZE;
|
@@ -35550,9 +35380,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
35550
35380
|
__privateAdd2(this, _getPaddedData);
|
35551
35381
|
}
|
35552
35382
|
encode(value) {
|
35553
|
-
if (!Array.isArray(value)) {
|
35554
|
-
throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
|
35555
|
-
}
|
35556
35383
|
const parts = [];
|
35557
35384
|
const pointer = new BigNumberCoder("u64").encode(BASE_VECTOR_OFFSET);
|
35558
35385
|
const data = __privateMethod2(this, _getPaddedData, getPaddedData_fn).call(this, value);
|
@@ -35579,7 +35406,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
35579
35406
|
};
|
35580
35407
|
_getPaddedData = /* @__PURE__ */ new WeakSet();
|
35581
35408
|
getPaddedData_fn = function(value) {
|
35582
|
-
const data = [Uint8Array
|
35409
|
+
const data = value instanceof Uint8Array ? [value] : [new Uint8Array(value)];
|
35583
35410
|
const paddingLength = (WORD_SIZE - value.length % WORD_SIZE) % WORD_SIZE;
|
35584
35411
|
if (paddingLength) {
|
35585
35412
|
data.push(new Uint8Array(paddingLength));
|
@@ -35599,10 +35426,10 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
35599
35426
|
constructor(name, coders) {
|
35600
35427
|
const caseIndexCoder = new BigNumberCoder("u64");
|
35601
35428
|
const encodedValueSize = Object.values(coders).reduce(
|
35602
|
-
(
|
35429
|
+
(max2, coder) => Math.max(max2, coder.encodedLength),
|
35603
35430
|
0
|
35604
35431
|
);
|
35605
|
-
super(
|
35432
|
+
super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
|
35606
35433
|
this.name = name;
|
35607
35434
|
this.coders = coders;
|
35608
35435
|
this.#caseIndexCoder = caseIndexCoder;
|
@@ -35672,7 +35499,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
35672
35499
|
return { None: [] };
|
35673
35500
|
}
|
35674
35501
|
decode(data, offset) {
|
35675
|
-
if (data.length < this.encodedLength
|
35502
|
+
if (data.length < this.encodedLength) {
|
35676
35503
|
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid option data size.`);
|
35677
35504
|
}
|
35678
35505
|
const [decoded, newOffset] = super.decode(data, offset);
|
@@ -36255,11 +36082,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36255
36082
|
super("struct", "struct Bytes", WORD_SIZE);
|
36256
36083
|
}
|
36257
36084
|
encode(value) {
|
36258
|
-
|
36259
|
-
|
36260
|
-
}
|
36261
|
-
const bytes3 = new Uint8Array(value);
|
36262
|
-
const lengthBytes = new BigNumberCoder("u64").encode(value.length);
|
36085
|
+
const bytes3 = value instanceof Uint8Array ? value : new Uint8Array(value);
|
36086
|
+
const lengthBytes = new BigNumberCoder("u64").encode(bytes3.length);
|
36263
36087
|
return new Uint8Array([...lengthBytes, ...bytes3]);
|
36264
36088
|
}
|
36265
36089
|
decode(data, offset) {
|
@@ -36289,10 +36113,10 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36289
36113
|
constructor(name, coders) {
|
36290
36114
|
const caseIndexCoder = new BigNumberCoder("u64");
|
36291
36115
|
const encodedValueSize = Object.values(coders).reduce(
|
36292
|
-
(
|
36116
|
+
(max2, coder) => Math.max(max2, coder.encodedLength),
|
36293
36117
|
0
|
36294
36118
|
);
|
36295
|
-
super(
|
36119
|
+
super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
|
36296
36120
|
this.name = name;
|
36297
36121
|
this.coders = coders;
|
36298
36122
|
this.#caseIndexCoder = caseIndexCoder;
|
@@ -36390,6 +36214,28 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36390
36214
|
return [toNumber2(bytes3), offset + this.length];
|
36391
36215
|
}
|
36392
36216
|
};
|
36217
|
+
var OptionCoder2 = class extends EnumCoder2 {
|
36218
|
+
encode(value) {
|
36219
|
+
const result = super.encode(this.toSwayOption(value));
|
36220
|
+
return result;
|
36221
|
+
}
|
36222
|
+
toSwayOption(input) {
|
36223
|
+
if (input !== void 0) {
|
36224
|
+
return { Some: input };
|
36225
|
+
}
|
36226
|
+
return { None: [] };
|
36227
|
+
}
|
36228
|
+
decode(data, offset) {
|
36229
|
+
const [decoded, newOffset] = super.decode(data, offset);
|
36230
|
+
return [this.toOption(decoded), newOffset];
|
36231
|
+
}
|
36232
|
+
toOption(output3) {
|
36233
|
+
if (output3 && "Some" in output3) {
|
36234
|
+
return output3.Some;
|
36235
|
+
}
|
36236
|
+
return void 0;
|
36237
|
+
}
|
36238
|
+
};
|
36393
36239
|
var RawSliceCoder2 = class extends Coder {
|
36394
36240
|
constructor() {
|
36395
36241
|
super("raw untyped slice", "raw untyped slice", WORD_SIZE);
|
@@ -36443,6 +36289,30 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36443
36289
|
}
|
36444
36290
|
};
|
36445
36291
|
__publicField4(StdStringCoder2, "memorySize", 1);
|
36292
|
+
var StrSliceCoder = class extends Coder {
|
36293
|
+
constructor() {
|
36294
|
+
super("strSlice", "str", WORD_SIZE);
|
36295
|
+
}
|
36296
|
+
encode(value) {
|
36297
|
+
const bytes3 = toUtf8Bytes(value);
|
36298
|
+
const lengthBytes = new BigNumberCoder("u64").encode(value.length);
|
36299
|
+
return new Uint8Array([...lengthBytes, ...bytes3]);
|
36300
|
+
}
|
36301
|
+
decode(data, offset) {
|
36302
|
+
if (data.length < this.encodedLength) {
|
36303
|
+
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string slice data size.`);
|
36304
|
+
}
|
36305
|
+
const offsetAndLength = offset + WORD_SIZE;
|
36306
|
+
const lengthBytes = data.slice(offset, offsetAndLength);
|
36307
|
+
const length = bn(new BigNumberCoder("u64").decode(lengthBytes, 0)[0]).toNumber();
|
36308
|
+
const bytes3 = data.slice(offsetAndLength, offsetAndLength + length);
|
36309
|
+
if (bytes3.length !== length) {
|
36310
|
+
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string slice byte data size.`);
|
36311
|
+
}
|
36312
|
+
return [toUtf8String(bytes3), offsetAndLength + length];
|
36313
|
+
}
|
36314
|
+
};
|
36315
|
+
__publicField4(StrSliceCoder, "memorySize", 1);
|
36446
36316
|
var StringCoder2 = class extends Coder {
|
36447
36317
|
constructor(length) {
|
36448
36318
|
super("string", `str[${length}]`, length);
|
@@ -36481,7 +36351,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36481
36351
|
Object.keys(this.coders).map((fieldName) => {
|
36482
36352
|
const fieldCoder = this.coders[fieldName];
|
36483
36353
|
const fieldValue = value[fieldName];
|
36484
|
-
if (!(fieldCoder instanceof
|
36354
|
+
if (!(fieldCoder instanceof OptionCoder2) && fieldValue == null) {
|
36485
36355
|
throw new FuelError(
|
36486
36356
|
ErrorCode.ENCODE_ERROR,
|
36487
36357
|
`Invalid ${this.type}. Field "${fieldName}" not present.`
|
@@ -36589,6 +36459,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36589
36459
|
return new ByteCoder2();
|
36590
36460
|
case STD_STRING_CODER_TYPE:
|
36591
36461
|
return new StdStringCoder2();
|
36462
|
+
case STR_SLICE_CODER_TYPE:
|
36463
|
+
return new StrSliceCoder();
|
36592
36464
|
default:
|
36593
36465
|
break;
|
36594
36466
|
}
|
@@ -36633,7 +36505,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36633
36505
|
const coders = getCoders(components, { getCoder: getCoder2 });
|
36634
36506
|
const isOptionEnum = resolvedAbiType.type === OPTION_CODER_TYPE;
|
36635
36507
|
if (isOptionEnum) {
|
36636
|
-
return new
|
36508
|
+
return new OptionCoder2(enumMatch.name, coders);
|
36637
36509
|
}
|
36638
36510
|
return new EnumCoder2(enumMatch.name, coders);
|
36639
36511
|
}
|
@@ -36644,12 +36516,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36644
36516
|
);
|
36645
36517
|
return new TupleCoder2(coders);
|
36646
36518
|
}
|
36647
|
-
if (resolvedAbiType.type === STR_SLICE_CODER_TYPE) {
|
36648
|
-
throw new FuelError(
|
36649
|
-
ErrorCode.INVALID_DATA,
|
36650
|
-
"String slices can not be decoded from logs. Convert the slice to `str[N]` with `__to_str_array`"
|
36651
|
-
);
|
36652
|
-
}
|
36653
36519
|
throw new FuelError(
|
36654
36520
|
ErrorCode.CODER_NOT_FOUND,
|
36655
36521
|
`Coder not found: ${JSON.stringify(resolvedAbiType)}.`
|
@@ -36685,6 +36551,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36685
36551
|
var FunctionFragment = class {
|
36686
36552
|
signature;
|
36687
36553
|
selector;
|
36554
|
+
selectorBytes;
|
36555
|
+
encoding;
|
36688
36556
|
name;
|
36689
36557
|
jsonFn;
|
36690
36558
|
attributes;
|
@@ -36697,6 +36565,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36697
36565
|
this.name = name;
|
36698
36566
|
this.signature = FunctionFragment.getSignature(this.jsonAbi, this.jsonFn);
|
36699
36567
|
this.selector = FunctionFragment.getFunctionSelector(this.signature);
|
36568
|
+
this.selectorBytes = new StdStringCoder2().encode(name);
|
36569
|
+
this.encoding = this.jsonAbi.encoding ?? ENCODING_V0;
|
36700
36570
|
this.isInputDataPointer = this.#isInputDataPointer();
|
36701
36571
|
this.outputMetadata = {
|
36702
36572
|
isHeapType: this.#isOutputDataHeap(),
|
@@ -36750,11 +36620,14 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36750
36620
|
}
|
36751
36621
|
const coders = nonEmptyInputs.map(
|
36752
36622
|
(t) => AbiCoder.getCoder(this.jsonAbi, t, {
|
36753
|
-
isRightPadded: nonEmptyInputs.length > 1
|
36623
|
+
isRightPadded: nonEmptyInputs.length > 1,
|
36624
|
+
encoding: this.encoding
|
36754
36625
|
})
|
36755
36626
|
);
|
36756
|
-
|
36757
|
-
|
36627
|
+
if (this.encoding === ENCODING_V1) {
|
36628
|
+
return new TupleCoder2(coders).encode(shallowCopyValues);
|
36629
|
+
}
|
36630
|
+
const results = new TupleCoder(coders).encode(shallowCopyValues);
|
36758
36631
|
return unpackDynamicData(results, offset, results.byteLength);
|
36759
36632
|
}
|
36760
36633
|
static verifyArgsAndInputsAlign(args, inputs, abi) {
|
@@ -36801,7 +36674,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36801
36674
|
}
|
36802
36675
|
const result = nonEmptyInputs.reduce(
|
36803
36676
|
(obj, input) => {
|
36804
|
-
const coder = AbiCoder.getCoder(this.jsonAbi, input);
|
36677
|
+
const coder = AbiCoder.getCoder(this.jsonAbi, input, { encoding: this.encoding });
|
36805
36678
|
const [decodedValue, decodedValueByteSize] = coder.decode(bytes3, obj.offset);
|
36806
36679
|
return {
|
36807
36680
|
decoded: [...obj.decoded, decodedValue],
|
@@ -36821,7 +36694,9 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36821
36694
|
return [void 0, 0];
|
36822
36695
|
}
|
36823
36696
|
const bytes3 = arrayify(data);
|
36824
|
-
const coder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output
|
36697
|
+
const coder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output, {
|
36698
|
+
encoding: this.encoding
|
36699
|
+
});
|
36825
36700
|
return coder.decode(bytes3, 0);
|
36826
36701
|
}
|
36827
36702
|
};
|
@@ -36883,7 +36758,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36883
36758
|
}
|
36884
36759
|
);
|
36885
36760
|
return AbiCoder.encode(this.jsonAbi, configurable.configurableType, value, {
|
36886
|
-
isRightPadded: true
|
36761
|
+
isRightPadded: true,
|
36762
|
+
encoding: this.jsonAbi.encoding
|
36887
36763
|
});
|
36888
36764
|
}
|
36889
36765
|
getTypeById(typeId) {
|
@@ -36966,6 +36842,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36966
36842
|
parts.push(new B256Coder().encode(value.assetId));
|
36967
36843
|
parts.push(new TxPointerCoder().encode(value.txPointer));
|
36968
36844
|
parts.push(new NumberCoder("u8").encode(value.witnessIndex));
|
36845
|
+
parts.push(new NumberCoder("u32").encode(value.maturity));
|
36969
36846
|
parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
|
36970
36847
|
parts.push(new NumberCoder("u32").encode(value.predicateLength));
|
36971
36848
|
parts.push(new NumberCoder("u32").encode(value.predicateDataLength));
|
@@ -36990,6 +36867,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36990
36867
|
const txPointer = decoded;
|
36991
36868
|
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
36992
36869
|
const witnessIndex = Number(decoded);
|
36870
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
36871
|
+
const maturity = decoded;
|
36993
36872
|
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
36994
36873
|
const predicateGasUsed = decoded;
|
36995
36874
|
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
@@ -37010,6 +36889,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
37010
36889
|
assetId,
|
37011
36890
|
txPointer,
|
37012
36891
|
witnessIndex,
|
36892
|
+
maturity,
|
37013
36893
|
predicateGasUsed,
|
37014
36894
|
predicateLength,
|
37015
36895
|
predicateDataLength,
|
@@ -37441,7 +37321,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
37441
37321
|
}
|
37442
37322
|
};
|
37443
37323
|
var PolicyType = /* @__PURE__ */ ((PolicyType2) => {
|
37444
|
-
PolicyType2[PolicyType2["
|
37324
|
+
PolicyType2[PolicyType2["GasPrice"] = 1] = "GasPrice";
|
37445
37325
|
PolicyType2[PolicyType2["WitnessLimit"] = 2] = "WitnessLimit";
|
37446
37326
|
PolicyType2[PolicyType2["Maturity"] = 4] = "Maturity";
|
37447
37327
|
PolicyType2[PolicyType2["MaxFee"] = 8] = "MaxFee";
|
@@ -37489,9 +37369,9 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
37489
37369
|
let o = offset;
|
37490
37370
|
const policies = [];
|
37491
37371
|
if (policyTypes & 1) {
|
37492
|
-
const [
|
37372
|
+
const [gasPrice, nextOffset] = new BigNumberCoder("u64").decode(data, o);
|
37493
37373
|
o = nextOffset;
|
37494
|
-
policies.push({ type: 1, data:
|
37374
|
+
policies.push({ type: 1, data: gasPrice });
|
37495
37375
|
}
|
37496
37376
|
if (policyTypes & 2) {
|
37497
37377
|
const [witnessLimit, nextOffset] = new BigNumberCoder("u64").decode(data, o);
|
@@ -38204,6 +38084,159 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
38204
38084
|
// src/providers/provider.ts
|
38205
38085
|
var import_graphql_request = __toESM(require_dist2());
|
38206
38086
|
|
38087
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isPlaceholder.js
|
38088
|
+
function _isPlaceholder(a) {
|
38089
|
+
return a != null && typeof a === "object" && a["@@functional/placeholder"] === true;
|
38090
|
+
}
|
38091
|
+
|
38092
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_curry1.js
|
38093
|
+
function _curry1(fn) {
|
38094
|
+
return function f1(a) {
|
38095
|
+
if (arguments.length === 0 || _isPlaceholder(a)) {
|
38096
|
+
return f1;
|
38097
|
+
} else {
|
38098
|
+
return fn.apply(this, arguments);
|
38099
|
+
}
|
38100
|
+
};
|
38101
|
+
}
|
38102
|
+
|
38103
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isArray.js
|
38104
|
+
var isArray_default = Array.isArray || function _isArray(val) {
|
38105
|
+
return val != null && val.length >= 0 && Object.prototype.toString.call(val) === "[object Array]";
|
38106
|
+
};
|
38107
|
+
|
38108
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/type.js
|
38109
|
+
var type = /* @__PURE__ */ _curry1(function type2(val) {
|
38110
|
+
return val === null ? "Null" : val === void 0 ? "Undefined" : Object.prototype.toString.call(val).slice(8, -1);
|
38111
|
+
});
|
38112
|
+
var type_default = type;
|
38113
|
+
|
38114
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_toISOString.js
|
38115
|
+
var pad = function pad2(n) {
|
38116
|
+
return (n < 10 ? "0" : "") + n;
|
38117
|
+
};
|
38118
|
+
var _toISOString = typeof Date.prototype.toISOString === "function" ? function _toISOString2(d) {
|
38119
|
+
return d.toISOString();
|
38120
|
+
} : function _toISOString3(d) {
|
38121
|
+
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";
|
38122
|
+
};
|
38123
|
+
|
38124
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isInteger.js
|
38125
|
+
var isInteger_default = Number.isInteger || function _isInteger(n) {
|
38126
|
+
return n << 0 === n;
|
38127
|
+
};
|
38128
|
+
|
38129
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_cloneRegExp.js
|
38130
|
+
function _cloneRegExp(pattern) {
|
38131
|
+
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" : ""));
|
38132
|
+
}
|
38133
|
+
|
38134
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_clone.js
|
38135
|
+
function _clone(value, deep, map) {
|
38136
|
+
map || (map = new _ObjectMap());
|
38137
|
+
if (_isPrimitive(value)) {
|
38138
|
+
return value;
|
38139
|
+
}
|
38140
|
+
var copy = function copy2(copiedValue) {
|
38141
|
+
var cachedCopy = map.get(value);
|
38142
|
+
if (cachedCopy) {
|
38143
|
+
return cachedCopy;
|
38144
|
+
}
|
38145
|
+
map.set(value, copiedValue);
|
38146
|
+
for (var key in value) {
|
38147
|
+
if (Object.prototype.hasOwnProperty.call(value, key)) {
|
38148
|
+
copiedValue[key] = deep ? _clone(value[key], true, map) : value[key];
|
38149
|
+
}
|
38150
|
+
}
|
38151
|
+
return copiedValue;
|
38152
|
+
};
|
38153
|
+
switch (type_default(value)) {
|
38154
|
+
case "Object":
|
38155
|
+
return copy(Object.create(Object.getPrototypeOf(value)));
|
38156
|
+
case "Array":
|
38157
|
+
return copy([]);
|
38158
|
+
case "Date":
|
38159
|
+
return new Date(value.valueOf());
|
38160
|
+
case "RegExp":
|
38161
|
+
return _cloneRegExp(value);
|
38162
|
+
case "Int8Array":
|
38163
|
+
case "Uint8Array":
|
38164
|
+
case "Uint8ClampedArray":
|
38165
|
+
case "Int16Array":
|
38166
|
+
case "Uint16Array":
|
38167
|
+
case "Int32Array":
|
38168
|
+
case "Uint32Array":
|
38169
|
+
case "Float32Array":
|
38170
|
+
case "Float64Array":
|
38171
|
+
case "BigInt64Array":
|
38172
|
+
case "BigUint64Array":
|
38173
|
+
return value.slice();
|
38174
|
+
default:
|
38175
|
+
return value;
|
38176
|
+
}
|
38177
|
+
}
|
38178
|
+
function _isPrimitive(param) {
|
38179
|
+
var type3 = typeof param;
|
38180
|
+
return param == null || type3 != "object" && type3 != "function";
|
38181
|
+
}
|
38182
|
+
var _ObjectMap = /* @__PURE__ */ function() {
|
38183
|
+
function _ObjectMap2() {
|
38184
|
+
this.map = {};
|
38185
|
+
this.length = 0;
|
38186
|
+
}
|
38187
|
+
_ObjectMap2.prototype.set = function(key, value) {
|
38188
|
+
const hashedKey = this.hash(key);
|
38189
|
+
let bucket = this.map[hashedKey];
|
38190
|
+
if (!bucket) {
|
38191
|
+
this.map[hashedKey] = bucket = [];
|
38192
|
+
}
|
38193
|
+
bucket.push([key, value]);
|
38194
|
+
this.length += 1;
|
38195
|
+
};
|
38196
|
+
_ObjectMap2.prototype.hash = function(key) {
|
38197
|
+
let hashedKey = [];
|
38198
|
+
for (var value in key) {
|
38199
|
+
hashedKey.push(Object.prototype.toString.call(key[value]));
|
38200
|
+
}
|
38201
|
+
return hashedKey.join();
|
38202
|
+
};
|
38203
|
+
_ObjectMap2.prototype.get = function(key) {
|
38204
|
+
if (this.length <= 180) {
|
38205
|
+
for (const p in this.map) {
|
38206
|
+
const bucket2 = this.map[p];
|
38207
|
+
for (let i = 0; i < bucket2.length; i += 1) {
|
38208
|
+
const element = bucket2[i];
|
38209
|
+
if (element[0] === key) {
|
38210
|
+
return element[1];
|
38211
|
+
}
|
38212
|
+
}
|
38213
|
+
}
|
38214
|
+
return;
|
38215
|
+
}
|
38216
|
+
const hashedKey = this.hash(key);
|
38217
|
+
const bucket = this.map[hashedKey];
|
38218
|
+
if (!bucket) {
|
38219
|
+
return;
|
38220
|
+
}
|
38221
|
+
for (let i = 0; i < bucket.length; i += 1) {
|
38222
|
+
const element = bucket[i];
|
38223
|
+
if (element[0] === key) {
|
38224
|
+
return element[1];
|
38225
|
+
}
|
38226
|
+
}
|
38227
|
+
};
|
38228
|
+
return _ObjectMap2;
|
38229
|
+
}();
|
38230
|
+
|
38231
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/clone.js
|
38232
|
+
var clone2 = /* @__PURE__ */ _curry1(function clone3(value) {
|
38233
|
+
return value != null && typeof value.clone === "function" ? value.clone() : _clone(value, true);
|
38234
|
+
});
|
38235
|
+
var clone_default = clone2;
|
38236
|
+
|
38237
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/trim.js
|
38238
|
+
var hasProtoTrim = typeof String.prototype.trim === "function";
|
38239
|
+
|
38207
38240
|
// ../../node_modules/.pnpm/tslib@2.6.0/node_modules/tslib/tslib.es6.mjs
|
38208
38241
|
var __assign = function() {
|
38209
38242
|
__assign = Object.assign || function __assign2(t) {
|
@@ -41371,10 +41404,14 @@ spurious results.`);
|
|
41371
41404
|
// src/providers/__generated__/operations.ts
|
41372
41405
|
var ReceiptFragmentFragmentDoc = lib_default2`
|
41373
41406
|
fragment receiptFragment on Receipt {
|
41374
|
-
|
41407
|
+
contract {
|
41408
|
+
id
|
41409
|
+
}
|
41375
41410
|
pc
|
41376
41411
|
is
|
41377
|
-
to
|
41412
|
+
to {
|
41413
|
+
id
|
41414
|
+
}
|
41378
41415
|
toAddress
|
41379
41416
|
amount
|
41380
41417
|
assetId
|
@@ -41412,16 +41449,10 @@ spurious results.`);
|
|
41412
41449
|
id
|
41413
41450
|
}
|
41414
41451
|
time
|
41415
|
-
receipts {
|
41416
|
-
...receiptFragment
|
41417
|
-
}
|
41418
41452
|
programState {
|
41419
41453
|
returnType
|
41420
41454
|
data
|
41421
41455
|
}
|
41422
|
-
receipts {
|
41423
|
-
...receiptFragment
|
41424
|
-
}
|
41425
41456
|
}
|
41426
41457
|
... on FailureStatus {
|
41427
41458
|
block {
|
@@ -41429,24 +41460,26 @@ spurious results.`);
|
|
41429
41460
|
}
|
41430
41461
|
time
|
41431
41462
|
reason
|
41432
|
-
receipts {
|
41433
|
-
...receiptFragment
|
41434
|
-
}
|
41435
41463
|
}
|
41436
41464
|
... on SqueezedOutStatus {
|
41437
41465
|
reason
|
41438
41466
|
}
|
41439
41467
|
}
|
41440
|
-
|
41468
|
+
`;
|
41441
41469
|
var TransactionFragmentFragmentDoc = lib_default2`
|
41442
41470
|
fragment transactionFragment on Transaction {
|
41443
41471
|
id
|
41444
41472
|
rawPayload
|
41473
|
+
gasPrice
|
41474
|
+
receipts {
|
41475
|
+
...receiptFragment
|
41476
|
+
}
|
41445
41477
|
status {
|
41446
41478
|
...transactionStatusFragment
|
41447
41479
|
}
|
41448
41480
|
}
|
41449
|
-
${
|
41481
|
+
${ReceiptFragmentFragmentDoc}
|
41482
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
41450
41483
|
var InputEstimatePredicatesFragmentFragmentDoc = lib_default2`
|
41451
41484
|
fragment inputEstimatePredicatesFragment on Input {
|
41452
41485
|
... on InputCoin {
|
@@ -41464,46 +41497,6 @@ spurious results.`);
|
|
41464
41497
|
}
|
41465
41498
|
}
|
41466
41499
|
${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}`;
|
41507
41500
|
var CoinFragmentFragmentDoc = lib_default2`
|
41508
41501
|
fragment coinFragment on Coin {
|
41509
41502
|
__typename
|
@@ -41511,6 +41504,7 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
41511
41504
|
owner
|
41512
41505
|
amount
|
41513
41506
|
assetId
|
41507
|
+
maturity
|
41514
41508
|
blockCreated
|
41515
41509
|
txCreatedIdx
|
41516
41510
|
}
|
@@ -41587,8 +41581,8 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
41587
41581
|
var BlockFragmentFragmentDoc = lib_default2`
|
41588
41582
|
fragment blockFragment on Block {
|
41589
41583
|
id
|
41590
|
-
height
|
41591
41584
|
header {
|
41585
|
+
height
|
41592
41586
|
time
|
41593
41587
|
}
|
41594
41588
|
transactions {
|
@@ -41658,6 +41652,7 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
41658
41652
|
cb
|
41659
41653
|
cfei
|
41660
41654
|
cfsi
|
41655
|
+
croo
|
41661
41656
|
div
|
41662
41657
|
divi
|
41663
41658
|
ecr1
|
@@ -41740,9 +41735,6 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
41740
41735
|
ccp {
|
41741
41736
|
...DependentCostFragment
|
41742
41737
|
}
|
41743
|
-
croo {
|
41744
|
-
...DependentCostFragment
|
41745
|
-
}
|
41746
41738
|
csiz {
|
41747
41739
|
...DependentCostFragment
|
41748
41740
|
}
|
@@ -41865,6 +41857,14 @@ ${ConsensusParametersFragmentFragmentDoc}`;
|
|
41865
41857
|
maxTx
|
41866
41858
|
maxDepth
|
41867
41859
|
nodeVersion
|
41860
|
+
peers {
|
41861
|
+
id
|
41862
|
+
addresses
|
41863
|
+
clientVersion
|
41864
|
+
blockHeight
|
41865
|
+
lastHeartbeatMs
|
41866
|
+
appScore
|
41867
|
+
}
|
41868
41868
|
}
|
41869
41869
|
`;
|
41870
41870
|
var GetVersionDocument = lib_default2`
|
@@ -41899,9 +41899,13 @@ ${ConsensusParametersFragmentFragmentDoc}`;
|
|
41899
41899
|
query getTransactionWithReceipts($transactionId: TransactionId!) {
|
41900
41900
|
transaction(id: $transactionId) {
|
41901
41901
|
...transactionFragment
|
41902
|
+
receipts {
|
41903
|
+
...receiptFragment
|
41904
|
+
}
|
41902
41905
|
}
|
41903
41906
|
}
|
41904
|
-
${TransactionFragmentFragmentDoc}
|
41907
|
+
${TransactionFragmentFragmentDoc}
|
41908
|
+
${ReceiptFragmentFragmentDoc}`;
|
41905
41909
|
var GetTransactionsDocument = lib_default2`
|
41906
41910
|
query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
|
41907
41911
|
transactions(after: $after, before: $before, first: $first, last: $last) {
|
@@ -42029,20 +42033,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42029
42033
|
}
|
42030
42034
|
}
|
42031
42035
|
${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
|
-
`;
|
42046
42036
|
var GetBalancesDocument = lib_default2`
|
42047
42037
|
query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
42048
42038
|
balances(
|
@@ -42097,12 +42087,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42097
42087
|
}
|
42098
42088
|
`;
|
42099
42089
|
var DryRunDocument = lib_default2`
|
42100
|
-
mutation dryRun($
|
42101
|
-
dryRun(
|
42102
|
-
...
|
42090
|
+
mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
|
42091
|
+
dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
|
42092
|
+
...receiptFragment
|
42103
42093
|
}
|
42104
42094
|
}
|
42105
|
-
${
|
42095
|
+
${ReceiptFragmentFragmentDoc}`;
|
42106
42096
|
var SubmitDocument = lib_default2`
|
42107
42097
|
mutation submit($encodedTransaction: HexString!) {
|
42108
42098
|
submit(tx: $encodedTransaction) {
|
@@ -42185,12 +42175,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42185
42175
|
getBalance(variables, options) {
|
42186
42176
|
return requester(GetBalanceDocument, variables, options);
|
42187
42177
|
},
|
42188
|
-
getLatestGasPrice(variables, options) {
|
42189
|
-
return requester(GetLatestGasPriceDocument, variables, options);
|
42190
|
-
},
|
42191
|
-
estimateGasPrice(variables, options) {
|
42192
|
-
return requester(EstimateGasPriceDocument, variables, options);
|
42193
|
-
},
|
42194
42178
|
getBalances(variables, options) {
|
42195
42179
|
return requester(GetBalancesDocument, variables, options);
|
42196
42180
|
},
|
@@ -42365,6 +42349,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42365
42349
|
txIndex: toNumber2(arrayify(value.txPointer).slice(8, 16))
|
42366
42350
|
},
|
42367
42351
|
witnessIndex: value.witnessIndex,
|
42352
|
+
maturity: value.maturity ?? 0,
|
42368
42353
|
predicateGasUsed: bn(value.predicateGasUsed),
|
42369
42354
|
predicateLength: predicate.length,
|
42370
42355
|
predicateDataLength: predicateData.length,
|
@@ -42556,8 +42541,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42556
42541
|
case "CALL" /* Call */: {
|
42557
42542
|
const callReceipt = {
|
42558
42543
|
type: ReceiptType.Call,
|
42559
|
-
from: hexOrZero(receipt.id
|
42560
|
-
to: hexOrZero(receipt?.to),
|
42544
|
+
from: hexOrZero(receipt.contract?.id),
|
42545
|
+
to: hexOrZero(receipt?.to?.id),
|
42561
42546
|
amount: bn(receipt.amount),
|
42562
42547
|
assetId: hexOrZero(receipt.assetId),
|
42563
42548
|
gas: bn(receipt.gas),
|
@@ -42571,7 +42556,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42571
42556
|
case "RETURN" /* Return */: {
|
42572
42557
|
const returnReceipt = {
|
42573
42558
|
type: ReceiptType.Return,
|
42574
|
-
id: hexOrZero(receipt.id
|
42559
|
+
id: hexOrZero(receipt.contract?.id),
|
42575
42560
|
val: bn(receipt.val),
|
42576
42561
|
pc: bn(receipt.pc),
|
42577
42562
|
is: bn(receipt.is)
|
@@ -42581,7 +42566,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42581
42566
|
case "RETURN_DATA" /* ReturnData */: {
|
42582
42567
|
const returnDataReceipt = {
|
42583
42568
|
type: ReceiptType.ReturnData,
|
42584
|
-
id: hexOrZero(receipt.id
|
42569
|
+
id: hexOrZero(receipt.contract?.id),
|
42585
42570
|
ptr: bn(receipt.ptr),
|
42586
42571
|
len: bn(receipt.len),
|
42587
42572
|
digest: hexOrZero(receipt.digest),
|
@@ -42593,7 +42578,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42593
42578
|
case "PANIC" /* Panic */: {
|
42594
42579
|
const panicReceipt = {
|
42595
42580
|
type: ReceiptType.Panic,
|
42596
|
-
id: hexOrZero(receipt.id),
|
42581
|
+
id: hexOrZero(receipt.contract?.id),
|
42597
42582
|
reason: bn(receipt.reason),
|
42598
42583
|
pc: bn(receipt.pc),
|
42599
42584
|
is: bn(receipt.is),
|
@@ -42604,7 +42589,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42604
42589
|
case "REVERT" /* Revert */: {
|
42605
42590
|
const revertReceipt = {
|
42606
42591
|
type: ReceiptType.Revert,
|
42607
|
-
id: hexOrZero(receipt.id
|
42592
|
+
id: hexOrZero(receipt.contract?.id),
|
42608
42593
|
val: bn(receipt.ra),
|
42609
42594
|
pc: bn(receipt.pc),
|
42610
42595
|
is: bn(receipt.is)
|
@@ -42614,7 +42599,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42614
42599
|
case "LOG" /* Log */: {
|
42615
42600
|
const logReceipt = {
|
42616
42601
|
type: ReceiptType.Log,
|
42617
|
-
id: hexOrZero(receipt.id
|
42602
|
+
id: hexOrZero(receipt.contract?.id),
|
42618
42603
|
val0: bn(receipt.ra),
|
42619
42604
|
val1: bn(receipt.rb),
|
42620
42605
|
val2: bn(receipt.rc),
|
@@ -42627,7 +42612,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42627
42612
|
case "LOG_DATA" /* LogData */: {
|
42628
42613
|
const logDataReceipt = {
|
42629
42614
|
type: ReceiptType.LogData,
|
42630
|
-
id: hexOrZero(receipt.id
|
42615
|
+
id: hexOrZero(receipt.contract?.id),
|
42631
42616
|
val0: bn(receipt.ra),
|
42632
42617
|
val1: bn(receipt.rb),
|
42633
42618
|
ptr: bn(receipt.ptr),
|
@@ -42641,8 +42626,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42641
42626
|
case "TRANSFER" /* Transfer */: {
|
42642
42627
|
const transferReceipt = {
|
42643
42628
|
type: ReceiptType.Transfer,
|
42644
|
-
from: hexOrZero(receipt.id
|
42645
|
-
to: hexOrZero(receipt.toAddress || receipt?.to),
|
42629
|
+
from: hexOrZero(receipt.contract?.id),
|
42630
|
+
to: hexOrZero(receipt.toAddress || receipt?.to?.id),
|
42646
42631
|
amount: bn(receipt.amount),
|
42647
42632
|
assetId: hexOrZero(receipt.assetId),
|
42648
42633
|
pc: bn(receipt.pc),
|
@@ -42653,8 +42638,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42653
42638
|
case "TRANSFER_OUT" /* TransferOut */: {
|
42654
42639
|
const transferOutReceipt = {
|
42655
42640
|
type: ReceiptType.TransferOut,
|
42656
|
-
from: hexOrZero(receipt.id
|
42657
|
-
to: hexOrZero(receipt.toAddress || receipt.to),
|
42641
|
+
from: hexOrZero(receipt.contract?.id),
|
42642
|
+
to: hexOrZero(receipt.toAddress || receipt.to?.id),
|
42658
42643
|
amount: bn(receipt.amount),
|
42659
42644
|
assetId: hexOrZero(receipt.assetId),
|
42660
42645
|
pc: bn(receipt.pc),
|
@@ -42697,7 +42682,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42697
42682
|
return receiptMessageOut;
|
42698
42683
|
}
|
42699
42684
|
case "MINT" /* Mint */: {
|
42700
|
-
const contractId = hexOrZero(receipt.id
|
42685
|
+
const contractId = hexOrZero(receipt.contract?.id);
|
42701
42686
|
const subId = hexOrZero(receipt.subId);
|
42702
42687
|
const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
|
42703
42688
|
const mintReceipt = {
|
@@ -42712,7 +42697,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42712
42697
|
return mintReceipt;
|
42713
42698
|
}
|
42714
42699
|
case "BURN" /* Burn */: {
|
42715
|
-
const contractId = hexOrZero(receipt.id
|
42700
|
+
const contractId = hexOrZero(receipt.contract?.id);
|
42716
42701
|
const subId = hexOrZero(receipt.subId);
|
42717
42702
|
const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
|
42718
42703
|
const burnReceipt = {
|
@@ -42732,6 +42717,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42732
42717
|
}
|
42733
42718
|
|
42734
42719
|
// src/providers/utils/gas.ts
|
42720
|
+
var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
|
42735
42721
|
var getGasUsedFromReceipts = (receipts) => {
|
42736
42722
|
const scriptResult = receipts.filter(
|
42737
42723
|
(receipt) => receipt.type === ReceiptType.ScriptResult
|
@@ -42752,28 +42738,18 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42752
42738
|
}
|
42753
42739
|
function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
42754
42740
|
const witnessCache = [];
|
42755
|
-
const
|
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) => {
|
42741
|
+
const totalGas = inputs.reduce((total, input) => {
|
42770
42742
|
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
42771
42743
|
return total.add(
|
42772
|
-
|
42744
|
+
resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify(input.predicate).length, gasCosts.contractRoot)).add(bn(input.predicateGasUsed))
|
42773
42745
|
);
|
42774
42746
|
}
|
42775
|
-
|
42776
|
-
|
42747
|
+
if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
|
42748
|
+
witnessCache.push(input.witnessIndex);
|
42749
|
+
return total.add(gasCosts.ecr1);
|
42750
|
+
}
|
42751
|
+
return total;
|
42752
|
+
}, bn());
|
42777
42753
|
return totalGas;
|
42778
42754
|
}
|
42779
42755
|
function getMinGas(params) {
|
@@ -42785,20 +42761,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42785
42761
|
return minGas;
|
42786
42762
|
}
|
42787
42763
|
function getMaxGas(params) {
|
42788
|
-
const {
|
42789
|
-
gasPerByte,
|
42790
|
-
witnessesLength,
|
42791
|
-
witnessLimit,
|
42792
|
-
minGas,
|
42793
|
-
gasLimit = bn(0),
|
42794
|
-
maxGasPerTx
|
42795
|
-
} = params;
|
42764
|
+
const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = bn(0) } = params;
|
42796
42765
|
let remainingAllowedWitnessGas = bn(0);
|
42797
42766
|
if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
|
42798
42767
|
remainingAllowedWitnessGas = bn(witnessLimit).sub(witnessesLength).mul(gasPerByte);
|
42799
42768
|
}
|
42800
|
-
|
42801
|
-
return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
|
42769
|
+
return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
|
42802
42770
|
}
|
42803
42771
|
function calculateMetadataGasForTxCreate({
|
42804
42772
|
gasCosts,
|
@@ -42820,10 +42788,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42820
42788
|
}) {
|
42821
42789
|
return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
42822
42790
|
}
|
42823
|
-
var calculateGasFee = (params) => {
|
42824
|
-
const { gas, gasPrice, priceFactor, tip } = params;
|
42825
|
-
return gas.mul(gasPrice).div(priceFactor).add(tip);
|
42826
|
-
};
|
42827
42791
|
|
42828
42792
|
// src/providers/utils/json.ts
|
42829
42793
|
function normalize2(object) {
|
@@ -42953,7 +42917,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42953
42917
|
// src/providers/transaction-request/transaction-request.ts
|
42954
42918
|
var BaseTransactionRequest = class {
|
42955
42919
|
/** Gas price for transaction */
|
42956
|
-
|
42920
|
+
gasPrice;
|
42957
42921
|
/** Block until which tx cannot be included */
|
42958
42922
|
maturity;
|
42959
42923
|
/** The maximum fee payable by this transaction using BASE_ASSET. */
|
@@ -42972,7 +42936,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42972
42936
|
* @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
|
42973
42937
|
*/
|
42974
42938
|
constructor({
|
42975
|
-
|
42939
|
+
gasPrice,
|
42976
42940
|
maturity,
|
42977
42941
|
maxFee,
|
42978
42942
|
witnessLimit,
|
@@ -42980,7 +42944,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42980
42944
|
outputs,
|
42981
42945
|
witnesses
|
42982
42946
|
} = {}) {
|
42983
|
-
this.
|
42947
|
+
this.gasPrice = bn(gasPrice);
|
42984
42948
|
this.maturity = maturity ?? 0;
|
42985
42949
|
this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
|
42986
42950
|
this.maxFee = maxFee ? bn(maxFee) : void 0;
|
@@ -42991,9 +42955,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42991
42955
|
static getPolicyMeta(req) {
|
42992
42956
|
let policyTypes = 0;
|
42993
42957
|
const policies = [];
|
42994
|
-
if (req.
|
42995
|
-
policyTypes += PolicyType.
|
42996
|
-
policies.push({ data: req.
|
42958
|
+
if (req.gasPrice) {
|
42959
|
+
policyTypes += PolicyType.GasPrice;
|
42960
|
+
policies.push({ data: req.gasPrice, type: PolicyType.GasPrice });
|
42997
42961
|
}
|
42998
42962
|
if (req.witnessLimit) {
|
42999
42963
|
policyTypes += PolicyType.WitnessLimit;
|
@@ -43180,10 +43144,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43180
43144
|
* @param predicate - Predicate bytes.
|
43181
43145
|
* @param predicateData - Predicate data bytes.
|
43182
43146
|
*/
|
43183
|
-
addCoinInput(coin) {
|
43147
|
+
addCoinInput(coin, predicate) {
|
43184
43148
|
const { assetId, owner, amount } = coin;
|
43185
43149
|
let witnessIndex;
|
43186
|
-
if (
|
43150
|
+
if (predicate) {
|
43187
43151
|
witnessIndex = 0;
|
43188
43152
|
} else {
|
43189
43153
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
|
@@ -43198,7 +43162,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43198
43162
|
amount,
|
43199
43163
|
assetId,
|
43200
43164
|
txPointer: "0x00000000000000000000000000000000",
|
43201
|
-
witnessIndex
|
43165
|
+
witnessIndex,
|
43166
|
+
predicate: predicate?.bytes,
|
43167
|
+
predicateData: predicate?.predicateDataBytes
|
43202
43168
|
};
|
43203
43169
|
this.pushInput(input);
|
43204
43170
|
this.addChangeOutput(owner, assetId);
|
@@ -43211,11 +43177,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43211
43177
|
* @param predicate - Predicate bytes.
|
43212
43178
|
* @param predicateData - Predicate data bytes.
|
43213
43179
|
*/
|
43214
|
-
addMessageInput(message) {
|
43180
|
+
addMessageInput(message, predicate) {
|
43215
43181
|
const { recipient, sender, amount } = message;
|
43216
43182
|
const assetId = BaseAssetId;
|
43217
43183
|
let witnessIndex;
|
43218
|
-
if (
|
43184
|
+
if (predicate) {
|
43219
43185
|
witnessIndex = 0;
|
43220
43186
|
} else {
|
43221
43187
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
|
@@ -43229,7 +43195,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43229
43195
|
sender: sender.toB256(),
|
43230
43196
|
recipient: recipient.toB256(),
|
43231
43197
|
amount,
|
43232
|
-
witnessIndex
|
43198
|
+
witnessIndex,
|
43199
|
+
predicate: predicate?.bytes,
|
43200
|
+
predicateData: predicate?.predicateDataBytes
|
43233
43201
|
};
|
43234
43202
|
this.pushInput(input);
|
43235
43203
|
this.addChangeOutput(recipient, assetId);
|
@@ -43260,6 +43228,32 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43260
43228
|
resources.forEach((resource) => this.addResource(resource));
|
43261
43229
|
return this;
|
43262
43230
|
}
|
43231
|
+
/**
|
43232
|
+
* Adds multiple resources to the transaction by adding coin/message inputs and change
|
43233
|
+
* outputs from the related assetIds.
|
43234
|
+
*
|
43235
|
+
* @param resources - The resources to add.
|
43236
|
+
* @returns This transaction.
|
43237
|
+
*/
|
43238
|
+
addPredicateResource(resource, predicate) {
|
43239
|
+
if (isCoin(resource)) {
|
43240
|
+
this.addCoinInput(resource, predicate);
|
43241
|
+
} else {
|
43242
|
+
this.addMessageInput(resource, predicate);
|
43243
|
+
}
|
43244
|
+
return this;
|
43245
|
+
}
|
43246
|
+
/**
|
43247
|
+
* Adds multiple predicate coin/message inputs to the transaction and change outputs
|
43248
|
+
* from the related assetIds.
|
43249
|
+
*
|
43250
|
+
* @param resources - The resources to add.
|
43251
|
+
* @returns This transaction.
|
43252
|
+
*/
|
43253
|
+
addPredicateResources(resources, predicate) {
|
43254
|
+
resources.forEach((resource) => this.addPredicateResource(resource, predicate));
|
43255
|
+
return this;
|
43256
|
+
}
|
43263
43257
|
/**
|
43264
43258
|
* Adds a coin output to the transaction.
|
43265
43259
|
*
|
@@ -43339,7 +43333,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43339
43333
|
}
|
43340
43334
|
calculateMaxGas(chainInfo, minGas) {
|
43341
43335
|
const { consensusParameters } = chainInfo;
|
43342
|
-
const { gasPerByte
|
43336
|
+
const { gasPerByte } = consensusParameters;
|
43343
43337
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
43344
43338
|
(acc, wit) => acc + wit.dataLength,
|
43345
43339
|
0
|
@@ -43348,8 +43342,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43348
43342
|
gasPerByte,
|
43349
43343
|
minGas,
|
43350
43344
|
witnessesLength,
|
43351
|
-
witnessLimit: this.witnessLimit
|
43352
|
-
maxGasPerTx
|
43345
|
+
witnessLimit: this.witnessLimit
|
43353
43346
|
});
|
43354
43347
|
}
|
43355
43348
|
/**
|
@@ -43359,6 +43352,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43359
43352
|
* @param quantities - CoinQuantity Array.
|
43360
43353
|
*/
|
43361
43354
|
fundWithFakeUtxos(quantities, resourcesOwner) {
|
43355
|
+
let idCounter = 0;
|
43356
|
+
const generateId = () => {
|
43357
|
+
const counterString = String(idCounter++);
|
43358
|
+
const id = ZeroBytes32.slice(0, -counterString.length).concat(counterString);
|
43359
|
+
return id;
|
43360
|
+
};
|
43362
43361
|
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
43363
43362
|
if ("assetId" in input) {
|
43364
43363
|
return input.assetId === assetId;
|
@@ -43367,20 +43366,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43367
43366
|
});
|
43368
43367
|
const updateAssetInput = (assetId, quantity) => {
|
43369
43368
|
const assetInput = findAssetInput(assetId);
|
43370
|
-
let usedQuantity = quantity;
|
43371
|
-
if (assetId === BaseAssetId) {
|
43372
|
-
usedQuantity = bn("1000000000000000000");
|
43373
|
-
}
|
43374
43369
|
if (assetInput && "assetId" in assetInput) {
|
43375
|
-
assetInput.id =
|
43376
|
-
assetInput.amount =
|
43370
|
+
assetInput.id = generateId();
|
43371
|
+
assetInput.amount = quantity;
|
43377
43372
|
} else {
|
43378
43373
|
this.addResources([
|
43379
43374
|
{
|
43380
|
-
id:
|
43381
|
-
amount:
|
43375
|
+
id: generateId(),
|
43376
|
+
amount: quantity,
|
43382
43377
|
assetId,
|
43383
43378
|
owner: resourcesOwner || Address.fromRandom(),
|
43379
|
+
maturity: 0,
|
43384
43380
|
blockCreated: bn(1),
|
43385
43381
|
txCreatedIdx: bn(1)
|
43386
43382
|
}
|
@@ -43412,7 +43408,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43412
43408
|
toJSON() {
|
43413
43409
|
return normalizeJSON(this);
|
43414
43410
|
}
|
43415
|
-
|
43411
|
+
updatePredicateInputs(inputs) {
|
43416
43412
|
this.inputs.forEach((i) => {
|
43417
43413
|
let correspondingInput;
|
43418
43414
|
switch (i.type) {
|
@@ -43434,15 +43430,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43434
43430
|
}
|
43435
43431
|
});
|
43436
43432
|
}
|
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
|
-
}
|
43446
43433
|
};
|
43447
43434
|
|
43448
43435
|
// src/providers/transaction-request/hash-transaction.ts
|
@@ -43757,7 +43744,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43757
43744
|
}
|
43758
43745
|
calculateMaxGas(chainInfo, minGas) {
|
43759
43746
|
const { consensusParameters } = chainInfo;
|
43760
|
-
const { gasPerByte
|
43747
|
+
const { gasPerByte } = consensusParameters;
|
43761
43748
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
43762
43749
|
(acc, wit) => acc + wit.dataLength,
|
43763
43750
|
0
|
@@ -43767,8 +43754,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43767
43754
|
minGas,
|
43768
43755
|
witnessesLength,
|
43769
43756
|
witnessLimit: this.witnessLimit,
|
43770
|
-
gasLimit: this.gasLimit
|
43771
|
-
maxGasPerTx
|
43757
|
+
gasLimit: this.gasLimit
|
43772
43758
|
});
|
43773
43759
|
}
|
43774
43760
|
/**
|
@@ -43841,29 +43827,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43841
43827
|
}
|
43842
43828
|
}
|
43843
43829
|
};
|
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
|
-
);
|
43859
43830
|
|
43860
43831
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
43861
43832
|
var calculateTransactionFee = (params) => {
|
43862
43833
|
const {
|
43863
|
-
|
43834
|
+
gasUsed,
|
43864
43835
|
rawPayload,
|
43865
|
-
|
43866
|
-
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
43836
|
+
consensusParameters: { gasCosts, feeParams }
|
43867
43837
|
} = params;
|
43868
43838
|
const gasPerByte = bn(feeParams.gasPerByte);
|
43869
43839
|
const gasPriceFactor = bn(feeParams.gasPriceFactor);
|
@@ -43873,7 +43843,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43873
43843
|
return {
|
43874
43844
|
fee: bn(0),
|
43875
43845
|
minFee: bn(0),
|
43876
|
-
maxFee: bn(0)
|
43846
|
+
maxFee: bn(0),
|
43847
|
+
feeFromGasUsed: bn(0)
|
43877
43848
|
};
|
43878
43849
|
}
|
43879
43850
|
const { type: type3, witnesses, inputs, policies } = transaction;
|
@@ -43905,6 +43876,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43905
43876
|
metadataGas,
|
43906
43877
|
txBytesSize: transactionBytes.length
|
43907
43878
|
});
|
43879
|
+
const gasPrice = bn(policies.find((policy) => policy.type === PolicyType.GasPrice)?.data);
|
43908
43880
|
const witnessLimit = policies.find((policy) => policy.type === PolicyType.WitnessLimit)?.data;
|
43909
43881
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
43910
43882
|
const maxGas = getMaxGas({
|
@@ -43912,25 +43884,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43912
43884
|
minGas,
|
43913
43885
|
witnessesLength,
|
43914
43886
|
gasLimit,
|
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
|
43887
|
+
witnessLimit
|
43929
43888
|
});
|
43889
|
+
const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
|
43890
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
|
43891
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
|
43892
|
+
const fee = minFee.add(feeFromGasUsed);
|
43930
43893
|
return {
|
43894
|
+
fee,
|
43931
43895
|
minFee,
|
43932
43896
|
maxFee,
|
43933
|
-
|
43897
|
+
feeFromGasUsed
|
43934
43898
|
};
|
43935
43899
|
};
|
43936
43900
|
|
@@ -44484,9 +44448,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44484
44448
|
gqlTransactionStatus,
|
44485
44449
|
abiMap = {},
|
44486
44450
|
maxInputs,
|
44487
|
-
gasCosts
|
44488
|
-
maxGasPerTx,
|
44489
|
-
gasPrice
|
44451
|
+
gasCosts
|
44490
44452
|
} = params;
|
44491
44453
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
44492
44454
|
const rawPayload = hexlify(transactionBytes);
|
@@ -44500,14 +44462,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44500
44462
|
maxInputs
|
44501
44463
|
});
|
44502
44464
|
const typeName = getTransactionTypeName(transaction.type);
|
44503
|
-
const tip = bn(transaction.policies?.find((policy) => policy.type === PolicyType.Tip)?.data);
|
44504
44465
|
const { fee } = calculateTransactionFee({
|
44505
|
-
|
44466
|
+
gasUsed,
|
44506
44467
|
rawPayload,
|
44507
|
-
tip,
|
44508
44468
|
consensusParameters: {
|
44509
44469
|
gasCosts,
|
44510
|
-
maxGasPerTx,
|
44511
44470
|
feeParams: {
|
44512
44471
|
gasPerByte,
|
44513
44472
|
gasPriceFactor
|
@@ -44643,13 +44602,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44643
44602
|
const decodedTransaction = this.decodeTransaction(
|
44644
44603
|
transaction
|
44645
44604
|
);
|
44646
|
-
|
44647
|
-
|
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();
|
44605
|
+
const receipts = transaction.receipts?.map(processGqlReceipt) || [];
|
44606
|
+
const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
|
44653
44607
|
const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
|
44654
44608
|
const transactionSummary = assembleTransactionSummary({
|
44655
44609
|
id: this.id,
|
@@ -44661,9 +44615,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44661
44615
|
gasPriceFactor,
|
44662
44616
|
abiMap: contractsAbiMap,
|
44663
44617
|
maxInputs,
|
44664
|
-
gasCosts
|
44665
|
-
maxGasPerTx,
|
44666
|
-
gasPrice
|
44618
|
+
gasCosts
|
44667
44619
|
});
|
44668
44620
|
return transactionSummary;
|
44669
44621
|
}
|
@@ -44812,7 +44764,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44812
44764
|
gasCosts,
|
44813
44765
|
latestBlock: {
|
44814
44766
|
id: latestBlock.id,
|
44815
|
-
height: bn(latestBlock.height),
|
44767
|
+
height: bn(latestBlock.header.height),
|
44816
44768
|
time: latestBlock.header.time,
|
44817
44769
|
transactions: latestBlock.transactions.map((i) => ({
|
44818
44770
|
id: i.id
|
@@ -45007,7 +44959,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45007
44959
|
*/
|
45008
44960
|
async getBlockNumber() {
|
45009
44961
|
const { chain } = await this.operations.getChain();
|
45010
|
-
return bn(chain.latestBlock.height, 10);
|
44962
|
+
return bn(chain.latestBlock.header.height, 10);
|
45011
44963
|
}
|
45012
44964
|
/**
|
45013
44965
|
* Returns the chain information.
|
@@ -45022,7 +44974,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45022
44974
|
minGasPrice: bn(nodeInfo.minGasPrice),
|
45023
44975
|
nodeVersion: nodeInfo.nodeVersion,
|
45024
44976
|
utxoValidation: nodeInfo.utxoValidation,
|
45025
|
-
vmBacktrace: nodeInfo.vmBacktrace
|
44977
|
+
vmBacktrace: nodeInfo.vmBacktrace,
|
44978
|
+
peers: nodeInfo.peers
|
45026
44979
|
};
|
45027
44980
|
_Provider.nodeInfoCache[this.url] = processedNodeInfo;
|
45028
44981
|
return processedNodeInfo;
|
@@ -45108,13 +45061,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45108
45061
|
return this.estimateTxDependencies(transactionRequest);
|
45109
45062
|
}
|
45110
45063
|
const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
|
45111
|
-
const { dryRun:
|
45112
|
-
|
45064
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
45065
|
+
encodedTransaction,
|
45113
45066
|
utxoValidation: utxoValidation || false
|
45114
45067
|
});
|
45115
|
-
const
|
45116
|
-
|
45117
|
-
|
45068
|
+
const receipts = gqlReceipts.map(processGqlReceipt);
|
45069
|
+
return {
|
45070
|
+
receipts
|
45071
|
+
};
|
45118
45072
|
}
|
45119
45073
|
/**
|
45120
45074
|
* Verifies whether enough gas is available to complete transaction.
|
@@ -45153,6 +45107,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45153
45107
|
* If there are missing variable outputs,
|
45154
45108
|
* `addVariableOutputs` is called on the transaction.
|
45155
45109
|
*
|
45110
|
+
* @privateRemarks
|
45111
|
+
* TODO: Investigate support for missing contract IDs
|
45112
|
+
* TODO: Add support for missing output messages
|
45156
45113
|
*
|
45157
45114
|
* @param transactionRequest - The transaction request object.
|
45158
45115
|
* @returns A promise.
|
@@ -45165,19 +45122,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45165
45122
|
missingContractIds: []
|
45166
45123
|
};
|
45167
45124
|
}
|
45125
|
+
await this.estimatePredicates(transactionRequest);
|
45168
45126
|
let receipts = [];
|
45169
45127
|
const missingContractIds = [];
|
45170
45128
|
let outputVariables = 0;
|
45171
|
-
let dryrunStatus;
|
45172
45129
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
45173
|
-
const {
|
45174
|
-
|
45175
|
-
} = await this.operations.dryRun({
|
45176
|
-
encodedTransactions: [hexlify(transactionRequest.toTransactionBytes())],
|
45130
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
45131
|
+
encodedTransaction: hexlify(transactionRequest.toTransactionBytes()),
|
45177
45132
|
utxoValidation: false
|
45178
45133
|
});
|
45179
|
-
receipts =
|
45180
|
-
dryrunStatus = status;
|
45134
|
+
receipts = gqlReceipts.map(processGqlReceipt);
|
45181
45135
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
45182
45136
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
45183
45137
|
if (hasMissingOutputs) {
|
@@ -45187,11 +45141,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45187
45141
|
transactionRequest.addContractInputAndOutput(Address.fromString(contractId));
|
45188
45142
|
missingContractIds.push(contractId);
|
45189
45143
|
});
|
45190
|
-
const { maxFee } = await this.estimateTxGasAndFee({
|
45191
|
-
transactionRequest,
|
45192
|
-
optimizeGas: false
|
45193
|
-
});
|
45194
|
-
transactionRequest.maxFee = maxFee;
|
45195
45144
|
} else {
|
45196
45145
|
break;
|
45197
45146
|
}
|
@@ -45199,133 +45148,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45199
45148
|
return {
|
45200
45149
|
receipts,
|
45201
45150
|
outputVariables,
|
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
|
45151
|
+
missingContractIds
|
45329
45152
|
};
|
45330
45153
|
}
|
45331
45154
|
/**
|
@@ -45343,17 +45166,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45343
45166
|
if (estimateTxDependencies) {
|
45344
45167
|
return this.estimateTxDependencies(transactionRequest);
|
45345
45168
|
}
|
45346
|
-
const
|
45347
|
-
const { dryRun:
|
45348
|
-
|
45169
|
+
const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
|
45170
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
45171
|
+
encodedTransaction,
|
45349
45172
|
utxoValidation: true
|
45350
45173
|
});
|
45351
|
-
const
|
45352
|
-
|
45353
|
-
|
45354
|
-
|
45355
|
-
});
|
45356
|
-
return { receipts: callResult[0].receipts };
|
45174
|
+
const receipts = gqlReceipts.map(processGqlReceipt);
|
45175
|
+
return {
|
45176
|
+
receipts
|
45177
|
+
};
|
45357
45178
|
}
|
45358
45179
|
/**
|
45359
45180
|
* Returns a transaction cost to enable user
|
@@ -45370,80 +45191,80 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45370
45191
|
* @param tolerance - The tolerance to add on top of the gasUsed.
|
45371
45192
|
* @returns A promise that resolves to the transaction cost object.
|
45372
45193
|
*/
|
45373
|
-
async getTransactionCost(transactionRequestLike,
|
45194
|
+
async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
|
45195
|
+
estimateTxDependencies = true,
|
45196
|
+
estimatePredicates = true,
|
45197
|
+
resourcesOwner,
|
45198
|
+
signatureCallback
|
45199
|
+
} = {}) {
|
45374
45200
|
const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
|
45201
|
+
const chainInfo = this.getChain();
|
45202
|
+
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
45203
|
+
const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
45375
45204
|
const isScriptTransaction = txRequestClone.type === TransactionType.Script;
|
45376
45205
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
45377
|
-
const allQuantities = mergeQuantities(coinOutputsQuantities,
|
45206
|
+
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
45378
45207
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
45379
|
-
|
45380
|
-
|
45381
|
-
|
45382
|
-
|
45383
|
-
|
45384
|
-
|
45208
|
+
if (estimatePredicates) {
|
45209
|
+
if (isScriptTransaction) {
|
45210
|
+
txRequestClone.gasLimit = bn(0);
|
45211
|
+
}
|
45212
|
+
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
45213
|
+
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
45214
|
+
}
|
45215
|
+
await this.estimatePredicates(txRequestClone);
|
45385
45216
|
}
|
45386
|
-
const signedRequest = clone_default(txRequestClone);
|
45387
|
-
let addedSignatures = 0;
|
45388
45217
|
if (signatureCallback && isScriptTransaction) {
|
45389
|
-
|
45390
|
-
|
45391
|
-
|
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;
|
45218
|
+
await signatureCallback(txRequestClone);
|
45219
|
+
}
|
45220
|
+
const minGas = txRequestClone.calculateMinGas(chainInfo);
|
45221
|
+
const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
|
45399
45222
|
let receipts = [];
|
45400
45223
|
let missingContractIds = [];
|
45401
45224
|
let outputVariables = 0;
|
45402
|
-
|
45403
|
-
|
45404
|
-
|
45405
|
-
if (signatureCallback) {
|
45406
|
-
await signatureCallback(txRequestClone);
|
45407
|
-
}
|
45408
|
-
txRequestClone.gasLimit = maxGas;
|
45225
|
+
if (isScriptTransaction && estimateTxDependencies) {
|
45226
|
+
txRequestClone.gasPrice = bn(0);
|
45227
|
+
txRequestClone.gasLimit = bn(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
|
45409
45228
|
const result = await this.estimateTxDependencies(txRequestClone);
|
45410
45229
|
receipts = result.receipts;
|
45411
45230
|
outputVariables = result.outputVariables;
|
45412
45231
|
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
|
-
}));
|
45419
45232
|
}
|
45233
|
+
const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
|
45234
|
+
const usedFee = calculatePriceWithFactor(
|
45235
|
+
gasUsed,
|
45236
|
+
gasPrice,
|
45237
|
+
gasPriceFactor
|
45238
|
+
).normalizeZeroToOne();
|
45239
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
45240
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
45420
45241
|
return {
|
45421
45242
|
requiredQuantities: allQuantities,
|
45422
45243
|
receipts,
|
45423
45244
|
gasUsed,
|
45245
|
+
minGasPrice,
|
45424
45246
|
gasPrice,
|
45425
45247
|
minGas,
|
45426
45248
|
maxGas,
|
45249
|
+
usedFee,
|
45427
45250
|
minFee,
|
45428
45251
|
maxFee,
|
45252
|
+
estimatedInputs: txRequestClone.inputs,
|
45429
45253
|
outputVariables,
|
45430
|
-
missingContractIds
|
45431
|
-
addedSignatures,
|
45432
|
-
estimatedPredicates: txRequestClone.inputs
|
45254
|
+
missingContractIds
|
45433
45255
|
};
|
45434
45256
|
}
|
45435
|
-
async getResourcesForTransaction(owner, transactionRequestLike,
|
45257
|
+
async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
|
45436
45258
|
const ownerAddress = Address.fromAddressOrString(owner);
|
45437
45259
|
const transactionRequest = transactionRequestify(clone_default(transactionRequestLike));
|
45438
|
-
const transactionCost = await this.getTransactionCost(transactionRequest,
|
45439
|
-
quantitiesToContract
|
45440
|
-
});
|
45260
|
+
const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
|
45441
45261
|
transactionRequest.addResources(
|
45442
45262
|
await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
|
45443
45263
|
);
|
45444
|
-
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
45445
|
-
|
45446
|
-
|
45264
|
+
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
45265
|
+
transactionRequest,
|
45266
|
+
forwardingQuantities
|
45267
|
+
);
|
45447
45268
|
const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
|
45448
45269
|
return {
|
45449
45270
|
resources,
|
@@ -45467,6 +45288,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45467
45288
|
assetId: coin.assetId,
|
45468
45289
|
amount: bn(coin.amount),
|
45469
45290
|
owner: Address.fromAddressOrString(coin.owner),
|
45291
|
+
maturity: bn(coin.maturity).toNumber(),
|
45470
45292
|
blockCreated: bn(coin.blockCreated),
|
45471
45293
|
txCreatedIdx: bn(coin.txCreatedIdx)
|
45472
45294
|
}));
|
@@ -45518,6 +45340,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45518
45340
|
amount: bn(coin.amount),
|
45519
45341
|
assetId: coin.assetId,
|
45520
45342
|
owner: Address.fromAddressOrString(coin.owner),
|
45343
|
+
maturity: bn(coin.maturity).toNumber(),
|
45521
45344
|
blockCreated: bn(coin.blockCreated),
|
45522
45345
|
txCreatedIdx: bn(coin.txCreatedIdx)
|
45523
45346
|
};
|
@@ -45550,7 +45373,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45550
45373
|
}
|
45551
45374
|
return {
|
45552
45375
|
id: block2.id,
|
45553
|
-
height: bn(block2.height),
|
45376
|
+
height: bn(block2.header.height),
|
45554
45377
|
time: block2.header.time,
|
45555
45378
|
transactionIds: block2.transactions.map((tx) => tx.id)
|
45556
45379
|
};
|
@@ -45565,7 +45388,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45565
45388
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
45566
45389
|
const blocks = fetchedData.edges.map(({ node: block2 }) => ({
|
45567
45390
|
id: block2.id,
|
45568
|
-
height: bn(block2.height),
|
45391
|
+
height: bn(block2.header.height),
|
45569
45392
|
time: block2.header.time,
|
45570
45393
|
transactionIds: block2.transactions.map((tx) => tx.id)
|
45571
45394
|
}));
|
@@ -45592,7 +45415,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45592
45415
|
}
|
45593
45416
|
return {
|
45594
45417
|
id: block2.id,
|
45595
|
-
height: bn(block2.height, 10),
|
45418
|
+
height: bn(block2.header.height, 10),
|
45596
45419
|
time: block2.header.time,
|
45597
45420
|
transactionIds: block2.transactions.map((tx) => tx.id),
|
45598
45421
|
transactions: block2.transactions.map(
|
@@ -45794,16 +45617,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45794
45617
|
data
|
45795
45618
|
};
|
45796
45619
|
}
|
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
|
-
}
|
45807
45620
|
/**
|
45808
45621
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
45809
45622
|
*
|
@@ -46087,33 +45900,36 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46087
45900
|
* @param fee - The estimated transaction fee.
|
46088
45901
|
* @returns A promise that resolves when the resources are added to the transaction.
|
46089
45902
|
*/
|
46090
|
-
async fund(request,
|
46091
|
-
const
|
46092
|
-
const txRequest = request;
|
46093
|
-
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
45903
|
+
async fund(request, coinQuantities, fee) {
|
45904
|
+
const updatedQuantities = addAmountToAsset({
|
46094
45905
|
amount: bn(fee),
|
46095
45906
|
assetId: BaseAssetId,
|
46096
|
-
coinQuantities
|
45907
|
+
coinQuantities
|
46097
45908
|
});
|
46098
45909
|
const quantitiesDict = {};
|
46099
|
-
|
45910
|
+
updatedQuantities.forEach(({ amount, assetId }) => {
|
46100
45911
|
quantitiesDict[assetId] = {
|
46101
45912
|
required: amount,
|
46102
45913
|
owned: bn(0)
|
46103
45914
|
};
|
46104
45915
|
});
|
46105
|
-
|
45916
|
+
const cachedUtxos = [];
|
45917
|
+
const cachedMessages = [];
|
45918
|
+
const owner = this.address.toB256();
|
45919
|
+
request.inputs.forEach((input) => {
|
46106
45920
|
const isResource = "amount" in input;
|
46107
45921
|
if (isResource) {
|
46108
45922
|
const isCoin2 = "owner" in input;
|
46109
45923
|
if (isCoin2) {
|
46110
45924
|
const assetId = String(input.assetId);
|
46111
|
-
if (quantitiesDict[assetId]) {
|
45925
|
+
if (input.owner === owner && quantitiesDict[assetId]) {
|
46112
45926
|
const amount = bn(input.amount);
|
46113
45927
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
45928
|
+
cachedUtxos.push(input.id);
|
46114
45929
|
}
|
46115
|
-
} else if (input.amount && quantitiesDict[BaseAssetId]) {
|
45930
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId]) {
|
46116
45931
|
quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
|
45932
|
+
cachedMessages.push(input.nonce);
|
46117
45933
|
}
|
46118
45934
|
}
|
46119
45935
|
});
|
@@ -46128,23 +45944,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46128
45944
|
});
|
46129
45945
|
const needsToBeFunded = missingQuantities.length;
|
46130
45946
|
if (needsToBeFunded) {
|
46131
|
-
const
|
46132
|
-
|
46133
|
-
|
46134
|
-
|
46135
|
-
|
46136
|
-
txRequest.updatePredicateGasUsed(estimatedPredicates);
|
46137
|
-
const requestToBeReEstimate = clone_default(txRequest);
|
46138
|
-
if (addedSignatures) {
|
46139
|
-
Array.from({ length: addedSignatures }).forEach(
|
46140
|
-
() => requestToBeReEstimate.addEmptyWitness()
|
46141
|
-
);
|
45947
|
+
const resources = await this.getResourcesToSpend(missingQuantities, {
|
45948
|
+
messages: cachedMessages,
|
45949
|
+
utxos: cachedUtxos
|
45950
|
+
});
|
45951
|
+
request.addResources(resources);
|
46142
45952
|
}
|
46143
|
-
const { maxFee } = await this.provider.estimateTxGasAndFee({
|
46144
|
-
transactionRequest: requestToBeReEstimate
|
46145
|
-
});
|
46146
|
-
txRequest.maxFee = maxFee;
|
46147
|
-
return txRequest;
|
46148
45953
|
}
|
46149
45954
|
/**
|
46150
45955
|
* A helper that creates a transfer transaction request and returns it.
|
@@ -46152,25 +45957,28 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46152
45957
|
* @param destination - The address of the destination.
|
46153
45958
|
* @param amount - The amount of coins to transfer.
|
46154
45959
|
* @param assetId - The asset ID of the coins to transfer.
|
46155
|
-
* @param txParams - The transaction parameters (gasLimit,
|
45960
|
+
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
46156
45961
|
* @returns A promise that resolves to the prepared transaction request.
|
46157
45962
|
*/
|
46158
45963
|
async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
46159
|
-
const
|
45964
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
45965
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
45966
|
+
const request = new ScriptTransactionRequest(params);
|
46160
45967
|
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
|
46161
|
-
const
|
45968
|
+
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
46162
45969
|
estimateTxDependencies: true,
|
46163
45970
|
resourcesOwner: this
|
46164
45971
|
});
|
46165
|
-
|
46166
|
-
|
46167
|
-
|
46168
|
-
|
46169
|
-
|
46170
|
-
|
46171
|
-
|
46172
|
-
|
46173
|
-
await this.fund(request,
|
45972
|
+
request.gasPrice = bn(txParams.gasPrice ?? minGasPrice);
|
45973
|
+
request.gasLimit = bn(txParams.gasLimit ?? gasUsed);
|
45974
|
+
this.validateGas({
|
45975
|
+
gasUsed,
|
45976
|
+
gasPrice: request.gasPrice,
|
45977
|
+
gasLimit: request.gasLimit,
|
45978
|
+
minGasPrice
|
45979
|
+
});
|
45980
|
+
await this.fund(request, requiredQuantities, maxFee);
|
45981
|
+
request.updatePredicateInputs(estimatedInputs);
|
46174
45982
|
return request;
|
46175
45983
|
}
|
46176
45984
|
/**
|
@@ -46209,30 +46017,31 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46209
46017
|
);
|
46210
46018
|
}
|
46211
46019
|
const contractAddress = Address.fromAddressOrString(contractId);
|
46020
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
46021
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
46212
46022
|
const { script, scriptData } = await assembleTransferToContractScript({
|
46213
46023
|
hexlifiedContractId: contractAddress.toB256(),
|
46214
46024
|
amountToTransfer: bn(amount),
|
46215
46025
|
assetId
|
46216
46026
|
});
|
46217
46027
|
const request = new ScriptTransactionRequest({
|
46218
|
-
...
|
46028
|
+
...params,
|
46219
46029
|
script,
|
46220
46030
|
scriptData
|
46221
46031
|
});
|
46222
46032
|
request.addContractInputAndOutput(contractAddress);
|
46223
|
-
const
|
46224
|
-
|
46225
|
-
|
46033
|
+
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
46034
|
+
request,
|
46035
|
+
[{ amount: bn(amount), assetId: String(assetId) }]
|
46036
|
+
);
|
46037
|
+
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
46038
|
+
this.validateGas({
|
46039
|
+
gasUsed,
|
46040
|
+
gasPrice: request.gasPrice,
|
46041
|
+
gasLimit: request.gasLimit,
|
46042
|
+
minGasPrice
|
46226
46043
|
});
|
46227
|
-
|
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);
|
46044
|
+
await this.fund(request, requiredQuantities, maxFee);
|
46236
46045
|
return this.sendTransaction(request);
|
46237
46046
|
}
|
46238
46047
|
/**
|
@@ -46244,6 +46053,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46244
46053
|
* @returns A promise that resolves to the transaction response.
|
46245
46054
|
*/
|
46246
46055
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
46056
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
46247
46057
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
46248
46058
|
const recipientDataArray = arrayify(
|
46249
46059
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -46256,19 +46066,21 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46256
46066
|
...recipientDataArray,
|
46257
46067
|
...amountDataArray
|
46258
46068
|
]);
|
46259
|
-
const params = { script, ...txParams };
|
46069
|
+
const params = { script, gasPrice: minGasPrice, ...txParams };
|
46260
46070
|
const request = new ScriptTransactionRequest(params);
|
46261
|
-
const
|
46262
|
-
const
|
46263
|
-
|
46264
|
-
|
46265
|
-
|
46266
|
-
|
46267
|
-
|
46268
|
-
|
46269
|
-
|
46270
|
-
|
46271
|
-
|
46071
|
+
const forwardingQuantities = [{ amount: bn(amount), assetId: BaseAssetId }];
|
46072
|
+
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
46073
|
+
request,
|
46074
|
+
forwardingQuantities
|
46075
|
+
);
|
46076
|
+
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
46077
|
+
this.validateGas({
|
46078
|
+
gasUsed,
|
46079
|
+
gasPrice: request.gasPrice,
|
46080
|
+
gasLimit: request.gasLimit,
|
46081
|
+
minGasPrice
|
46082
|
+
});
|
46083
|
+
await this.fund(request, requiredQuantities, maxFee);
|
46272
46084
|
return this.sendTransaction(request);
|
46273
46085
|
}
|
46274
46086
|
async signMessage(message) {
|
@@ -46326,7 +46138,18 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46326
46138
|
}
|
46327
46139
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
46328
46140
|
}
|
46329
|
-
validateGas({
|
46141
|
+
validateGas({
|
46142
|
+
gasUsed,
|
46143
|
+
gasPrice,
|
46144
|
+
gasLimit,
|
46145
|
+
minGasPrice
|
46146
|
+
}) {
|
46147
|
+
if (minGasPrice.gt(gasPrice)) {
|
46148
|
+
throw new FuelError(
|
46149
|
+
ErrorCode.GAS_PRICE_TOO_LOW,
|
46150
|
+
`Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
|
46151
|
+
);
|
46152
|
+
}
|
46330
46153
|
if (gasUsed.gt(gasLimit)) {
|
46331
46154
|
throw new FuelError(
|
46332
46155
|
ErrorCode.GAS_LIMIT_TOO_LOW,
|
@@ -47709,12 +47532,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47709
47532
|
};
|
47710
47533
|
|
47711
47534
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/rng.js
|
47712
|
-
var
|
47535
|
+
var import_crypto15 = __toESM(__require("crypto"));
|
47713
47536
|
var rnds8Pool = new Uint8Array(256);
|
47714
47537
|
var poolPtr = rnds8Pool.length;
|
47715
47538
|
function rng() {
|
47716
47539
|
if (poolPtr > rnds8Pool.length - 16) {
|
47717
|
-
|
47540
|
+
import_crypto15.default.randomFillSync(rnds8Pool);
|
47718
47541
|
poolPtr = 0;
|
47719
47542
|
}
|
47720
47543
|
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
@@ -47730,9 +47553,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47730
47553
|
}
|
47731
47554
|
|
47732
47555
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/native.js
|
47733
|
-
var
|
47556
|
+
var import_crypto16 = __toESM(__require("crypto"));
|
47734
47557
|
var native_default = {
|
47735
|
-
randomUUID:
|
47558
|
+
randomUUID: import_crypto16.default.randomUUID
|
47736
47559
|
};
|
47737
47560
|
|
47738
47561
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/v4.js
|
@@ -47915,7 +47738,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47915
47738
|
* @param transactionRequestLike - The transaction request to send.
|
47916
47739
|
* @returns A promise that resolves to the TransactionResponse object.
|
47917
47740
|
*/
|
47918
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies =
|
47741
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
|
47919
47742
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
47920
47743
|
if (estimateTxDependencies) {
|
47921
47744
|
await this.provider.estimateTxDependencies(transactionRequest);
|
@@ -50675,15 +50498,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
50675
50498
|
process.env.GENESIS_SECRET || randomBytes22(32),
|
50676
50499
|
wallet.provider
|
50677
50500
|
);
|
50678
|
-
const
|
50679
|
-
|
50680
|
-
|
50681
|
-
|
50501
|
+
const resources = await genesisWallet.getResourcesToSpend(quantities);
|
50502
|
+
const { minGasPrice } = genesisWallet.provider.getGasConfig();
|
50503
|
+
const request = new ScriptTransactionRequest({
|
50504
|
+
gasLimit: 1e4,
|
50505
|
+
gasPrice: minGasPrice
|
50682
50506
|
});
|
50683
|
-
|
50684
|
-
request.
|
50685
|
-
request.maxFee = txCost.maxFee;
|
50686
|
-
await genesisWallet.fund(request, txCost);
|
50507
|
+
request.addResources(resources);
|
50508
|
+
quantities.map(coinQuantityfy).forEach(({ amount, assetId }) => request.addCoinOutput(wallet.address, amount, assetId));
|
50687
50509
|
await genesisWallet.sendTransaction(request, { awaitExecution: true });
|
50688
50510
|
};
|
50689
50511
|
|
@@ -50713,7 +50535,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
50713
50535
|
|
50714
50536
|
// src/test-utils/launchNode.ts
|
50715
50537
|
var import_child_process = __require("child_process");
|
50716
|
-
var
|
50538
|
+
var import_crypto20 = __require("crypto");
|
50717
50539
|
var import_fs2 = __require("fs");
|
50718
50540
|
var import_os = __toESM(__require("os"));
|
50719
50541
|
var import_path8 = __toESM(__require("path"));
|
@@ -50785,7 +50607,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
50785
50607
|
})).toString();
|
50786
50608
|
let chainConfigPathToUse;
|
50787
50609
|
const prefix = basePath || import_os.default.tmpdir();
|
50788
|
-
const suffix = basePath ? "" : (0,
|
50610
|
+
const suffix = basePath ? "" : (0, import_crypto20.randomUUID)();
|
50789
50611
|
const tempDirPath = import_path8.default.join(prefix, ".fuels", suffix);
|
50790
50612
|
if (chainConfigPath) {
|
50791
50613
|
chainConfigPathToUse = chainConfigPath;
|
@@ -50824,7 +50646,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
50824
50646
|
["--ip", ipToUse],
|
50825
50647
|
["--port", portToUse],
|
50826
50648
|
useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
|
50827
|
-
["--min-gas-price", "
|
50649
|
+
["--min-gas-price", "0"],
|
50828
50650
|
poaInstant ? ["--poa-instant", "true"] : [],
|
50829
50651
|
["--consensus-key", consensusKey],
|
50830
50652
|
["--chain", chainConfigPathToUse],
|
@@ -50886,7 +50708,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
50886
50708
|
walletCount = 10
|
50887
50709
|
} = {}) => {
|
50888
50710
|
const { cleanup: closeNode, ip, port } = await launchNode(launchNodeOptions || {});
|
50889
|
-
const provider = await Provider.create(`http://${ip}:${port}/
|
50711
|
+
const provider = await Provider.create(`http://${ip}:${port}/graphql`);
|
50890
50712
|
const wallets = await generateWallets(walletCount, provider);
|
50891
50713
|
const cleanup = () => {
|
50892
50714
|
closeNode();
|