@fuel-ts/account 0.0.0-rc-2021-20240409151049 → 0.0.0-rc-2034-20240410011904
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 +623 -868
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +525 -759
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +406 -639
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +2 -10
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +328 -894
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/coin-quantity.d.ts +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 +1 -3
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +31 -36
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/input.d.ts +2 -2
- package/dist/providers/transaction-request/input.d.ts.map +1 -1
- package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +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/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +1122 -1582
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +521 -735
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +415 -629
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/package.json +17 -17
package/dist/index.global.js
CHANGED
@@ -289,7 +289,7 @@
|
|
289
289
|
}
|
290
290
|
return num !== null && typeof num === "object" && num.constructor.wordSize === BN2.wordSize && Array.isArray(num.words);
|
291
291
|
};
|
292
|
-
BN2.max = function
|
292
|
+
BN2.max = function max2(left, right) {
|
293
293
|
if (left.cmp(right) > 0)
|
294
294
|
return left;
|
295
295
|
return right;
|
@@ -5113,7 +5113,7 @@
|
|
5113
5113
|
function isBlob(obj) {
|
5114
5114
|
return typeof obj === "object" && typeof obj.arrayBuffer === "function" && typeof obj.type === "string" && typeof obj.stream === "function" && typeof obj.constructor === "function" && typeof obj.constructor.name === "string" && /^(Blob|File)$/.test(obj.constructor.name) && /^(Blob|File)$/.test(obj[Symbol.toStringTag]);
|
5115
5115
|
}
|
5116
|
-
function
|
5116
|
+
function clone(instance) {
|
5117
5117
|
let p1, p2;
|
5118
5118
|
let body = instance.body;
|
5119
5119
|
if (instance.bodyUsed) {
|
@@ -6047,7 +6047,7 @@
|
|
6047
6047
|
* @return Response
|
6048
6048
|
*/
|
6049
6049
|
clone() {
|
6050
|
-
return new Response2(
|
6050
|
+
return new Response2(clone(this), {
|
6051
6051
|
url: this.url,
|
6052
6052
|
status: this.status,
|
6053
6053
|
statusText: this.statusText,
|
@@ -6097,7 +6097,7 @@
|
|
6097
6097
|
if ((init.body != null || isRequest(input) && input.body !== null) && (method === "GET" || method === "HEAD")) {
|
6098
6098
|
throw new TypeError("Request with GET/HEAD method cannot have body");
|
6099
6099
|
}
|
6100
|
-
let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ?
|
6100
|
+
let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone(input) : null;
|
6101
6101
|
Body.call(this, inputBody, {
|
6102
6102
|
timeout: init.timeout || input.timeout || 0,
|
6103
6103
|
size: init.size || input.size || 0
|
@@ -28952,8 +28952,8 @@ spurious results.`);
|
|
28952
28952
|
// ../versions/dist/index.mjs
|
28953
28953
|
function getBuiltinVersions() {
|
28954
28954
|
return {
|
28955
|
-
FORC: "0.
|
28956
|
-
FUEL_CORE: "0.
|
28955
|
+
FORC: "0.49.3",
|
28956
|
+
FUEL_CORE: "0.22.1",
|
28957
28957
|
FUELS: "0.79.0"
|
28958
28958
|
};
|
28959
28959
|
}
|
@@ -29015,6 +29015,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
29015
29015
|
ErrorCode2["INVALID_COMPONENT"] = "invalid-component";
|
29016
29016
|
ErrorCode2["CONFIGURABLE_NOT_FOUND"] = "configurable-not-found";
|
29017
29017
|
ErrorCode2["TYPE_NOT_FOUND"] = "type-not-found";
|
29018
|
+
ErrorCode2["LOG_TYPE_NOT_FOUND"] = "log-type-not-found";
|
29018
29019
|
ErrorCode2["TYPE_NOT_SUPPORTED"] = "type-not-supported";
|
29019
29020
|
ErrorCode2["INVALID_DECODE_VALUE"] = "invalid-decode-value";
|
29020
29021
|
ErrorCode2["JSON_ABI_ERROR"] = "json-abi-error";
|
@@ -31515,182 +31516,32 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31515
31516
|
function toBytes3(value, bytesPadding) {
|
31516
31517
|
return bn(value).toBytes(bytesPadding);
|
31517
31518
|
}
|
31518
|
-
|
31519
|
-
|
31520
|
-
function _isPlaceholder(a) {
|
31521
|
-
return a != null && typeof a === "object" && a["@@functional/placeholder"] === true;
|
31519
|
+
function max(...numbers) {
|
31520
|
+
return numbers.reduce((prev, cur) => bn(cur).gt(prev) ? bn(cur) : prev, bn(0));
|
31522
31521
|
}
|
31523
31522
|
|
31524
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_curry1.js
|
31525
|
-
function _curry1(fn) {
|
31526
|
-
return function f1(a) {
|
31527
|
-
if (arguments.length === 0 || _isPlaceholder(a)) {
|
31528
|
-
return f1;
|
31529
|
-
} else {
|
31530
|
-
return fn.apply(this, arguments);
|
31531
|
-
}
|
31532
|
-
};
|
31533
|
-
}
|
31534
|
-
|
31535
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isArray.js
|
31536
|
-
var isArray_default = Array.isArray || function _isArray(val) {
|
31537
|
-
return val != null && val.length >= 0 && Object.prototype.toString.call(val) === "[object Array]";
|
31538
|
-
};
|
31539
|
-
|
31540
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/type.js
|
31541
|
-
var type = /* @__PURE__ */ _curry1(function type2(val) {
|
31542
|
-
return val === null ? "Null" : val === void 0 ? "Undefined" : Object.prototype.toString.call(val).slice(8, -1);
|
31543
|
-
});
|
31544
|
-
var type_default = type;
|
31545
|
-
|
31546
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_toISOString.js
|
31547
|
-
var pad = function pad2(n) {
|
31548
|
-
return (n < 10 ? "0" : "") + n;
|
31549
|
-
};
|
31550
|
-
var _toISOString = typeof Date.prototype.toISOString === "function" ? function _toISOString2(d) {
|
31551
|
-
return d.toISOString();
|
31552
|
-
} : function _toISOString3(d) {
|
31553
|
-
return d.getUTCFullYear() + "-" + pad(d.getUTCMonth() + 1) + "-" + pad(d.getUTCDate()) + "T" + pad(d.getUTCHours()) + ":" + pad(d.getUTCMinutes()) + ":" + pad(d.getUTCSeconds()) + "." + (d.getUTCMilliseconds() / 1e3).toFixed(3).slice(2, 5) + "Z";
|
31554
|
-
};
|
31555
|
-
|
31556
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isInteger.js
|
31557
|
-
var isInteger_default = Number.isInteger || function _isInteger(n) {
|
31558
|
-
return n << 0 === n;
|
31559
|
-
};
|
31560
|
-
|
31561
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_cloneRegExp.js
|
31562
|
-
function _cloneRegExp(pattern) {
|
31563
|
-
return new RegExp(pattern.source, pattern.flags ? pattern.flags : (pattern.global ? "g" : "") + (pattern.ignoreCase ? "i" : "") + (pattern.multiline ? "m" : "") + (pattern.sticky ? "y" : "") + (pattern.unicode ? "u" : "") + (pattern.dotAll ? "s" : ""));
|
31564
|
-
}
|
31565
|
-
|
31566
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_clone.js
|
31567
|
-
function _clone(value, deep, map) {
|
31568
|
-
map || (map = new _ObjectMap());
|
31569
|
-
if (_isPrimitive(value)) {
|
31570
|
-
return value;
|
31571
|
-
}
|
31572
|
-
var copy = function copy2(copiedValue) {
|
31573
|
-
var cachedCopy = map.get(value);
|
31574
|
-
if (cachedCopy) {
|
31575
|
-
return cachedCopy;
|
31576
|
-
}
|
31577
|
-
map.set(value, copiedValue);
|
31578
|
-
for (var key in value) {
|
31579
|
-
if (Object.prototype.hasOwnProperty.call(value, key)) {
|
31580
|
-
copiedValue[key] = deep ? _clone(value[key], true, map) : value[key];
|
31581
|
-
}
|
31582
|
-
}
|
31583
|
-
return copiedValue;
|
31584
|
-
};
|
31585
|
-
switch (type_default(value)) {
|
31586
|
-
case "Object":
|
31587
|
-
return copy(Object.create(Object.getPrototypeOf(value)));
|
31588
|
-
case "Array":
|
31589
|
-
return copy([]);
|
31590
|
-
case "Date":
|
31591
|
-
return new Date(value.valueOf());
|
31592
|
-
case "RegExp":
|
31593
|
-
return _cloneRegExp(value);
|
31594
|
-
case "Int8Array":
|
31595
|
-
case "Uint8Array":
|
31596
|
-
case "Uint8ClampedArray":
|
31597
|
-
case "Int16Array":
|
31598
|
-
case "Uint16Array":
|
31599
|
-
case "Int32Array":
|
31600
|
-
case "Uint32Array":
|
31601
|
-
case "Float32Array":
|
31602
|
-
case "Float64Array":
|
31603
|
-
case "BigInt64Array":
|
31604
|
-
case "BigUint64Array":
|
31605
|
-
return value.slice();
|
31606
|
-
default:
|
31607
|
-
return value;
|
31608
|
-
}
|
31609
|
-
}
|
31610
|
-
function _isPrimitive(param) {
|
31611
|
-
var type3 = typeof param;
|
31612
|
-
return param == null || type3 != "object" && type3 != "function";
|
31613
|
-
}
|
31614
|
-
var _ObjectMap = /* @__PURE__ */ function() {
|
31615
|
-
function _ObjectMap2() {
|
31616
|
-
this.map = {};
|
31617
|
-
this.length = 0;
|
31618
|
-
}
|
31619
|
-
_ObjectMap2.prototype.set = function(key, value) {
|
31620
|
-
const hashedKey = this.hash(key);
|
31621
|
-
let bucket = this.map[hashedKey];
|
31622
|
-
if (!bucket) {
|
31623
|
-
this.map[hashedKey] = bucket = [];
|
31624
|
-
}
|
31625
|
-
bucket.push([key, value]);
|
31626
|
-
this.length += 1;
|
31627
|
-
};
|
31628
|
-
_ObjectMap2.prototype.hash = function(key) {
|
31629
|
-
let hashedKey = [];
|
31630
|
-
for (var value in key) {
|
31631
|
-
hashedKey.push(Object.prototype.toString.call(key[value]));
|
31632
|
-
}
|
31633
|
-
return hashedKey.join();
|
31634
|
-
};
|
31635
|
-
_ObjectMap2.prototype.get = function(key) {
|
31636
|
-
if (this.length <= 180) {
|
31637
|
-
for (const p in this.map) {
|
31638
|
-
const bucket2 = this.map[p];
|
31639
|
-
for (let i = 0; i < bucket2.length; i += 1) {
|
31640
|
-
const element = bucket2[i];
|
31641
|
-
if (element[0] === key) {
|
31642
|
-
return element[1];
|
31643
|
-
}
|
31644
|
-
}
|
31645
|
-
}
|
31646
|
-
return;
|
31647
|
-
}
|
31648
|
-
const hashedKey = this.hash(key);
|
31649
|
-
const bucket = this.map[hashedKey];
|
31650
|
-
if (!bucket) {
|
31651
|
-
return;
|
31652
|
-
}
|
31653
|
-
for (let i = 0; i < bucket.length; i += 1) {
|
31654
|
-
const element = bucket[i];
|
31655
|
-
if (element[0] === key) {
|
31656
|
-
return element[1];
|
31657
|
-
}
|
31658
|
-
}
|
31659
|
-
};
|
31660
|
-
return _ObjectMap2;
|
31661
|
-
}();
|
31662
|
-
|
31663
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/clone.js
|
31664
|
-
var clone = /* @__PURE__ */ _curry1(function clone2(value) {
|
31665
|
-
return value != null && typeof value.clone === "function" ? value.clone() : _clone(value, true);
|
31666
|
-
});
|
31667
|
-
var clone_default = clone;
|
31668
|
-
|
31669
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/trim.js
|
31670
|
-
var hasProtoTrim = typeof String.prototype.trim === "function";
|
31671
|
-
|
31672
31523
|
// src/providers/coin-quantity.ts
|
31673
31524
|
var coinQuantityfy = (coinQuantityLike) => {
|
31674
31525
|
let assetId;
|
31675
31526
|
let amount;
|
31676
|
-
let
|
31527
|
+
let max2;
|
31677
31528
|
if (Array.isArray(coinQuantityLike)) {
|
31678
31529
|
amount = coinQuantityLike[0];
|
31679
31530
|
assetId = coinQuantityLike[1] ?? BaseAssetId;
|
31680
|
-
|
31531
|
+
max2 = coinQuantityLike[2] ?? void 0;
|
31681
31532
|
} else {
|
31682
31533
|
amount = coinQuantityLike.amount;
|
31683
31534
|
assetId = coinQuantityLike.assetId ?? BaseAssetId;
|
31684
|
-
|
31535
|
+
max2 = coinQuantityLike.max ?? void 0;
|
31685
31536
|
}
|
31686
31537
|
const bnAmount = bn(amount);
|
31687
31538
|
return {
|
31688
31539
|
assetId: hexlify(assetId),
|
31689
31540
|
amount: bnAmount.lt(1) ? bn(1) : bnAmount,
|
31690
|
-
max:
|
31541
|
+
max: max2 ? bn(max2) : void 0
|
31691
31542
|
};
|
31692
31543
|
};
|
31693
|
-
var
|
31544
|
+
var addAmountToAsset = (params) => {
|
31694
31545
|
const { amount, assetId } = params;
|
31695
31546
|
const coinQuantities = [...params.coinQuantities];
|
31696
31547
|
const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
|
@@ -31782,9 +31633,9 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31782
31633
|
var TX_POINTER_LEN = WORD_SIZE * 2;
|
31783
31634
|
var MAX_BYTES = 2 ** 32 - 1;
|
31784
31635
|
var calculateVmTxMemory = ({ maxInputs }) => BYTES_32 + // Tx ID
|
31785
|
-
|
31636
|
+
WORD_SIZE + // Tx size
|
31786
31637
|
// Asset ID/Balance coin input pairs
|
31787
|
-
maxInputs * (ASSET_ID_LEN + WORD_SIZE)
|
31638
|
+
maxInputs * (ASSET_ID_LEN + WORD_SIZE);
|
31788
31639
|
var SCRIPT_FIXED_SIZE = WORD_SIZE + // Identifier
|
31789
31640
|
WORD_SIZE + // Gas limit
|
31790
31641
|
WORD_SIZE + // Script size
|
@@ -31802,6 +31653,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31802
31653
|
ASSET_ID_LEN + // Asset id
|
31803
31654
|
TX_POINTER_LEN + // TxPointer
|
31804
31655
|
WORD_SIZE + // Witnesses index
|
31656
|
+
WORD_SIZE + // Maturity
|
31805
31657
|
WORD_SIZE + // Predicate size
|
31806
31658
|
WORD_SIZE + // Predicate data size
|
31807
31659
|
WORD_SIZE;
|
@@ -31924,15 +31776,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31924
31776
|
}
|
31925
31777
|
};
|
31926
31778
|
var isHeapType = (type3) => type3 === VEC_CODER_TYPE || type3 === BYTES_CODER_TYPE || type3 === STD_STRING_CODER_TYPE;
|
31927
|
-
function findOrThrow(arr, predicate, throwFn = () => {
|
31928
|
-
throw new FuelError(ErrorCode.ELEMENT_NOT_FOUND, "Element not found in the array.");
|
31929
|
-
}) {
|
31930
|
-
const found = arr.find(predicate);
|
31931
|
-
if (found === void 0) {
|
31932
|
-
throwFn();
|
31933
|
-
}
|
31934
|
-
return found;
|
31935
|
-
}
|
31936
31779
|
var isMultipleOfWordSize = (length) => length % WORD_SIZE === 0;
|
31937
31780
|
var getWordSizePadding = (length) => WORD_SIZE - length % WORD_SIZE;
|
31938
31781
|
var rightPadToWordSize = (encoded) => {
|
@@ -32131,7 +31974,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32131
31974
|
constructor(name, coders) {
|
32132
31975
|
const caseIndexCoder = new BigNumberCoder("u64");
|
32133
31976
|
const encodedValueSize = Object.values(coders).reduce(
|
32134
|
-
(
|
31977
|
+
(max2, coder) => Math.max(max2, coder.encodedLength),
|
32135
31978
|
0
|
32136
31979
|
);
|
32137
31980
|
super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
|
@@ -32515,6 +32358,38 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32515
32358
|
];
|
32516
32359
|
}
|
32517
32360
|
};
|
32361
|
+
var findFunctionByName = (abi, name) => {
|
32362
|
+
const fn = abi.functions.find((f2) => f2.name === name);
|
32363
|
+
if (!fn) {
|
32364
|
+
throw new FuelError(
|
32365
|
+
ErrorCode.FUNCTION_NOT_FOUND,
|
32366
|
+
`Function with name '${name}' doesn't exist in the ABI`
|
32367
|
+
);
|
32368
|
+
}
|
32369
|
+
return fn;
|
32370
|
+
};
|
32371
|
+
var findTypeById = (abi, typeId) => {
|
32372
|
+
const type3 = abi.types.find((t) => t.typeId === typeId);
|
32373
|
+
if (!type3) {
|
32374
|
+
throw new FuelError(
|
32375
|
+
ErrorCode.TYPE_NOT_FOUND,
|
32376
|
+
`Type with typeId '${typeId}' doesn't exist in the ABI.`
|
32377
|
+
);
|
32378
|
+
}
|
32379
|
+
return type3;
|
32380
|
+
};
|
32381
|
+
var findNonEmptyInputs = (abi, inputs) => inputs.filter((input) => findTypeById(abi, input.type).type !== "()");
|
32382
|
+
var findVectorBufferArgument = (components) => {
|
32383
|
+
const bufferComponent = components.find((c) => c.name === "buf");
|
32384
|
+
const bufferTypeArgument = bufferComponent?.originalTypeArguments?.[0];
|
32385
|
+
if (!bufferComponent || !bufferTypeArgument) {
|
32386
|
+
throw new FuelError(
|
32387
|
+
ErrorCode.INVALID_COMPONENT,
|
32388
|
+
`The Vec type provided is missing or has a malformed 'buf' component.`
|
32389
|
+
);
|
32390
|
+
}
|
32391
|
+
return bufferTypeArgument;
|
32392
|
+
};
|
32518
32393
|
var ResolvedAbiType = class {
|
32519
32394
|
abi;
|
32520
32395
|
name;
|
@@ -32523,20 +32398,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32523
32398
|
components;
|
32524
32399
|
constructor(abi, argument) {
|
32525
32400
|
this.abi = abi;
|
32526
|
-
const type3 = findOrThrow(
|
32527
|
-
abi.types,
|
32528
|
-
(t) => t.typeId === argument.type,
|
32529
|
-
() => {
|
32530
|
-
throw new FuelError(
|
32531
|
-
ErrorCode.TYPE_NOT_FOUND,
|
32532
|
-
`Type does not exist in the provided abi: ${JSON.stringify({
|
32533
|
-
argument,
|
32534
|
-
abi: this.abi
|
32535
|
-
})}`
|
32536
|
-
);
|
32537
|
-
}
|
32538
|
-
);
|
32539
32401
|
this.name = argument.name;
|
32402
|
+
const type3 = findTypeById(abi, argument.type);
|
32540
32403
|
this.type = type3.type;
|
32541
32404
|
this.originalTypeArguments = argument.typeArguments;
|
32542
32405
|
this.components = ResolvedAbiType.getResolvedGenericComponents(
|
@@ -32588,7 +32451,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32588
32451
|
)
|
32589
32452
|
};
|
32590
32453
|
}
|
32591
|
-
const argType =
|
32454
|
+
const argType = findTypeById(abi, arg.type);
|
32592
32455
|
const implicitTypeParameters = this.getImplicitGenericTypeParameters(abi, argType.components);
|
32593
32456
|
if (implicitTypeParameters && implicitTypeParameters.length > 0) {
|
32594
32457
|
return {
|
@@ -32605,7 +32468,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32605
32468
|
}
|
32606
32469
|
const implicitGenericParameters = implicitGenericParametersParam ?? [];
|
32607
32470
|
args.forEach((a) => {
|
32608
|
-
const argType =
|
32471
|
+
const argType = findTypeById(abi, a.type);
|
32609
32472
|
if (genericRegEx.test(argType.type)) {
|
32610
32473
|
implicitGenericParameters.push(argType.typeId);
|
32611
32474
|
return;
|
@@ -32714,13 +32577,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32714
32577
|
return new ArrayCoder(arrayElementCoder, length);
|
32715
32578
|
}
|
32716
32579
|
if (resolvedAbiType.type === VEC_CODER_TYPE) {
|
32717
|
-
const arg =
|
32718
|
-
if (!arg) {
|
32719
|
-
throw new FuelError(
|
32720
|
-
ErrorCode.INVALID_COMPONENT,
|
32721
|
-
`The provided Vec type is missing the 'type argument'.`
|
32722
|
-
);
|
32723
|
-
}
|
32580
|
+
const arg = findVectorBufferArgument(components);
|
32724
32581
|
const argType = new ResolvedAbiType(resolvedAbiType.abi, arg);
|
32725
32582
|
const itemCoder = getCoder(argType, { isSmallBytes: true, encoding: ENCODING_V0 });
|
32726
32583
|
return new VecCoder(itemCoder);
|
@@ -32818,7 +32675,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32818
32675
|
constructor(name, coders) {
|
32819
32676
|
const caseIndexCoder = new BigNumberCoder("u64");
|
32820
32677
|
const encodedValueSize = Object.values(coders).reduce(
|
32821
|
-
(
|
32678
|
+
(max2, coder) => Math.max(max2, coder.encodedLength),
|
32822
32679
|
0
|
32823
32680
|
);
|
32824
32681
|
super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
|
@@ -33189,13 +33046,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33189
33046
|
return new ArrayCoder(arrayElementCoder, length);
|
33190
33047
|
}
|
33191
33048
|
if (resolvedAbiType.type === VEC_CODER_TYPE) {
|
33192
|
-
const arg =
|
33193
|
-
if (!arg) {
|
33194
|
-
throw new FuelError(
|
33195
|
-
ErrorCode.INVALID_COMPONENT,
|
33196
|
-
`The provided Vec type is missing the 'type argument'.`
|
33197
|
-
);
|
33198
|
-
}
|
33049
|
+
const arg = findVectorBufferArgument(components);
|
33199
33050
|
const argType = new ResolvedAbiType(resolvedAbiType.abi, arg);
|
33200
33051
|
const itemCoder = getCoder2(argType, { isSmallBytes: true, encoding: ENCODING_V0 });
|
33201
33052
|
return new VecCoder2(itemCoder);
|
@@ -33266,7 +33117,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33266
33117
|
jsonAbi;
|
33267
33118
|
constructor(jsonAbi, name) {
|
33268
33119
|
this.jsonAbi = jsonAbi;
|
33269
|
-
this.jsonFn =
|
33120
|
+
this.jsonFn = findFunctionByName(this.jsonAbi, name);
|
33270
33121
|
this.name = name;
|
33271
33122
|
this.signature = FunctionFragment.getSignature(this.jsonAbi, this.jsonFn);
|
33272
33123
|
this.selector = FunctionFragment.getFunctionSelector(this.signature);
|
@@ -33290,13 +33141,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33290
33141
|
return bn(hashedFunctionSignature.slice(0, 10)).toHex(8);
|
33291
33142
|
}
|
33292
33143
|
#isInputDataPointer() {
|
33293
|
-
const inputTypes = this.jsonFn.inputs.map(
|
33294
|
-
(i) => this.jsonAbi.types.find((t) => t.typeId === i.type)
|
33295
|
-
);
|
33144
|
+
const inputTypes = this.jsonFn.inputs.map((i) => findTypeById(this.jsonAbi, i.type));
|
33296
33145
|
return this.jsonFn.inputs.length > 1 || isPointerType(inputTypes[0]?.type || "");
|
33297
33146
|
}
|
33298
33147
|
#isOutputDataHeap() {
|
33299
|
-
const outputType =
|
33148
|
+
const outputType = findTypeById(this.jsonAbi, this.jsonFn.output.type);
|
33300
33149
|
return isHeapType(outputType?.type || "");
|
33301
33150
|
}
|
33302
33151
|
#getOutputEncodedLength() {
|
@@ -33316,9 +33165,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33316
33165
|
encodeArguments(values, offset = 0) {
|
33317
33166
|
FunctionFragment.verifyArgsAndInputsAlign(values, this.jsonFn.inputs, this.jsonAbi);
|
33318
33167
|
const shallowCopyValues = values.slice();
|
33319
|
-
const nonEmptyInputs = this.jsonFn.inputs
|
33320
|
-
(x) => findOrThrow(this.jsonAbi.types, (t) => t.typeId === x.type).type !== "()"
|
33321
|
-
);
|
33168
|
+
const nonEmptyInputs = findNonEmptyInputs(this.jsonAbi, this.jsonFn.inputs);
|
33322
33169
|
if (Array.isArray(values) && nonEmptyInputs.length !== values.length) {
|
33323
33170
|
shallowCopyValues.length = this.jsonFn.inputs.length;
|
33324
33171
|
shallowCopyValues.fill(void 0, values.length);
|
@@ -33339,7 +33186,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33339
33186
|
if (args.length === inputs.length) {
|
33340
33187
|
return;
|
33341
33188
|
}
|
33342
|
-
const inputTypes = inputs.map((
|
33189
|
+
const inputTypes = inputs.map((input) => findTypeById(abi, input.type));
|
33343
33190
|
const optionalInputs = inputTypes.filter(
|
33344
33191
|
(x) => x.type === OPTION_CODER_TYPE || x.type === "()"
|
33345
33192
|
);
|
@@ -33354,9 +33201,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33354
33201
|
}
|
33355
33202
|
decodeArguments(data) {
|
33356
33203
|
const bytes3 = arrayify(data);
|
33357
|
-
const nonEmptyInputs = this.jsonFn.inputs
|
33358
|
-
(x) => findOrThrow(this.jsonAbi.types, (t) => t.typeId === x.type).type !== "()"
|
33359
|
-
);
|
33204
|
+
const nonEmptyInputs = findNonEmptyInputs(this.jsonAbi, this.jsonFn.inputs);
|
33360
33205
|
if (nonEmptyInputs.length === 0) {
|
33361
33206
|
if (bytes3.length === 0) {
|
33362
33207
|
return void 0;
|
@@ -33391,10 +33236,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33391
33236
|
return result.decoded;
|
33392
33237
|
}
|
33393
33238
|
decodeOutput(data) {
|
33394
|
-
const outputAbiType =
|
33395
|
-
this.jsonAbi.types,
|
33396
|
-
(t) => t.typeId === this.jsonFn.output.type
|
33397
|
-
);
|
33239
|
+
const outputAbiType = findTypeById(this.jsonAbi, this.jsonFn.output.type);
|
33398
33240
|
if (outputAbiType.type === "()") {
|
33399
33241
|
return [void 0, 0];
|
33400
33242
|
}
|
@@ -33446,38 +33288,32 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33446
33288
|
return fragment.decodeOutput(data);
|
33447
33289
|
}
|
33448
33290
|
decodeLog(data, logId) {
|
33449
|
-
const
|
33450
|
-
|
33291
|
+
const loggedType = this.jsonAbi.loggedTypes.find((type3) => type3.logId === logId);
|
33292
|
+
if (!loggedType) {
|
33293
|
+
throw new FuelError(
|
33294
|
+
ErrorCode.LOG_TYPE_NOT_FOUND,
|
33295
|
+
`Log type with logId '${logId}' doesn't exist in the ABI.`
|
33296
|
+
);
|
33297
|
+
}
|
33298
|
+
return AbiCoder.decode(this.jsonAbi, loggedType.loggedType, arrayify(data), 0, {
|
33451
33299
|
encoding: this.jsonAbi.encoding
|
33452
33300
|
});
|
33453
33301
|
}
|
33454
33302
|
encodeConfigurable(name, value) {
|
33455
|
-
const configurable =
|
33456
|
-
|
33457
|
-
|
33458
|
-
|
33459
|
-
|
33460
|
-
|
33461
|
-
|
33462
|
-
);
|
33463
|
-
}
|
33464
|
-
);
|
33303
|
+
const configurable = this.jsonAbi.configurables.find((c) => c.name === name);
|
33304
|
+
if (!configurable) {
|
33305
|
+
throw new FuelError(
|
33306
|
+
ErrorCode.CONFIGURABLE_NOT_FOUND,
|
33307
|
+
`A configurable with the '${name}' was not found in the ABI.`
|
33308
|
+
);
|
33309
|
+
}
|
33465
33310
|
return AbiCoder.encode(this.jsonAbi, configurable.configurableType, value, {
|
33466
33311
|
isRightPadded: true,
|
33467
33312
|
encoding: this.jsonAbi.encoding
|
33468
33313
|
});
|
33469
33314
|
}
|
33470
33315
|
getTypeById(typeId) {
|
33471
|
-
return
|
33472
|
-
this.jsonAbi.types,
|
33473
|
-
(t) => t.typeId === typeId,
|
33474
|
-
() => {
|
33475
|
-
throw new FuelError(
|
33476
|
-
ErrorCode.TYPE_NOT_FOUND,
|
33477
|
-
`Type with typeId '${typeId}' doesn't exist in the ABI.`
|
33478
|
-
);
|
33479
|
-
}
|
33480
|
-
);
|
33316
|
+
return findTypeById(this.jsonAbi, typeId);
|
33481
33317
|
}
|
33482
33318
|
};
|
33483
33319
|
|
@@ -33541,19 +33377,18 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33541
33377
|
encode(value) {
|
33542
33378
|
const parts = [];
|
33543
33379
|
parts.push(new B256Coder().encode(value.txID));
|
33544
|
-
parts.push(new NumberCoder("
|
33380
|
+
parts.push(new NumberCoder("u8").encode(value.outputIndex));
|
33545
33381
|
parts.push(new B256Coder().encode(value.owner));
|
33546
33382
|
parts.push(new BigNumberCoder("u64").encode(value.amount));
|
33547
33383
|
parts.push(new B256Coder().encode(value.assetId));
|
33548
33384
|
parts.push(new TxPointerCoder().encode(value.txPointer));
|
33549
|
-
parts.push(new NumberCoder("
|
33385
|
+
parts.push(new NumberCoder("u8").encode(value.witnessIndex));
|
33386
|
+
parts.push(new NumberCoder("u32").encode(value.maturity));
|
33550
33387
|
parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
|
33551
|
-
parts.push(new
|
33552
|
-
parts.push(new
|
33553
|
-
parts.push(new ByteArrayCoder(value.predicateLength
|
33554
|
-
parts.push(
|
33555
|
-
new ByteArrayCoder(value.predicateDataLength.toNumber()).encode(value.predicateData)
|
33556
|
-
);
|
33388
|
+
parts.push(new NumberCoder("u32").encode(value.predicateLength));
|
33389
|
+
parts.push(new NumberCoder("u32").encode(value.predicateDataLength));
|
33390
|
+
parts.push(new ByteArrayCoder(value.predicateLength).encode(value.predicate));
|
33391
|
+
parts.push(new ByteArrayCoder(value.predicateDataLength).encode(value.predicateData));
|
33557
33392
|
return concat(parts);
|
33558
33393
|
}
|
33559
33394
|
decode(data, offset) {
|
@@ -33561,7 +33396,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33561
33396
|
let o = offset;
|
33562
33397
|
[decoded, o] = new B256Coder().decode(data, o);
|
33563
33398
|
const txID = decoded;
|
33564
|
-
[decoded, o] = new NumberCoder("
|
33399
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
33565
33400
|
const outputIndex = decoded;
|
33566
33401
|
[decoded, o] = new B256Coder().decode(data, o);
|
33567
33402
|
const owner = decoded;
|
@@ -33571,17 +33406,19 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33571
33406
|
const assetId = decoded;
|
33572
33407
|
[decoded, o] = new TxPointerCoder().decode(data, o);
|
33573
33408
|
const txPointer = decoded;
|
33574
|
-
[decoded, o] = new NumberCoder("
|
33409
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
33575
33410
|
const witnessIndex = Number(decoded);
|
33411
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33412
|
+
const maturity = decoded;
|
33576
33413
|
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33577
33414
|
const predicateGasUsed = decoded;
|
33578
|
-
[decoded, o] = new
|
33415
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33579
33416
|
const predicateLength = decoded;
|
33580
|
-
[decoded, o] = new
|
33417
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33581
33418
|
const predicateDataLength = decoded;
|
33582
|
-
[decoded, o] = new ByteArrayCoder(predicateLength
|
33419
|
+
[decoded, o] = new ByteArrayCoder(predicateLength).decode(data, o);
|
33583
33420
|
const predicate = decoded;
|
33584
|
-
[decoded, o] = new ByteArrayCoder(predicateDataLength
|
33421
|
+
[decoded, o] = new ByteArrayCoder(predicateDataLength).decode(data, o);
|
33585
33422
|
const predicateData = decoded;
|
33586
33423
|
return [
|
33587
33424
|
{
|
@@ -33593,6 +33430,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33593
33430
|
assetId,
|
33594
33431
|
txPointer,
|
33595
33432
|
witnessIndex,
|
33433
|
+
maturity,
|
33596
33434
|
predicateGasUsed,
|
33597
33435
|
predicateLength,
|
33598
33436
|
predicateDataLength,
|
@@ -33610,7 +33448,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33610
33448
|
encode(value) {
|
33611
33449
|
const parts = [];
|
33612
33450
|
parts.push(new B256Coder().encode(value.txID));
|
33613
|
-
parts.push(new NumberCoder("
|
33451
|
+
parts.push(new NumberCoder("u8").encode(value.outputIndex));
|
33614
33452
|
parts.push(new B256Coder().encode(value.balanceRoot));
|
33615
33453
|
parts.push(new B256Coder().encode(value.stateRoot));
|
33616
33454
|
parts.push(new TxPointerCoder().encode(value.txPointer));
|
@@ -33622,7 +33460,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33622
33460
|
let o = offset;
|
33623
33461
|
[decoded, o] = new B256Coder().decode(data, o);
|
33624
33462
|
const txID = decoded;
|
33625
|
-
[decoded, o] = new NumberCoder("
|
33463
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
33626
33464
|
const outputIndex = decoded;
|
33627
33465
|
[decoded, o] = new B256Coder().decode(data, o);
|
33628
33466
|
const balanceRoot = decoded;
|
@@ -33671,16 +33509,14 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33671
33509
|
parts.push(new ByteArrayCoder(32).encode(value.recipient));
|
33672
33510
|
parts.push(new BigNumberCoder("u64").encode(value.amount));
|
33673
33511
|
parts.push(new ByteArrayCoder(32).encode(value.nonce));
|
33674
|
-
parts.push(new NumberCoder("
|
33512
|
+
parts.push(new NumberCoder("u8").encode(value.witnessIndex));
|
33675
33513
|
parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
|
33676
|
-
parts.push(new
|
33677
|
-
parts.push(new
|
33678
|
-
parts.push(new
|
33514
|
+
parts.push(new NumberCoder("u32").encode(data.length));
|
33515
|
+
parts.push(new NumberCoder("u32").encode(value.predicateLength));
|
33516
|
+
parts.push(new NumberCoder("u32").encode(value.predicateDataLength));
|
33679
33517
|
parts.push(new ByteArrayCoder(data.length).encode(data));
|
33680
|
-
parts.push(new ByteArrayCoder(value.predicateLength
|
33681
|
-
parts.push(
|
33682
|
-
new ByteArrayCoder(value.predicateDataLength.toNumber()).encode(value.predicateData)
|
33683
|
-
);
|
33518
|
+
parts.push(new ByteArrayCoder(value.predicateLength).encode(value.predicate));
|
33519
|
+
parts.push(new ByteArrayCoder(value.predicateDataLength).encode(value.predicateData));
|
33684
33520
|
return concat(parts);
|
33685
33521
|
}
|
33686
33522
|
static decodeData(messageData) {
|
@@ -33700,21 +33536,21 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33700
33536
|
const amount = decoded;
|
33701
33537
|
[decoded, o] = new B256Coder().decode(data, o);
|
33702
33538
|
const nonce = decoded;
|
33703
|
-
[decoded, o] = new NumberCoder("
|
33539
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
33704
33540
|
const witnessIndex = Number(decoded);
|
33705
33541
|
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33706
33542
|
const predicateGasUsed = decoded;
|
33707
33543
|
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33708
33544
|
const dataLength2 = decoded;
|
33709
|
-
[decoded, o] = new
|
33545
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33710
33546
|
const predicateLength = decoded;
|
33711
|
-
[decoded, o] = new
|
33547
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33712
33548
|
const predicateDataLength = decoded;
|
33713
33549
|
[decoded, o] = new ByteArrayCoder(dataLength2).decode(data, o);
|
33714
33550
|
const messageData = decoded;
|
33715
|
-
[decoded, o] = new ByteArrayCoder(predicateLength
|
33551
|
+
[decoded, o] = new ByteArrayCoder(predicateLength).decode(data, o);
|
33716
33552
|
const predicate = decoded;
|
33717
|
-
[decoded, o] = new ByteArrayCoder(predicateDataLength
|
33553
|
+
[decoded, o] = new ByteArrayCoder(predicateDataLength).decode(data, o);
|
33718
33554
|
const predicateData = decoded;
|
33719
33555
|
return [
|
33720
33556
|
{
|
@@ -34026,7 +33862,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34026
33862
|
}
|
34027
33863
|
};
|
34028
33864
|
var PolicyType = /* @__PURE__ */ ((PolicyType2) => {
|
34029
|
-
PolicyType2[PolicyType2["
|
33865
|
+
PolicyType2[PolicyType2["GasPrice"] = 1] = "GasPrice";
|
34030
33866
|
PolicyType2[PolicyType2["WitnessLimit"] = 2] = "WitnessLimit";
|
34031
33867
|
PolicyType2[PolicyType2["Maturity"] = 4] = "Maturity";
|
34032
33868
|
PolicyType2[PolicyType2["MaxFee"] = 8] = "MaxFee";
|
@@ -34074,9 +33910,9 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34074
33910
|
let o = offset;
|
34075
33911
|
const policies = [];
|
34076
33912
|
if (policyTypes & 1) {
|
34077
|
-
const [
|
33913
|
+
const [gasPrice, nextOffset] = new BigNumberCoder("u64").decode(data, o);
|
34078
33914
|
o = nextOffset;
|
34079
|
-
policies.push({ type: 1, data:
|
33915
|
+
policies.push({ type: 1, data: gasPrice });
|
34080
33916
|
}
|
34081
33917
|
if (policyTypes & 2) {
|
34082
33918
|
const [witnessLimit, nextOffset] = new BigNumberCoder("u64").decode(data, o);
|
@@ -34308,15 +34144,15 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34308
34144
|
encode(value) {
|
34309
34145
|
const parts = [];
|
34310
34146
|
parts.push(new BigNumberCoder("u64").encode(value.scriptGasLimit));
|
34311
|
-
parts.push(new
|
34312
|
-
parts.push(new
|
34313
|
-
parts.push(new BigNumberCoder("u64").encode(value.scriptDataLength));
|
34147
|
+
parts.push(new NumberCoder("u32").encode(value.scriptLength));
|
34148
|
+
parts.push(new NumberCoder("u32").encode(value.scriptDataLength));
|
34314
34149
|
parts.push(new NumberCoder("u32").encode(value.policyTypes));
|
34315
|
-
parts.push(new NumberCoder("
|
34316
|
-
parts.push(new NumberCoder("
|
34317
|
-
parts.push(new NumberCoder("
|
34318
|
-
parts.push(new
|
34319
|
-
parts.push(new ByteArrayCoder(value.
|
34150
|
+
parts.push(new NumberCoder("u8").encode(value.inputsCount));
|
34151
|
+
parts.push(new NumberCoder("u8").encode(value.outputsCount));
|
34152
|
+
parts.push(new NumberCoder("u8").encode(value.witnessesCount));
|
34153
|
+
parts.push(new B256Coder().encode(value.receiptsRoot));
|
34154
|
+
parts.push(new ByteArrayCoder(value.scriptLength).encode(value.script));
|
34155
|
+
parts.push(new ByteArrayCoder(value.scriptDataLength).encode(value.scriptData));
|
34320
34156
|
parts.push(new PoliciesCoder().encode(value.policies));
|
34321
34157
|
parts.push(new ArrayCoder(new InputCoder(), value.inputsCount).encode(value.inputs));
|
34322
34158
|
parts.push(new ArrayCoder(new OutputCoder(), value.outputsCount).encode(value.outputs));
|
@@ -34328,23 +34164,23 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34328
34164
|
let o = offset;
|
34329
34165
|
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34330
34166
|
const scriptGasLimit = decoded;
|
34331
|
-
[decoded, o] = new
|
34332
|
-
const receiptsRoot = decoded;
|
34333
|
-
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34167
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
34334
34168
|
const scriptLength = decoded;
|
34335
|
-
[decoded, o] = new
|
34169
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
34336
34170
|
const scriptDataLength = decoded;
|
34337
34171
|
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
34338
34172
|
const policyTypes = decoded;
|
34339
|
-
[decoded, o] = new NumberCoder("
|
34173
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34340
34174
|
const inputsCount = decoded;
|
34341
|
-
[decoded, o] = new NumberCoder("
|
34175
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34342
34176
|
const outputsCount = decoded;
|
34343
|
-
[decoded, o] = new NumberCoder("
|
34177
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34344
34178
|
const witnessesCount = decoded;
|
34345
|
-
[decoded, o] = new
|
34179
|
+
[decoded, o] = new B256Coder().decode(data, o);
|
34180
|
+
const receiptsRoot = decoded;
|
34181
|
+
[decoded, o] = new ByteArrayCoder(scriptLength).decode(data, o);
|
34346
34182
|
const script = decoded;
|
34347
|
-
[decoded, o] = new ByteArrayCoder(scriptDataLength
|
34183
|
+
[decoded, o] = new ByteArrayCoder(scriptDataLength).decode(data, o);
|
34348
34184
|
const scriptData = decoded;
|
34349
34185
|
[decoded, o] = new PoliciesCoder().decode(data, o, policyTypes);
|
34350
34186
|
const policies = decoded;
|
@@ -34382,19 +34218,18 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34382
34218
|
}
|
34383
34219
|
encode(value) {
|
34384
34220
|
const parts = [];
|
34385
|
-
parts.push(new NumberCoder("
|
34386
|
-
parts.push(new
|
34387
|
-
parts.push(new BigNumberCoder("u64").encode(value.storageSlotsCount));
|
34221
|
+
parts.push(new NumberCoder("u32").encode(value.bytecodeLength));
|
34222
|
+
parts.push(new NumberCoder("u8").encode(value.bytecodeWitnessIndex));
|
34388
34223
|
parts.push(new NumberCoder("u32").encode(value.policyTypes));
|
34389
|
-
parts.push(new NumberCoder("u16").encode(value.
|
34390
|
-
parts.push(new NumberCoder("
|
34391
|
-
parts.push(new NumberCoder("
|
34224
|
+
parts.push(new NumberCoder("u16").encode(value.storageSlotsCount));
|
34225
|
+
parts.push(new NumberCoder("u8").encode(value.inputsCount));
|
34226
|
+
parts.push(new NumberCoder("u8").encode(value.outputsCount));
|
34227
|
+
parts.push(new NumberCoder("u8").encode(value.witnessesCount));
|
34228
|
+
parts.push(new B256Coder().encode(value.salt));
|
34229
|
+
parts.push(new PoliciesCoder().encode(value.policies));
|
34392
34230
|
parts.push(
|
34393
|
-
new ArrayCoder(new StorageSlotCoder(), value.storageSlotsCount
|
34394
|
-
value.storageSlots
|
34395
|
-
)
|
34231
|
+
new ArrayCoder(new StorageSlotCoder(), value.storageSlotsCount).encode(value.storageSlots)
|
34396
34232
|
);
|
34397
|
-
parts.push(new PoliciesCoder().encode(value.policies));
|
34398
34233
|
parts.push(new ArrayCoder(new InputCoder(), value.inputsCount).encode(value.inputs));
|
34399
34234
|
parts.push(new ArrayCoder(new OutputCoder(), value.outputsCount).encode(value.outputs));
|
34400
34235
|
parts.push(new ArrayCoder(new WitnessCoder(), value.witnessesCount).encode(value.witnesses));
|
@@ -34403,27 +34238,26 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34403
34238
|
decode(data, offset) {
|
34404
34239
|
let decoded;
|
34405
34240
|
let o = offset;
|
34406
|
-
[decoded, o] = new NumberCoder("
|
34241
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
34242
|
+
const bytecodeLength = decoded;
|
34243
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34407
34244
|
const bytecodeWitnessIndex = decoded;
|
34408
|
-
[decoded, o] = new B256Coder().decode(data, o);
|
34409
|
-
const salt = decoded;
|
34410
|
-
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34411
|
-
const storageSlotsCount = decoded;
|
34412
34245
|
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
34413
34246
|
const policyTypes = decoded;
|
34414
34247
|
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
34248
|
+
const storageSlotsCount = decoded;
|
34249
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34415
34250
|
const inputsCount = decoded;
|
34416
|
-
[decoded, o] = new NumberCoder("
|
34251
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34417
34252
|
const outputsCount = decoded;
|
34418
|
-
[decoded, o] = new NumberCoder("
|
34253
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34419
34254
|
const witnessesCount = decoded;
|
34420
|
-
[decoded, o] = new
|
34421
|
-
|
34422
|
-
o
|
34423
|
-
);
|
34424
|
-
const storageSlots = decoded;
|
34255
|
+
[decoded, o] = new B256Coder().decode(data, o);
|
34256
|
+
const salt = decoded;
|
34425
34257
|
[decoded, o] = new PoliciesCoder().decode(data, o, policyTypes);
|
34426
34258
|
const policies = decoded;
|
34259
|
+
[decoded, o] = new ArrayCoder(new StorageSlotCoder(), storageSlotsCount).decode(data, o);
|
34260
|
+
const storageSlots = decoded;
|
34427
34261
|
[decoded, o] = new ArrayCoder(new InputCoder(), inputsCount).decode(data, o);
|
34428
34262
|
const inputs = decoded;
|
34429
34263
|
[decoded, o] = new ArrayCoder(new OutputCoder(), outputsCount).decode(data, o);
|
@@ -34433,6 +34267,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34433
34267
|
return [
|
34434
34268
|
{
|
34435
34269
|
type: 1,
|
34270
|
+
bytecodeLength,
|
34436
34271
|
bytecodeWitnessIndex,
|
34437
34272
|
policyTypes,
|
34438
34273
|
storageSlotsCount,
|
@@ -34461,7 +34296,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34461
34296
|
parts.push(new OutputContractCoder().encode(value.outputContract));
|
34462
34297
|
parts.push(new BigNumberCoder("u64").encode(value.mintAmount));
|
34463
34298
|
parts.push(new B256Coder().encode(value.mintAssetId));
|
34464
|
-
parts.push(new BigNumberCoder("u64").encode(value.gasPrice));
|
34465
34299
|
return concat(parts);
|
34466
34300
|
}
|
34467
34301
|
decode(data, offset) {
|
@@ -34477,8 +34311,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34477
34311
|
const mintAmount = decoded;
|
34478
34312
|
[decoded, o] = new B256Coder().decode(data, o);
|
34479
34313
|
const mintAssetId = decoded;
|
34480
|
-
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34481
|
-
const gasPrice = decoded;
|
34482
34314
|
return [
|
34483
34315
|
{
|
34484
34316
|
type: 2,
|
@@ -34486,8 +34318,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34486
34318
|
inputContract,
|
34487
34319
|
outputContract,
|
34488
34320
|
mintAmount,
|
34489
|
-
mintAssetId
|
34490
|
-
gasPrice
|
34321
|
+
mintAssetId
|
34491
34322
|
},
|
34492
34323
|
o
|
34493
34324
|
];
|
@@ -34794,6 +34625,159 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34794
34625
|
// src/providers/provider.ts
|
34795
34626
|
var import_graphql_request = __toESM(require_dist2());
|
34796
34627
|
|
34628
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isPlaceholder.js
|
34629
|
+
function _isPlaceholder(a) {
|
34630
|
+
return a != null && typeof a === "object" && a["@@functional/placeholder"] === true;
|
34631
|
+
}
|
34632
|
+
|
34633
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_curry1.js
|
34634
|
+
function _curry1(fn) {
|
34635
|
+
return function f1(a) {
|
34636
|
+
if (arguments.length === 0 || _isPlaceholder(a)) {
|
34637
|
+
return f1;
|
34638
|
+
} else {
|
34639
|
+
return fn.apply(this, arguments);
|
34640
|
+
}
|
34641
|
+
};
|
34642
|
+
}
|
34643
|
+
|
34644
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isArray.js
|
34645
|
+
var isArray_default = Array.isArray || function _isArray(val) {
|
34646
|
+
return val != null && val.length >= 0 && Object.prototype.toString.call(val) === "[object Array]";
|
34647
|
+
};
|
34648
|
+
|
34649
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/type.js
|
34650
|
+
var type = /* @__PURE__ */ _curry1(function type2(val) {
|
34651
|
+
return val === null ? "Null" : val === void 0 ? "Undefined" : Object.prototype.toString.call(val).slice(8, -1);
|
34652
|
+
});
|
34653
|
+
var type_default = type;
|
34654
|
+
|
34655
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_toISOString.js
|
34656
|
+
var pad = function pad2(n) {
|
34657
|
+
return (n < 10 ? "0" : "") + n;
|
34658
|
+
};
|
34659
|
+
var _toISOString = typeof Date.prototype.toISOString === "function" ? function _toISOString2(d) {
|
34660
|
+
return d.toISOString();
|
34661
|
+
} : function _toISOString3(d) {
|
34662
|
+
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";
|
34663
|
+
};
|
34664
|
+
|
34665
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isInteger.js
|
34666
|
+
var isInteger_default = Number.isInteger || function _isInteger(n) {
|
34667
|
+
return n << 0 === n;
|
34668
|
+
};
|
34669
|
+
|
34670
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_cloneRegExp.js
|
34671
|
+
function _cloneRegExp(pattern) {
|
34672
|
+
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" : ""));
|
34673
|
+
}
|
34674
|
+
|
34675
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_clone.js
|
34676
|
+
function _clone(value, deep, map) {
|
34677
|
+
map || (map = new _ObjectMap());
|
34678
|
+
if (_isPrimitive(value)) {
|
34679
|
+
return value;
|
34680
|
+
}
|
34681
|
+
var copy = function copy2(copiedValue) {
|
34682
|
+
var cachedCopy = map.get(value);
|
34683
|
+
if (cachedCopy) {
|
34684
|
+
return cachedCopy;
|
34685
|
+
}
|
34686
|
+
map.set(value, copiedValue);
|
34687
|
+
for (var key in value) {
|
34688
|
+
if (Object.prototype.hasOwnProperty.call(value, key)) {
|
34689
|
+
copiedValue[key] = deep ? _clone(value[key], true, map) : value[key];
|
34690
|
+
}
|
34691
|
+
}
|
34692
|
+
return copiedValue;
|
34693
|
+
};
|
34694
|
+
switch (type_default(value)) {
|
34695
|
+
case "Object":
|
34696
|
+
return copy(Object.create(Object.getPrototypeOf(value)));
|
34697
|
+
case "Array":
|
34698
|
+
return copy([]);
|
34699
|
+
case "Date":
|
34700
|
+
return new Date(value.valueOf());
|
34701
|
+
case "RegExp":
|
34702
|
+
return _cloneRegExp(value);
|
34703
|
+
case "Int8Array":
|
34704
|
+
case "Uint8Array":
|
34705
|
+
case "Uint8ClampedArray":
|
34706
|
+
case "Int16Array":
|
34707
|
+
case "Uint16Array":
|
34708
|
+
case "Int32Array":
|
34709
|
+
case "Uint32Array":
|
34710
|
+
case "Float32Array":
|
34711
|
+
case "Float64Array":
|
34712
|
+
case "BigInt64Array":
|
34713
|
+
case "BigUint64Array":
|
34714
|
+
return value.slice();
|
34715
|
+
default:
|
34716
|
+
return value;
|
34717
|
+
}
|
34718
|
+
}
|
34719
|
+
function _isPrimitive(param) {
|
34720
|
+
var type3 = typeof param;
|
34721
|
+
return param == null || type3 != "object" && type3 != "function";
|
34722
|
+
}
|
34723
|
+
var _ObjectMap = /* @__PURE__ */ function() {
|
34724
|
+
function _ObjectMap2() {
|
34725
|
+
this.map = {};
|
34726
|
+
this.length = 0;
|
34727
|
+
}
|
34728
|
+
_ObjectMap2.prototype.set = function(key, value) {
|
34729
|
+
const hashedKey = this.hash(key);
|
34730
|
+
let bucket = this.map[hashedKey];
|
34731
|
+
if (!bucket) {
|
34732
|
+
this.map[hashedKey] = bucket = [];
|
34733
|
+
}
|
34734
|
+
bucket.push([key, value]);
|
34735
|
+
this.length += 1;
|
34736
|
+
};
|
34737
|
+
_ObjectMap2.prototype.hash = function(key) {
|
34738
|
+
let hashedKey = [];
|
34739
|
+
for (var value in key) {
|
34740
|
+
hashedKey.push(Object.prototype.toString.call(key[value]));
|
34741
|
+
}
|
34742
|
+
return hashedKey.join();
|
34743
|
+
};
|
34744
|
+
_ObjectMap2.prototype.get = function(key) {
|
34745
|
+
if (this.length <= 180) {
|
34746
|
+
for (const p in this.map) {
|
34747
|
+
const bucket2 = this.map[p];
|
34748
|
+
for (let i = 0; i < bucket2.length; i += 1) {
|
34749
|
+
const element = bucket2[i];
|
34750
|
+
if (element[0] === key) {
|
34751
|
+
return element[1];
|
34752
|
+
}
|
34753
|
+
}
|
34754
|
+
}
|
34755
|
+
return;
|
34756
|
+
}
|
34757
|
+
const hashedKey = this.hash(key);
|
34758
|
+
const bucket = this.map[hashedKey];
|
34759
|
+
if (!bucket) {
|
34760
|
+
return;
|
34761
|
+
}
|
34762
|
+
for (let i = 0; i < bucket.length; i += 1) {
|
34763
|
+
const element = bucket[i];
|
34764
|
+
if (element[0] === key) {
|
34765
|
+
return element[1];
|
34766
|
+
}
|
34767
|
+
}
|
34768
|
+
};
|
34769
|
+
return _ObjectMap2;
|
34770
|
+
}();
|
34771
|
+
|
34772
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/clone.js
|
34773
|
+
var clone2 = /* @__PURE__ */ _curry1(function clone3(value) {
|
34774
|
+
return value != null && typeof value.clone === "function" ? value.clone() : _clone(value, true);
|
34775
|
+
});
|
34776
|
+
var clone_default = clone2;
|
34777
|
+
|
34778
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/trim.js
|
34779
|
+
var hasProtoTrim = typeof String.prototype.trim === "function";
|
34780
|
+
|
34797
34781
|
// ../../node_modules/.pnpm/tslib@2.6.0/node_modules/tslib/tslib.es6.mjs
|
34798
34782
|
var __assign = function() {
|
34799
34783
|
__assign = Object.assign || function __assign2(t) {
|
@@ -37961,10 +37945,14 @@ spurious results.`);
|
|
37961
37945
|
// src/providers/__generated__/operations.ts
|
37962
37946
|
var ReceiptFragmentFragmentDoc = lib_default2`
|
37963
37947
|
fragment receiptFragment on Receipt {
|
37964
|
-
|
37948
|
+
contract {
|
37949
|
+
id
|
37950
|
+
}
|
37965
37951
|
pc
|
37966
37952
|
is
|
37967
|
-
to
|
37953
|
+
to {
|
37954
|
+
id
|
37955
|
+
}
|
37968
37956
|
toAddress
|
37969
37957
|
amount
|
37970
37958
|
assetId
|
@@ -38002,16 +37990,10 @@ spurious results.`);
|
|
38002
37990
|
id
|
38003
37991
|
}
|
38004
37992
|
time
|
38005
|
-
receipts {
|
38006
|
-
...receiptFragment
|
38007
|
-
}
|
38008
37993
|
programState {
|
38009
37994
|
returnType
|
38010
37995
|
data
|
38011
37996
|
}
|
38012
|
-
receipts {
|
38013
|
-
...receiptFragment
|
38014
|
-
}
|
38015
37997
|
}
|
38016
37998
|
... on FailureStatus {
|
38017
37999
|
block {
|
@@ -38019,24 +38001,26 @@ spurious results.`);
|
|
38019
38001
|
}
|
38020
38002
|
time
|
38021
38003
|
reason
|
38022
|
-
receipts {
|
38023
|
-
...receiptFragment
|
38024
|
-
}
|
38025
38004
|
}
|
38026
38005
|
... on SqueezedOutStatus {
|
38027
38006
|
reason
|
38028
38007
|
}
|
38029
38008
|
}
|
38030
|
-
|
38009
|
+
`;
|
38031
38010
|
var TransactionFragmentFragmentDoc = lib_default2`
|
38032
38011
|
fragment transactionFragment on Transaction {
|
38033
38012
|
id
|
38034
38013
|
rawPayload
|
38014
|
+
gasPrice
|
38015
|
+
receipts {
|
38016
|
+
...receiptFragment
|
38017
|
+
}
|
38035
38018
|
status {
|
38036
38019
|
...transactionStatusFragment
|
38037
38020
|
}
|
38038
38021
|
}
|
38039
|
-
${
|
38022
|
+
${ReceiptFragmentFragmentDoc}
|
38023
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
38040
38024
|
var InputEstimatePredicatesFragmentFragmentDoc = lib_default2`
|
38041
38025
|
fragment inputEstimatePredicatesFragment on Input {
|
38042
38026
|
... on InputCoin {
|
@@ -38054,46 +38038,6 @@ spurious results.`);
|
|
38054
38038
|
}
|
38055
38039
|
}
|
38056
38040
|
${InputEstimatePredicatesFragmentFragmentDoc}`;
|
38057
|
-
var DryRunFailureStatusFragmentFragmentDoc = lib_default2`
|
38058
|
-
fragment dryRunFailureStatusFragment on DryRunFailureStatus {
|
38059
|
-
reason
|
38060
|
-
programState {
|
38061
|
-
returnType
|
38062
|
-
data
|
38063
|
-
}
|
38064
|
-
}
|
38065
|
-
`;
|
38066
|
-
var DryRunSuccessStatusFragmentFragmentDoc = lib_default2`
|
38067
|
-
fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
|
38068
|
-
programState {
|
38069
|
-
returnType
|
38070
|
-
data
|
38071
|
-
}
|
38072
|
-
}
|
38073
|
-
`;
|
38074
|
-
var DryRunTransactionStatusFragmentFragmentDoc = lib_default2`
|
38075
|
-
fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
|
38076
|
-
... on DryRunFailureStatus {
|
38077
|
-
...dryRunFailureStatusFragment
|
38078
|
-
}
|
38079
|
-
... on DryRunSuccessStatus {
|
38080
|
-
...dryRunSuccessStatusFragment
|
38081
|
-
}
|
38082
|
-
}
|
38083
|
-
${DryRunFailureStatusFragmentFragmentDoc}
|
38084
|
-
${DryRunSuccessStatusFragmentFragmentDoc}`;
|
38085
|
-
var DryRunTransactionExecutionStatusFragmentFragmentDoc = lib_default2`
|
38086
|
-
fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
|
38087
|
-
id
|
38088
|
-
status {
|
38089
|
-
...dryRunTransactionStatusFragment
|
38090
|
-
}
|
38091
|
-
receipts {
|
38092
|
-
...receiptFragment
|
38093
|
-
}
|
38094
|
-
}
|
38095
|
-
${DryRunTransactionStatusFragmentFragmentDoc}
|
38096
|
-
${ReceiptFragmentFragmentDoc}`;
|
38097
38041
|
var CoinFragmentFragmentDoc = lib_default2`
|
38098
38042
|
fragment coinFragment on Coin {
|
38099
38043
|
__typename
|
@@ -38101,6 +38045,7 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38101
38045
|
owner
|
38102
38046
|
amount
|
38103
38047
|
assetId
|
38048
|
+
maturity
|
38104
38049
|
blockCreated
|
38105
38050
|
txCreatedIdx
|
38106
38051
|
}
|
@@ -38145,6 +38090,7 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38145
38090
|
prevRoot
|
38146
38091
|
time
|
38147
38092
|
applicationHash
|
38093
|
+
messageReceiptRoot
|
38148
38094
|
messageReceiptCount
|
38149
38095
|
}
|
38150
38096
|
commitBlockHeader {
|
@@ -38156,6 +38102,7 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38156
38102
|
prevRoot
|
38157
38103
|
time
|
38158
38104
|
applicationHash
|
38105
|
+
messageReceiptRoot
|
38159
38106
|
messageReceiptCount
|
38160
38107
|
}
|
38161
38108
|
sender
|
@@ -38175,8 +38122,8 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38175
38122
|
var BlockFragmentFragmentDoc = lib_default2`
|
38176
38123
|
fragment blockFragment on Block {
|
38177
38124
|
id
|
38178
|
-
height
|
38179
38125
|
header {
|
38126
|
+
height
|
38180
38127
|
time
|
38181
38128
|
}
|
38182
38129
|
transactions {
|
@@ -38234,11 +38181,6 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38234
38181
|
`;
|
38235
38182
|
var GasCostsFragmentFragmentDoc = lib_default2`
|
38236
38183
|
fragment GasCostsFragment on GasCosts {
|
38237
|
-
version {
|
38238
|
-
... on Version {
|
38239
|
-
value
|
38240
|
-
}
|
38241
|
-
}
|
38242
38184
|
add
|
38243
38185
|
addi
|
38244
38186
|
aloc
|
@@ -38251,6 +38193,7 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38251
38193
|
cb
|
38252
38194
|
cfei
|
38253
38195
|
cfsi
|
38196
|
+
croo
|
38254
38197
|
div
|
38255
38198
|
divi
|
38256
38199
|
ecr1
|
@@ -38333,9 +38276,6 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38333
38276
|
ccp {
|
38334
38277
|
...DependentCostFragment
|
38335
38278
|
}
|
38336
|
-
croo {
|
38337
|
-
...DependentCostFragment
|
38338
|
-
}
|
38339
38279
|
csiz {
|
38340
38280
|
...DependentCostFragment
|
38341
38281
|
}
|
@@ -38395,11 +38335,6 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38395
38335
|
${DependentCostFragmentFragmentDoc}`;
|
38396
38336
|
var ConsensusParametersFragmentFragmentDoc = lib_default2`
|
38397
38337
|
fragment consensusParametersFragment on ConsensusParameters {
|
38398
|
-
version {
|
38399
|
-
... on Version {
|
38400
|
-
value
|
38401
|
-
}
|
38402
|
-
}
|
38403
38338
|
txParams {
|
38404
38339
|
...TxParametersFragment
|
38405
38340
|
}
|
@@ -38459,9 +38394,18 @@ ${ConsensusParametersFragmentFragmentDoc}`;
|
|
38459
38394
|
fragment nodeInfoFragment on NodeInfo {
|
38460
38395
|
utxoValidation
|
38461
38396
|
vmBacktrace
|
38397
|
+
minGasPrice
|
38462
38398
|
maxTx
|
38463
38399
|
maxDepth
|
38464
38400
|
nodeVersion
|
38401
|
+
peers {
|
38402
|
+
id
|
38403
|
+
addresses
|
38404
|
+
clientVersion
|
38405
|
+
blockHeight
|
38406
|
+
lastHeartbeatMs
|
38407
|
+
appScore
|
38408
|
+
}
|
38465
38409
|
}
|
38466
38410
|
`;
|
38467
38411
|
var GetVersionDocument = lib_default2`
|
@@ -38496,9 +38440,13 @@ ${ConsensusParametersFragmentFragmentDoc}`;
|
|
38496
38440
|
query getTransactionWithReceipts($transactionId: TransactionId!) {
|
38497
38441
|
transaction(id: $transactionId) {
|
38498
38442
|
...transactionFragment
|
38443
|
+
receipts {
|
38444
|
+
...receiptFragment
|
38445
|
+
}
|
38499
38446
|
}
|
38500
38447
|
}
|
38501
|
-
${TransactionFragmentFragmentDoc}
|
38448
|
+
${TransactionFragmentFragmentDoc}
|
38449
|
+
${ReceiptFragmentFragmentDoc}`;
|
38502
38450
|
var GetTransactionsDocument = lib_default2`
|
38503
38451
|
query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
|
38504
38452
|
transactions(after: $after, before: $before, first: $first, last: $last) {
|
@@ -38626,20 +38574,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38626
38574
|
}
|
38627
38575
|
}
|
38628
38576
|
${BalanceFragmentFragmentDoc}`;
|
38629
|
-
var GetLatestGasPriceDocument = lib_default2`
|
38630
|
-
query getLatestGasPrice {
|
38631
|
-
latestGasPrice {
|
38632
|
-
gasPrice
|
38633
|
-
}
|
38634
|
-
}
|
38635
|
-
`;
|
38636
|
-
var EstimateGasPriceDocument = lib_default2`
|
38637
|
-
query estimateGasPrice($blockHorizon: U32!) {
|
38638
|
-
estimateGasPrice(blockHorizon: $blockHorizon) {
|
38639
|
-
gasPrice
|
38640
|
-
}
|
38641
|
-
}
|
38642
|
-
`;
|
38643
38577
|
var GetBalancesDocument = lib_default2`
|
38644
38578
|
query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
38645
38579
|
balances(
|
@@ -38694,12 +38628,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38694
38628
|
}
|
38695
38629
|
`;
|
38696
38630
|
var DryRunDocument = lib_default2`
|
38697
|
-
mutation dryRun($
|
38698
|
-
dryRun(
|
38699
|
-
...
|
38631
|
+
mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
|
38632
|
+
dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
|
38633
|
+
...receiptFragment
|
38700
38634
|
}
|
38701
38635
|
}
|
38702
|
-
${
|
38636
|
+
${ReceiptFragmentFragmentDoc}`;
|
38703
38637
|
var SubmitDocument = lib_default2`
|
38704
38638
|
mutation submit($encodedTransaction: HexString!) {
|
38705
38639
|
submit(tx: $encodedTransaction) {
|
@@ -38782,12 +38716,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38782
38716
|
getBalance(variables, options) {
|
38783
38717
|
return requester(GetBalanceDocument, variables, options);
|
38784
38718
|
},
|
38785
|
-
getLatestGasPrice(variables, options) {
|
38786
|
-
return requester(GetLatestGasPriceDocument, variables, options);
|
38787
|
-
},
|
38788
|
-
estimateGasPrice(variables, options) {
|
38789
|
-
return requester(EstimateGasPriceDocument, variables, options);
|
38790
|
-
},
|
38791
38719
|
getBalances(variables, options) {
|
38792
38720
|
return requester(GetBalancesDocument, variables, options);
|
38793
38721
|
},
|
@@ -38855,14 +38783,11 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38855
38783
|
let data;
|
38856
38784
|
let errors;
|
38857
38785
|
try {
|
38858
|
-
|
38859
|
-
({ data, errors } = JSON.parse(sanitizedText.replace(/^data:/, "")));
|
38786
|
+
({ data, errors } = JSON.parse(text.replace(/^data:/, "")));
|
38860
38787
|
} catch (e) {
|
38861
38788
|
throw new FuelError(
|
38862
38789
|
ErrorCode.STREAM_PARSING_ERROR,
|
38863
|
-
`Error while parsing stream data response: ${text}
|
38864
|
-
|
38865
|
-
Thrown error: ${e}`
|
38790
|
+
`Error while parsing stream data response: ${text}`
|
38866
38791
|
);
|
38867
38792
|
}
|
38868
38793
|
if (Array.isArray(errors)) {
|
@@ -38956,7 +38881,7 @@ Thrown error: ${e}`
|
|
38956
38881
|
return {
|
38957
38882
|
type: InputType.Coin,
|
38958
38883
|
txID: hexlify(arrayify(value.id).slice(0, 32)),
|
38959
|
-
outputIndex: toNumber2(arrayify(value.id).slice(32,
|
38884
|
+
outputIndex: toNumber2(arrayify(value.id).slice(32, 33)),
|
38960
38885
|
owner: hexlify(value.owner),
|
38961
38886
|
amount: bn(value.amount),
|
38962
38887
|
assetId: hexlify(value.assetId),
|
@@ -38965,9 +38890,10 @@ Thrown error: ${e}`
|
|
38965
38890
|
txIndex: toNumber2(arrayify(value.txPointer).slice(8, 16))
|
38966
38891
|
},
|
38967
38892
|
witnessIndex: value.witnessIndex,
|
38893
|
+
maturity: value.maturity ?? 0,
|
38968
38894
|
predicateGasUsed: bn(value.predicateGasUsed),
|
38969
|
-
predicateLength:
|
38970
|
-
predicateDataLength:
|
38895
|
+
predicateLength: predicate.length,
|
38896
|
+
predicateDataLength: predicateData.length,
|
38971
38897
|
predicate: hexlify(predicate),
|
38972
38898
|
predicateData: hexlify(predicateData)
|
38973
38899
|
};
|
@@ -38998,8 +38924,8 @@ Thrown error: ${e}`
|
|
38998
38924
|
nonce: hexlify(value.nonce),
|
38999
38925
|
witnessIndex: value.witnessIndex,
|
39000
38926
|
predicateGasUsed: bn(value.predicateGasUsed),
|
39001
|
-
predicateLength:
|
39002
|
-
predicateDataLength:
|
38927
|
+
predicateLength: predicate.length,
|
38928
|
+
predicateDataLength: predicateData.length,
|
39003
38929
|
predicate: hexlify(predicate),
|
39004
38930
|
predicateData: hexlify(predicateData),
|
39005
38931
|
data: hexlify(data),
|
@@ -39159,8 +39085,8 @@ Thrown error: ${e}`
|
|
39159
39085
|
case "CALL" /* Call */: {
|
39160
39086
|
const callReceipt = {
|
39161
39087
|
type: ReceiptType.Call,
|
39162
|
-
from: hexOrZero(receipt.id
|
39163
|
-
to: hexOrZero(receipt?.to),
|
39088
|
+
from: hexOrZero(receipt.contract?.id),
|
39089
|
+
to: hexOrZero(receipt?.to?.id),
|
39164
39090
|
amount: bn(receipt.amount),
|
39165
39091
|
assetId: hexOrZero(receipt.assetId),
|
39166
39092
|
gas: bn(receipt.gas),
|
@@ -39174,7 +39100,7 @@ Thrown error: ${e}`
|
|
39174
39100
|
case "RETURN" /* Return */: {
|
39175
39101
|
const returnReceipt = {
|
39176
39102
|
type: ReceiptType.Return,
|
39177
|
-
id: hexOrZero(receipt.id
|
39103
|
+
id: hexOrZero(receipt.contract?.id),
|
39178
39104
|
val: bn(receipt.val),
|
39179
39105
|
pc: bn(receipt.pc),
|
39180
39106
|
is: bn(receipt.is)
|
@@ -39184,7 +39110,7 @@ Thrown error: ${e}`
|
|
39184
39110
|
case "RETURN_DATA" /* ReturnData */: {
|
39185
39111
|
const returnDataReceipt = {
|
39186
39112
|
type: ReceiptType.ReturnData,
|
39187
|
-
id: hexOrZero(receipt.id
|
39113
|
+
id: hexOrZero(receipt.contract?.id),
|
39188
39114
|
ptr: bn(receipt.ptr),
|
39189
39115
|
len: bn(receipt.len),
|
39190
39116
|
digest: hexOrZero(receipt.digest),
|
@@ -39196,7 +39122,7 @@ Thrown error: ${e}`
|
|
39196
39122
|
case "PANIC" /* Panic */: {
|
39197
39123
|
const panicReceipt = {
|
39198
39124
|
type: ReceiptType.Panic,
|
39199
|
-
id: hexOrZero(receipt.id),
|
39125
|
+
id: hexOrZero(receipt.contract?.id),
|
39200
39126
|
reason: bn(receipt.reason),
|
39201
39127
|
pc: bn(receipt.pc),
|
39202
39128
|
is: bn(receipt.is),
|
@@ -39207,7 +39133,7 @@ Thrown error: ${e}`
|
|
39207
39133
|
case "REVERT" /* Revert */: {
|
39208
39134
|
const revertReceipt = {
|
39209
39135
|
type: ReceiptType.Revert,
|
39210
|
-
id: hexOrZero(receipt.id
|
39136
|
+
id: hexOrZero(receipt.contract?.id),
|
39211
39137
|
val: bn(receipt.ra),
|
39212
39138
|
pc: bn(receipt.pc),
|
39213
39139
|
is: bn(receipt.is)
|
@@ -39217,7 +39143,7 @@ Thrown error: ${e}`
|
|
39217
39143
|
case "LOG" /* Log */: {
|
39218
39144
|
const logReceipt = {
|
39219
39145
|
type: ReceiptType.Log,
|
39220
|
-
id: hexOrZero(receipt.id
|
39146
|
+
id: hexOrZero(receipt.contract?.id),
|
39221
39147
|
val0: bn(receipt.ra),
|
39222
39148
|
val1: bn(receipt.rb),
|
39223
39149
|
val2: bn(receipt.rc),
|
@@ -39230,7 +39156,7 @@ Thrown error: ${e}`
|
|
39230
39156
|
case "LOG_DATA" /* LogData */: {
|
39231
39157
|
const logDataReceipt = {
|
39232
39158
|
type: ReceiptType.LogData,
|
39233
|
-
id: hexOrZero(receipt.id
|
39159
|
+
id: hexOrZero(receipt.contract?.id),
|
39234
39160
|
val0: bn(receipt.ra),
|
39235
39161
|
val1: bn(receipt.rb),
|
39236
39162
|
ptr: bn(receipt.ptr),
|
@@ -39244,8 +39170,8 @@ Thrown error: ${e}`
|
|
39244
39170
|
case "TRANSFER" /* Transfer */: {
|
39245
39171
|
const transferReceipt = {
|
39246
39172
|
type: ReceiptType.Transfer,
|
39247
|
-
from: hexOrZero(receipt.id
|
39248
|
-
to: hexOrZero(receipt.toAddress || receipt?.to),
|
39173
|
+
from: hexOrZero(receipt.contract?.id),
|
39174
|
+
to: hexOrZero(receipt.toAddress || receipt?.to?.id),
|
39249
39175
|
amount: bn(receipt.amount),
|
39250
39176
|
assetId: hexOrZero(receipt.assetId),
|
39251
39177
|
pc: bn(receipt.pc),
|
@@ -39256,8 +39182,8 @@ Thrown error: ${e}`
|
|
39256
39182
|
case "TRANSFER_OUT" /* TransferOut */: {
|
39257
39183
|
const transferOutReceipt = {
|
39258
39184
|
type: ReceiptType.TransferOut,
|
39259
|
-
from: hexOrZero(receipt.id
|
39260
|
-
to: hexOrZero(receipt.toAddress || receipt.to),
|
39185
|
+
from: hexOrZero(receipt.contract?.id),
|
39186
|
+
to: hexOrZero(receipt.toAddress || receipt.to?.id),
|
39261
39187
|
amount: bn(receipt.amount),
|
39262
39188
|
assetId: hexOrZero(receipt.assetId),
|
39263
39189
|
pc: bn(receipt.pc),
|
@@ -39300,7 +39226,7 @@ Thrown error: ${e}`
|
|
39300
39226
|
return receiptMessageOut;
|
39301
39227
|
}
|
39302
39228
|
case "MINT" /* Mint */: {
|
39303
|
-
const contractId = hexOrZero(receipt.id
|
39229
|
+
const contractId = hexOrZero(receipt.contract?.id);
|
39304
39230
|
const subId = hexOrZero(receipt.subId);
|
39305
39231
|
const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
|
39306
39232
|
const mintReceipt = {
|
@@ -39315,7 +39241,7 @@ Thrown error: ${e}`
|
|
39315
39241
|
return mintReceipt;
|
39316
39242
|
}
|
39317
39243
|
case "BURN" /* Burn */: {
|
39318
|
-
const contractId = hexOrZero(receipt.id
|
39244
|
+
const contractId = hexOrZero(receipt.contract?.id);
|
39319
39245
|
const subId = hexOrZero(receipt.subId);
|
39320
39246
|
const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
|
39321
39247
|
const burnReceipt = {
|
@@ -39396,6 +39322,7 @@ Thrown error: ${e}`
|
|
39396
39322
|
};
|
39397
39323
|
|
39398
39324
|
// src/providers/utils/gas.ts
|
39325
|
+
var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
|
39399
39326
|
var getGasUsedFromReceipts = (receipts) => {
|
39400
39327
|
const scriptResult = receipts.filter(
|
39401
39328
|
(receipt) => receipt.type === ReceiptType.ScriptResult
|
@@ -39416,28 +39343,18 @@ Thrown error: ${e}`
|
|
39416
39343
|
}
|
39417
39344
|
function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
39418
39345
|
const witnessCache = [];
|
39419
|
-
const
|
39420
|
-
const isCoinOrMessage = "owner" in input || "sender" in input;
|
39421
|
-
if (isCoinOrMessage) {
|
39422
|
-
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
39423
|
-
return true;
|
39424
|
-
}
|
39425
|
-
if (!witnessCache.includes(input.witnessIndex)) {
|
39426
|
-
witnessCache.push(input.witnessIndex);
|
39427
|
-
return true;
|
39428
|
-
}
|
39429
|
-
}
|
39430
|
-
return false;
|
39431
|
-
});
|
39432
|
-
const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
|
39433
|
-
const totalGas = chargeableInputs.reduce((total, input) => {
|
39346
|
+
const totalGas = inputs.reduce((total, input) => {
|
39434
39347
|
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
39435
39348
|
return total.add(
|
39436
|
-
|
39349
|
+
resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify(input.predicate).length, gasCosts.contractRoot)).add(bn(input.predicateGasUsed))
|
39437
39350
|
);
|
39438
39351
|
}
|
39439
|
-
|
39440
|
-
|
39352
|
+
if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
|
39353
|
+
witnessCache.push(input.witnessIndex);
|
39354
|
+
return total.add(gasCosts.ecr1);
|
39355
|
+
}
|
39356
|
+
return total;
|
39357
|
+
}, bn());
|
39441
39358
|
return totalGas;
|
39442
39359
|
}
|
39443
39360
|
function getMinGas(params) {
|
@@ -39449,20 +39366,12 @@ Thrown error: ${e}`
|
|
39449
39366
|
return minGas;
|
39450
39367
|
}
|
39451
39368
|
function getMaxGas(params) {
|
39452
|
-
const {
|
39453
|
-
gasPerByte,
|
39454
|
-
witnessesLength,
|
39455
|
-
witnessLimit,
|
39456
|
-
minGas,
|
39457
|
-
gasLimit = bn(0),
|
39458
|
-
maxGasPerTx
|
39459
|
-
} = params;
|
39369
|
+
const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = bn(0) } = params;
|
39460
39370
|
let remainingAllowedWitnessGas = bn(0);
|
39461
39371
|
if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
|
39462
39372
|
remainingAllowedWitnessGas = bn(witnessLimit).sub(witnessesLength).mul(gasPerByte);
|
39463
39373
|
}
|
39464
|
-
|
39465
|
-
return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
|
39374
|
+
return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
|
39466
39375
|
}
|
39467
39376
|
function calculateMetadataGasForTxCreate({
|
39468
39377
|
gasCosts,
|
@@ -39484,10 +39393,6 @@ Thrown error: ${e}`
|
|
39484
39393
|
}) {
|
39485
39394
|
return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
39486
39395
|
}
|
39487
|
-
var calculateGasFee = (params) => {
|
39488
|
-
const { gas, gasPrice, priceFactor, tip } = params;
|
39489
|
-
return gas.mul(gasPrice).div(priceFactor).add(tip);
|
39490
|
-
};
|
39491
39396
|
|
39492
39397
|
// src/providers/utils/json.ts
|
39493
39398
|
function normalize2(object) {
|
@@ -39629,7 +39534,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39629
39534
|
// src/providers/transaction-request/transaction-request.ts
|
39630
39535
|
var BaseTransactionRequest = class {
|
39631
39536
|
/** Gas price for transaction */
|
39632
|
-
|
39537
|
+
gasPrice;
|
39633
39538
|
/** Block until which tx cannot be included */
|
39634
39539
|
maturity;
|
39635
39540
|
/** The maximum fee payable by this transaction using BASE_ASSET. */
|
@@ -39648,7 +39553,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39648
39553
|
* @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
|
39649
39554
|
*/
|
39650
39555
|
constructor({
|
39651
|
-
|
39556
|
+
gasPrice,
|
39652
39557
|
maturity,
|
39653
39558
|
maxFee,
|
39654
39559
|
witnessLimit,
|
@@ -39656,7 +39561,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39656
39561
|
outputs,
|
39657
39562
|
witnesses
|
39658
39563
|
} = {}) {
|
39659
|
-
this.
|
39564
|
+
this.gasPrice = bn(gasPrice);
|
39660
39565
|
this.maturity = maturity ?? 0;
|
39661
39566
|
this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
|
39662
39567
|
this.maxFee = maxFee ? bn(maxFee) : void 0;
|
@@ -39667,9 +39572,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39667
39572
|
static getPolicyMeta(req) {
|
39668
39573
|
let policyTypes = 0;
|
39669
39574
|
const policies = [];
|
39670
|
-
if (req.
|
39671
|
-
policyTypes += PolicyType.
|
39672
|
-
policies.push({ data: req.
|
39575
|
+
if (req.gasPrice) {
|
39576
|
+
policyTypes += PolicyType.GasPrice;
|
39577
|
+
policies.push({ data: req.gasPrice, type: PolicyType.GasPrice });
|
39673
39578
|
}
|
39674
39579
|
if (req.witnessLimit) {
|
39675
39580
|
policyTypes += PolicyType.WitnessLimit;
|
@@ -39856,10 +39761,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39856
39761
|
* @param predicate - Predicate bytes.
|
39857
39762
|
* @param predicateData - Predicate data bytes.
|
39858
39763
|
*/
|
39859
|
-
addCoinInput(coin) {
|
39764
|
+
addCoinInput(coin, predicate) {
|
39860
39765
|
const { assetId, owner, amount } = coin;
|
39861
39766
|
let witnessIndex;
|
39862
|
-
if (
|
39767
|
+
if (predicate) {
|
39863
39768
|
witnessIndex = 0;
|
39864
39769
|
} else {
|
39865
39770
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
|
@@ -39874,7 +39779,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39874
39779
|
amount,
|
39875
39780
|
assetId,
|
39876
39781
|
txPointer: "0x00000000000000000000000000000000",
|
39877
|
-
witnessIndex
|
39782
|
+
witnessIndex,
|
39783
|
+
predicate: predicate?.bytes,
|
39784
|
+
predicateData: predicate?.predicateDataBytes
|
39878
39785
|
};
|
39879
39786
|
this.pushInput(input);
|
39880
39787
|
this.addChangeOutput(owner, assetId);
|
@@ -39887,11 +39794,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39887
39794
|
* @param predicate - Predicate bytes.
|
39888
39795
|
* @param predicateData - Predicate data bytes.
|
39889
39796
|
*/
|
39890
|
-
addMessageInput(message) {
|
39797
|
+
addMessageInput(message, predicate) {
|
39891
39798
|
const { recipient, sender, amount } = message;
|
39892
39799
|
const assetId = BaseAssetId;
|
39893
39800
|
let witnessIndex;
|
39894
|
-
if (
|
39801
|
+
if (predicate) {
|
39895
39802
|
witnessIndex = 0;
|
39896
39803
|
} else {
|
39897
39804
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
|
@@ -39905,7 +39812,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39905
39812
|
sender: sender.toB256(),
|
39906
39813
|
recipient: recipient.toB256(),
|
39907
39814
|
amount,
|
39908
|
-
witnessIndex
|
39815
|
+
witnessIndex,
|
39816
|
+
predicate: predicate?.bytes,
|
39817
|
+
predicateData: predicate?.predicateDataBytes
|
39909
39818
|
};
|
39910
39819
|
this.pushInput(input);
|
39911
39820
|
this.addChangeOutput(recipient, assetId);
|
@@ -39936,6 +39845,32 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39936
39845
|
resources.forEach((resource) => this.addResource(resource));
|
39937
39846
|
return this;
|
39938
39847
|
}
|
39848
|
+
/**
|
39849
|
+
* Adds multiple resources to the transaction by adding coin/message inputs and change
|
39850
|
+
* outputs from the related assetIds.
|
39851
|
+
*
|
39852
|
+
* @param resources - The resources to add.
|
39853
|
+
* @returns This transaction.
|
39854
|
+
*/
|
39855
|
+
addPredicateResource(resource, predicate) {
|
39856
|
+
if (isCoin(resource)) {
|
39857
|
+
this.addCoinInput(resource, predicate);
|
39858
|
+
} else {
|
39859
|
+
this.addMessageInput(resource, predicate);
|
39860
|
+
}
|
39861
|
+
return this;
|
39862
|
+
}
|
39863
|
+
/**
|
39864
|
+
* Adds multiple predicate coin/message inputs to the transaction and change outputs
|
39865
|
+
* from the related assetIds.
|
39866
|
+
*
|
39867
|
+
* @param resources - The resources to add.
|
39868
|
+
* @returns This transaction.
|
39869
|
+
*/
|
39870
|
+
addPredicateResources(resources, predicate) {
|
39871
|
+
resources.forEach((resource) => this.addPredicateResource(resource, predicate));
|
39872
|
+
return this;
|
39873
|
+
}
|
39939
39874
|
/**
|
39940
39875
|
* Adds a coin output to the transaction.
|
39941
39876
|
*
|
@@ -40015,7 +39950,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40015
39950
|
}
|
40016
39951
|
calculateMaxGas(chainInfo, minGas) {
|
40017
39952
|
const { consensusParameters } = chainInfo;
|
40018
|
-
const { gasPerByte
|
39953
|
+
const { gasPerByte } = consensusParameters;
|
40019
39954
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
40020
39955
|
(acc, wit) => acc + wit.dataLength,
|
40021
39956
|
0
|
@@ -40024,8 +39959,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40024
39959
|
gasPerByte,
|
40025
39960
|
minGas,
|
40026
39961
|
witnessesLength,
|
40027
|
-
witnessLimit: this.witnessLimit
|
40028
|
-
maxGasPerTx
|
39962
|
+
witnessLimit: this.witnessLimit
|
40029
39963
|
});
|
40030
39964
|
}
|
40031
39965
|
/**
|
@@ -40043,20 +39977,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40043
39977
|
});
|
40044
39978
|
const updateAssetInput = (assetId, quantity) => {
|
40045
39979
|
const assetInput = findAssetInput(assetId);
|
40046
|
-
let usedQuantity = quantity;
|
40047
|
-
if (assetId === BaseAssetId) {
|
40048
|
-
usedQuantity = bn("1000000000000000000");
|
40049
|
-
}
|
40050
39980
|
if (assetInput && "assetId" in assetInput) {
|
40051
|
-
assetInput.id = hexlify(randomBytes3(
|
40052
|
-
assetInput.amount =
|
39981
|
+
assetInput.id = hexlify(randomBytes3(33));
|
39982
|
+
assetInput.amount = quantity;
|
40053
39983
|
} else {
|
40054
39984
|
this.addResources([
|
40055
39985
|
{
|
40056
|
-
id: hexlify(randomBytes3(
|
40057
|
-
amount:
|
39986
|
+
id: hexlify(randomBytes3(33)),
|
39987
|
+
amount: quantity,
|
40058
39988
|
assetId,
|
40059
39989
|
owner: resourcesOwner || Address.fromRandom(),
|
39990
|
+
maturity: 0,
|
40060
39991
|
blockCreated: bn(1),
|
40061
39992
|
txCreatedIdx: bn(1)
|
40062
39993
|
}
|
@@ -40088,7 +40019,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40088
40019
|
toJSON() {
|
40089
40020
|
return normalizeJSON(this);
|
40090
40021
|
}
|
40091
|
-
|
40022
|
+
updatePredicateInputs(inputs) {
|
40092
40023
|
this.inputs.forEach((i) => {
|
40093
40024
|
let correspondingInput;
|
40094
40025
|
switch (i.type) {
|
@@ -40110,15 +40041,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40110
40041
|
}
|
40111
40042
|
});
|
40112
40043
|
}
|
40113
|
-
shiftPredicateData() {
|
40114
|
-
this.inputs.forEach((input) => {
|
40115
|
-
if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
|
40116
|
-
input.predicateData = input.paddPredicateData(
|
40117
|
-
BaseTransactionRequest.getPolicyMeta(this).policies.length
|
40118
|
-
);
|
40119
|
-
}
|
40120
|
-
});
|
40121
|
-
}
|
40122
40044
|
};
|
40123
40045
|
|
40124
40046
|
// src/providers/transaction-request/hash-transaction.ts
|
@@ -40252,8 +40174,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40252
40174
|
return {
|
40253
40175
|
type: TransactionType.Create,
|
40254
40176
|
...baseTransaction,
|
40177
|
+
bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
|
40255
40178
|
bytecodeWitnessIndex,
|
40256
|
-
storageSlotsCount:
|
40179
|
+
storageSlotsCount: storageSlots.length,
|
40257
40180
|
salt: this.salt ? hexlify(this.salt) : ZeroBytes32,
|
40258
40181
|
storageSlots
|
40259
40182
|
};
|
@@ -40367,8 +40290,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40367
40290
|
type: TransactionType.Script,
|
40368
40291
|
scriptGasLimit: this.gasLimit,
|
40369
40292
|
...super.getBaseTransaction(),
|
40370
|
-
scriptLength:
|
40371
|
-
scriptDataLength:
|
40293
|
+
scriptLength: script.length,
|
40294
|
+
scriptDataLength: scriptData.length,
|
40372
40295
|
receiptsRoot: ZeroBytes32,
|
40373
40296
|
script: hexlify(script),
|
40374
40297
|
scriptData: hexlify(scriptData)
|
@@ -40432,7 +40355,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40432
40355
|
}
|
40433
40356
|
calculateMaxGas(chainInfo, minGas) {
|
40434
40357
|
const { consensusParameters } = chainInfo;
|
40435
|
-
const { gasPerByte
|
40358
|
+
const { gasPerByte } = consensusParameters;
|
40436
40359
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
40437
40360
|
(acc, wit) => acc + wit.dataLength,
|
40438
40361
|
0
|
@@ -40442,8 +40365,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40442
40365
|
minGas,
|
40443
40366
|
witnessesLength,
|
40444
40367
|
witnessLimit: this.witnessLimit,
|
40445
|
-
gasLimit: this.gasLimit
|
40446
|
-
maxGasPerTx
|
40368
|
+
gasLimit: this.gasLimit
|
40447
40369
|
});
|
40448
40370
|
}
|
40449
40371
|
/**
|
@@ -40516,29 +40438,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40516
40438
|
}
|
40517
40439
|
}
|
40518
40440
|
};
|
40519
|
-
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
40520
|
-
(acc, input) => {
|
40521
|
-
if (input.type === InputType.Coin && input.owner === owner) {
|
40522
|
-
acc.utxos.push(input.id);
|
40523
|
-
}
|
40524
|
-
if (input.type === InputType.Message && input.recipient === owner) {
|
40525
|
-
acc.messages.push(input.nonce);
|
40526
|
-
}
|
40527
|
-
return acc;
|
40528
|
-
},
|
40529
|
-
{
|
40530
|
-
utxos: [],
|
40531
|
-
messages: []
|
40532
|
-
}
|
40533
|
-
);
|
40534
40441
|
|
40535
40442
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
40536
40443
|
var calculateTransactionFee = (params) => {
|
40537
40444
|
const {
|
40538
|
-
|
40445
|
+
gasUsed,
|
40539
40446
|
rawPayload,
|
40540
|
-
|
40541
|
-
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
40447
|
+
consensusParameters: { gasCosts, feeParams }
|
40542
40448
|
} = params;
|
40543
40449
|
const gasPerByte = bn(feeParams.gasPerByte);
|
40544
40450
|
const gasPriceFactor = bn(feeParams.gasPriceFactor);
|
@@ -40548,7 +40454,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40548
40454
|
return {
|
40549
40455
|
fee: bn(0),
|
40550
40456
|
minFee: bn(0),
|
40551
|
-
maxFee: bn(0)
|
40457
|
+
maxFee: bn(0),
|
40458
|
+
feeFromGasUsed: bn(0)
|
40552
40459
|
};
|
40553
40460
|
}
|
40554
40461
|
const { type: type3, witnesses, inputs, policies } = transaction;
|
@@ -40580,6 +40487,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40580
40487
|
metadataGas,
|
40581
40488
|
txBytesSize: transactionBytes.length
|
40582
40489
|
});
|
40490
|
+
const gasPrice = bn(policies.find((policy) => policy.type === PolicyType.GasPrice)?.data);
|
40583
40491
|
const witnessLimit = policies.find((policy) => policy.type === PolicyType.WitnessLimit)?.data;
|
40584
40492
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
40585
40493
|
const maxGas = getMaxGas({
|
@@ -40587,25 +40495,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40587
40495
|
minGas,
|
40588
40496
|
witnessesLength,
|
40589
40497
|
gasLimit,
|
40590
|
-
witnessLimit
|
40591
|
-
maxGasPerTx
|
40592
|
-
});
|
40593
|
-
const minFee = calculateGasFee({
|
40594
|
-
gasPrice,
|
40595
|
-
gas: minGas,
|
40596
|
-
priceFactor: gasPriceFactor,
|
40597
|
-
tip
|
40598
|
-
});
|
40599
|
-
const maxFee = calculateGasFee({
|
40600
|
-
gasPrice,
|
40601
|
-
gas: maxGas,
|
40602
|
-
priceFactor: gasPriceFactor,
|
40603
|
-
tip
|
40498
|
+
witnessLimit
|
40604
40499
|
});
|
40500
|
+
const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
|
40501
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
|
40502
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
|
40503
|
+
const fee = minFee.add(feeFromGasUsed);
|
40605
40504
|
return {
|
40505
|
+
fee,
|
40606
40506
|
minFee,
|
40607
40507
|
maxFee,
|
40608
|
-
|
40508
|
+
feeFromGasUsed
|
40609
40509
|
};
|
40610
40510
|
};
|
40611
40511
|
|
@@ -41206,9 +41106,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41206
41106
|
gqlTransactionStatus,
|
41207
41107
|
abiMap = {},
|
41208
41108
|
maxInputs,
|
41209
|
-
gasCosts
|
41210
|
-
maxGasPerTx,
|
41211
|
-
gasPrice
|
41109
|
+
gasCosts
|
41212
41110
|
} = params;
|
41213
41111
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
41214
41112
|
const rawPayload = hexlify(transactionBytes);
|
@@ -41222,14 +41120,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41222
41120
|
maxInputs
|
41223
41121
|
});
|
41224
41122
|
const typeName = getTransactionTypeName(transaction.type);
|
41225
|
-
const tip = bn(transaction.policies?.find((policy) => policy.type === PolicyType.Tip)?.data);
|
41226
41123
|
const { fee } = calculateTransactionFee({
|
41227
|
-
|
41124
|
+
gasUsed,
|
41228
41125
|
rawPayload,
|
41229
|
-
tip,
|
41230
41126
|
consensusParameters: {
|
41231
41127
|
gasCosts,
|
41232
|
-
maxGasPerTx,
|
41233
41128
|
feeParams: {
|
41234
41129
|
gasPerByte,
|
41235
41130
|
gasPriceFactor
|
@@ -41365,13 +41260,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41365
41260
|
const decodedTransaction = this.decodeTransaction(
|
41366
41261
|
transaction
|
41367
41262
|
);
|
41368
|
-
|
41369
|
-
|
41370
|
-
txReceipts = transaction.status.receipts;
|
41371
|
-
}
|
41372
|
-
const receipts = txReceipts.map(processGqlReceipt) || [];
|
41373
|
-
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
41374
|
-
const gasPrice = await this.provider.getLatestGasPrice();
|
41263
|
+
const receipts = transaction.receipts?.map(processGqlReceipt) || [];
|
41264
|
+
const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
|
41375
41265
|
const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
|
41376
41266
|
const transactionSummary = assembleTransactionSummary({
|
41377
41267
|
id: this.id,
|
@@ -41383,9 +41273,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41383
41273
|
gasPriceFactor,
|
41384
41274
|
abiMap: contractsAbiMap,
|
41385
41275
|
maxInputs,
|
41386
|
-
gasCosts
|
41387
|
-
maxGasPerTx,
|
41388
|
-
gasPrice
|
41276
|
+
gasCosts
|
41389
41277
|
});
|
41390
41278
|
return transactionSummary;
|
41391
41279
|
}
|
@@ -41534,7 +41422,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41534
41422
|
gasCosts,
|
41535
41423
|
latestBlock: {
|
41536
41424
|
id: latestBlock.id,
|
41537
|
-
height: bn(latestBlock.height),
|
41425
|
+
height: bn(latestBlock.header.height),
|
41538
41426
|
time: latestBlock.header.time,
|
41539
41427
|
transactions: latestBlock.transactions.map((i) => ({
|
41540
41428
|
id: i.id
|
@@ -41628,8 +41516,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41628
41516
|
* Returns some helpful parameters related to gas fees.
|
41629
41517
|
*/
|
41630
41518
|
getGasConfig() {
|
41519
|
+
const { minGasPrice } = this.getNode();
|
41631
41520
|
const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
|
41632
41521
|
return {
|
41522
|
+
minGasPrice,
|
41633
41523
|
maxGasPerTx,
|
41634
41524
|
maxGasPerPredicate,
|
41635
41525
|
gasPriceFactor,
|
@@ -41727,7 +41617,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41727
41617
|
*/
|
41728
41618
|
async getBlockNumber() {
|
41729
41619
|
const { chain } = await this.operations.getChain();
|
41730
|
-
return bn(chain.latestBlock.height, 10);
|
41620
|
+
return bn(chain.latestBlock.header.height, 10);
|
41731
41621
|
}
|
41732
41622
|
/**
|
41733
41623
|
* Returns the chain information.
|
@@ -41739,9 +41629,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41739
41629
|
const processedNodeInfo = {
|
41740
41630
|
maxDepth: bn(nodeInfo.maxDepth),
|
41741
41631
|
maxTx: bn(nodeInfo.maxTx),
|
41632
|
+
minGasPrice: bn(nodeInfo.minGasPrice),
|
41742
41633
|
nodeVersion: nodeInfo.nodeVersion,
|
41743
41634
|
utxoValidation: nodeInfo.utxoValidation,
|
41744
|
-
vmBacktrace: nodeInfo.vmBacktrace
|
41635
|
+
vmBacktrace: nodeInfo.vmBacktrace,
|
41636
|
+
peers: nodeInfo.peers
|
41745
41637
|
};
|
41746
41638
|
_Provider.nodeInfoCache[this.url] = processedNodeInfo;
|
41747
41639
|
return processedNodeInfo;
|
@@ -41827,13 +41719,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41827
41719
|
return this.estimateTxDependencies(transactionRequest);
|
41828
41720
|
}
|
41829
41721
|
const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
|
41830
|
-
const { dryRun:
|
41831
|
-
|
41722
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
41723
|
+
encodedTransaction,
|
41832
41724
|
utxoValidation: utxoValidation || false
|
41833
41725
|
});
|
41834
|
-
const
|
41835
|
-
|
41836
|
-
|
41726
|
+
const receipts = gqlReceipts.map(processGqlReceipt);
|
41727
|
+
return {
|
41728
|
+
receipts
|
41729
|
+
};
|
41837
41730
|
}
|
41838
41731
|
/**
|
41839
41732
|
* Verifies whether enough gas is available to complete transaction.
|
@@ -41872,6 +41765,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41872
41765
|
* If there are missing variable outputs,
|
41873
41766
|
* `addVariableOutputs` is called on the transaction.
|
41874
41767
|
*
|
41768
|
+
* @privateRemarks
|
41769
|
+
* TODO: Investigate support for missing contract IDs
|
41770
|
+
* TODO: Add support for missing output messages
|
41875
41771
|
*
|
41876
41772
|
* @param transactionRequest - The transaction request object.
|
41877
41773
|
* @returns A promise.
|
@@ -41884,19 +41780,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41884
41780
|
missingContractIds: []
|
41885
41781
|
};
|
41886
41782
|
}
|
41783
|
+
await this.estimatePredicates(transactionRequest);
|
41887
41784
|
let receipts = [];
|
41888
41785
|
const missingContractIds = [];
|
41889
41786
|
let outputVariables = 0;
|
41890
|
-
let dryrunStatus;
|
41891
41787
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
41892
|
-
const {
|
41893
|
-
|
41894
|
-
} = await this.operations.dryRun({
|
41895
|
-
encodedTransactions: [hexlify(transactionRequest.toTransactionBytes())],
|
41788
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
41789
|
+
encodedTransaction: hexlify(transactionRequest.toTransactionBytes()),
|
41896
41790
|
utxoValidation: false
|
41897
41791
|
});
|
41898
|
-
receipts =
|
41899
|
-
dryrunStatus = status;
|
41792
|
+
receipts = gqlReceipts.map(processGqlReceipt);
|
41900
41793
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
41901
41794
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
41902
41795
|
if (hasMissingOutputs) {
|
@@ -41906,11 +41799,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41906
41799
|
transactionRequest.addContractInputAndOutput(Address.fromString(contractId));
|
41907
41800
|
missingContractIds.push(contractId);
|
41908
41801
|
});
|
41909
|
-
const { maxFee } = await this.estimateTxGasAndFee({
|
41910
|
-
transactionRequest,
|
41911
|
-
optimizeGas: false
|
41912
|
-
});
|
41913
|
-
transactionRequest.maxFee = maxFee;
|
41914
41802
|
} else {
|
41915
41803
|
break;
|
41916
41804
|
}
|
@@ -41918,133 +41806,38 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41918
41806
|
return {
|
41919
41807
|
receipts,
|
41920
41808
|
outputVariables,
|
41921
|
-
missingContractIds
|
41922
|
-
dryrunStatus
|
41809
|
+
missingContractIds
|
41923
41810
|
};
|
41924
41811
|
}
|
41925
41812
|
/**
|
41926
|
-
*
|
41927
|
-
*
|
41928
|
-
*
|
41929
|
-
*
|
41930
|
-
|
41931
|
-
|
41932
|
-
|
41933
|
-
|
41934
|
-
*/
|
41935
|
-
async estimateMultipleTxDependencies(transactionRequests) {
|
41936
|
-
const results = transactionRequests.map(() => ({
|
41937
|
-
receipts: [],
|
41938
|
-
outputVariables: 0,
|
41939
|
-
missingContractIds: [],
|
41940
|
-
dryrunStatus: void 0
|
41941
|
-
}));
|
41942
|
-
const allRequests = clone_default(transactionRequests);
|
41943
|
-
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
41944
|
-
allRequests.forEach((req, index) => {
|
41945
|
-
if (req.type === TransactionType.Script) {
|
41946
|
-
serializedTransactionsMap.set(index, hexlify(req.toTransactionBytes()));
|
41947
|
-
}
|
41948
|
-
});
|
41949
|
-
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
41950
|
-
let attempt = 0;
|
41951
|
-
while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
|
41952
|
-
const encodedTransactions = transactionsToProcess.map(
|
41953
|
-
(index) => serializedTransactionsMap.get(index)
|
41954
|
-
);
|
41955
|
-
const dryRunResults = await this.operations.dryRun({
|
41956
|
-
encodedTransactions,
|
41957
|
-
utxoValidation: false
|
41958
|
-
});
|
41959
|
-
const nextRoundTransactions = [];
|
41960
|
-
for (let i = 0; i < dryRunResults.dryRun.length; i++) {
|
41961
|
-
const currentResultIndex = transactionsToProcess[i];
|
41962
|
-
const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
|
41963
|
-
results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
|
41964
|
-
results[currentResultIndex].dryrunStatus = status;
|
41965
|
-
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
|
41966
|
-
results[currentResultIndex].receipts
|
41967
|
-
);
|
41968
|
-
const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
|
41969
|
-
const requestToProcess = allRequests[currentResultIndex];
|
41970
|
-
if (hasMissingOutputs && requestToProcess?.type === TransactionType.Script) {
|
41971
|
-
results[currentResultIndex].outputVariables += missingOutputVariables.length;
|
41972
|
-
requestToProcess.addVariableOutputs(missingOutputVariables.length);
|
41973
|
-
missingOutputContractIds.forEach(({ contractId }) => {
|
41974
|
-
requestToProcess.addContractInputAndOutput(Address.fromString(contractId));
|
41975
|
-
results[currentResultIndex].missingContractIds.push(contractId);
|
41976
|
-
});
|
41977
|
-
const { maxFee } = await this.estimateTxGasAndFee({
|
41978
|
-
transactionRequest: requestToProcess,
|
41979
|
-
optimizeGas: false
|
41980
|
-
});
|
41981
|
-
requestToProcess.maxFee = maxFee;
|
41982
|
-
serializedTransactionsMap.set(
|
41983
|
-
currentResultIndex,
|
41984
|
-
hexlify(requestToProcess.toTransactionBytes())
|
41985
|
-
);
|
41986
|
-
nextRoundTransactions.push(currentResultIndex);
|
41987
|
-
allRequests[currentResultIndex] = requestToProcess;
|
41988
|
-
}
|
41989
|
-
}
|
41990
|
-
transactionsToProcess = nextRoundTransactions;
|
41991
|
-
attempt += 1;
|
41992
|
-
}
|
41993
|
-
return results;
|
41994
|
-
}
|
41995
|
-
async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
|
41996
|
-
if (estimateTxDependencies) {
|
41997
|
-
return this.estimateMultipleTxDependencies(transactionRequests);
|
41998
|
-
}
|
41999
|
-
const encodedTransactions = transactionRequests.map((tx) => hexlify(tx.toTransactionBytes()));
|
42000
|
-
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
42001
|
-
encodedTransactions,
|
42002
|
-
utxoValidation: utxoValidation || false
|
42003
|
-
});
|
42004
|
-
const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
|
42005
|
-
const receipts = rawReceipts.map(processGqlReceipt);
|
42006
|
-
return { receipts, dryrunStatus: status };
|
42007
|
-
});
|
42008
|
-
return results;
|
42009
|
-
}
|
42010
|
-
async estimateTxGasAndFee(params) {
|
42011
|
-
const { transactionRequest, optimizeGas = true } = params;
|
42012
|
-
let { gasPrice } = params;
|
41813
|
+
* Estimates the transaction gas and fee based on the provided transaction request.
|
41814
|
+
* @param transactionRequest - The transaction request object.
|
41815
|
+
* @param optimizeGas - Optional. Specifies whether to optimize the gas. Default is false.
|
41816
|
+
* @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
|
41817
|
+
*/
|
41818
|
+
estimateTxGasAndFee(params) {
|
41819
|
+
const { transactionRequest } = params;
|
41820
|
+
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
42013
41821
|
const chainInfo = this.getChain();
|
42014
|
-
const
|
41822
|
+
const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
|
41823
|
+
transactionRequest.gasPrice = gasPrice;
|
42015
41824
|
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
42016
|
-
|
42017
|
-
gasPrice = await this.estimateGasPrice(10);
|
42018
|
-
}
|
42019
|
-
const minFee = calculateGasFee({
|
42020
|
-
gasPrice: bn(gasPrice),
|
42021
|
-
gas: minGas,
|
42022
|
-
priceFactor: gasPriceFactor,
|
42023
|
-
tip: transactionRequest.tip
|
42024
|
-
}).add(1);
|
42025
|
-
let gasLimit = bn(0);
|
41825
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
42026
41826
|
if (transactionRequest.type === TransactionType.Script) {
|
42027
|
-
|
42028
|
-
if (!optimizeGas) {
|
41827
|
+
if (transactionRequest.gasLimit.eq(0)) {
|
42029
41828
|
transactionRequest.gasLimit = minGas;
|
42030
|
-
gasLimit =
|
42031
|
-
|
41829
|
+
transactionRequest.gasLimit = maxGasPerTx.sub(
|
41830
|
+
transactionRequest.calculateMaxGas(chainInfo, minGas)
|
41831
|
+
);
|
42032
41832
|
}
|
42033
41833
|
}
|
42034
41834
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
42035
|
-
const maxFee =
|
42036
|
-
gasPrice: bn(gasPrice),
|
42037
|
-
gas: maxGas,
|
42038
|
-
priceFactor: gasPriceFactor,
|
42039
|
-
tip: transactionRequest.tip
|
42040
|
-
}).add(1);
|
41835
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
42041
41836
|
return {
|
42042
41837
|
minGas,
|
42043
41838
|
minFee,
|
42044
41839
|
maxGas,
|
42045
|
-
maxFee
|
42046
|
-
gasPrice,
|
42047
|
-
gasLimit
|
41840
|
+
maxFee
|
42048
41841
|
};
|
42049
41842
|
}
|
42050
41843
|
/**
|
@@ -42062,17 +41855,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42062
41855
|
if (estimateTxDependencies) {
|
42063
41856
|
return this.estimateTxDependencies(transactionRequest);
|
42064
41857
|
}
|
42065
|
-
const
|
42066
|
-
const { dryRun:
|
42067
|
-
|
41858
|
+
const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
|
41859
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
41860
|
+
encodedTransaction,
|
42068
41861
|
utxoValidation: true
|
42069
41862
|
});
|
42070
|
-
const
|
42071
|
-
|
42072
|
-
|
42073
|
-
|
42074
|
-
});
|
42075
|
-
return { receipts: callResult[0].receipts };
|
41863
|
+
const receipts = gqlReceipts.map(processGqlReceipt);
|
41864
|
+
return {
|
41865
|
+
receipts
|
41866
|
+
};
|
42076
41867
|
}
|
42077
41868
|
/**
|
42078
41869
|
* Returns a transaction cost to enable user
|
@@ -42089,80 +41880,77 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42089
41880
|
* @param tolerance - The tolerance to add on top of the gasUsed.
|
42090
41881
|
* @returns A promise that resolves to the transaction cost object.
|
42091
41882
|
*/
|
42092
|
-
async getTransactionCost(transactionRequestLike,
|
41883
|
+
async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
|
41884
|
+
estimateTxDependencies = true,
|
41885
|
+
estimatePredicates = true,
|
41886
|
+
resourcesOwner,
|
41887
|
+
signatureCallback
|
41888
|
+
} = {}) {
|
42093
41889
|
const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
|
41890
|
+
const { minGasPrice } = this.getGasConfig();
|
41891
|
+
const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
42094
41892
|
const isScriptTransaction = txRequestClone.type === TransactionType.Script;
|
42095
41893
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
42096
|
-
const allQuantities = mergeQuantities(coinOutputsQuantities,
|
41894
|
+
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
42097
41895
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
42098
|
-
txRequestClone.maxFee = bn(0);
|
42099
41896
|
if (isScriptTransaction) {
|
42100
41897
|
txRequestClone.gasLimit = bn(0);
|
42101
41898
|
}
|
42102
|
-
if (
|
42103
|
-
resourcesOwner
|
41899
|
+
if (estimatePredicates) {
|
41900
|
+
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
41901
|
+
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
41902
|
+
}
|
41903
|
+
await this.estimatePredicates(txRequestClone);
|
42104
41904
|
}
|
42105
|
-
const signedRequest = clone_default(txRequestClone);
|
42106
|
-
let addedSignatures = 0;
|
42107
41905
|
if (signatureCallback && isScriptTransaction) {
|
42108
|
-
|
42109
|
-
|
42110
|
-
|
42111
|
-
|
42112
|
-
await this.estimatePredicates(signedRequest);
|
42113
|
-
let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
|
42114
|
-
transactionRequest: signedRequest,
|
42115
|
-
optimizeGas: false
|
41906
|
+
await signatureCallback(txRequestClone);
|
41907
|
+
}
|
41908
|
+
let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
41909
|
+
transactionRequest: txRequestClone
|
42116
41910
|
});
|
42117
|
-
txRequestClone.maxFee = maxFee;
|
42118
41911
|
let receipts = [];
|
42119
41912
|
let missingContractIds = [];
|
42120
41913
|
let outputVariables = 0;
|
42121
41914
|
let gasUsed = bn(0);
|
42122
|
-
|
42123
|
-
|
42124
|
-
if (signatureCallback) {
|
42125
|
-
await signatureCallback(txRequestClone);
|
42126
|
-
}
|
42127
|
-
txRequestClone.gasLimit = gasLimit;
|
41915
|
+
if (isScriptTransaction && estimateTxDependencies) {
|
41916
|
+
txRequestClone.gasPrice = bn(0);
|
42128
41917
|
const result = await this.estimateTxDependencies(txRequestClone);
|
42129
41918
|
receipts = result.receipts;
|
42130
41919
|
outputVariables = result.outputVariables;
|
42131
41920
|
missingContractIds = result.missingContractIds;
|
42132
|
-
gasUsed = getGasUsedFromReceipts(receipts);
|
41921
|
+
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
42133
41922
|
txRequestClone.gasLimit = gasUsed;
|
42134
|
-
|
42135
|
-
|
42136
|
-
|
41923
|
+
txRequestClone.gasPrice = setGasPrice;
|
41924
|
+
({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
41925
|
+
transactionRequest: txRequestClone
|
42137
41926
|
}));
|
42138
41927
|
}
|
42139
41928
|
return {
|
42140
41929
|
requiredQuantities: allQuantities,
|
42141
41930
|
receipts,
|
42142
41931
|
gasUsed,
|
42143
|
-
|
41932
|
+
minGasPrice,
|
41933
|
+
gasPrice: setGasPrice,
|
42144
41934
|
minGas,
|
42145
41935
|
maxGas,
|
42146
41936
|
minFee,
|
42147
41937
|
maxFee,
|
41938
|
+
estimatedInputs: txRequestClone.inputs,
|
42148
41939
|
outputVariables,
|
42149
|
-
missingContractIds
|
42150
|
-
addedSignatures,
|
42151
|
-
estimatedPredicates: txRequestClone.inputs
|
41940
|
+
missingContractIds
|
42152
41941
|
};
|
42153
41942
|
}
|
42154
|
-
async getResourcesForTransaction(owner, transactionRequestLike,
|
41943
|
+
async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
|
42155
41944
|
const ownerAddress = Address.fromAddressOrString(owner);
|
42156
41945
|
const transactionRequest = transactionRequestify(clone_default(transactionRequestLike));
|
42157
|
-
const transactionCost = await this.getTransactionCost(transactionRequest,
|
42158
|
-
quantitiesToContract
|
42159
|
-
});
|
41946
|
+
const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
|
42160
41947
|
transactionRequest.addResources(
|
42161
41948
|
await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
|
42162
41949
|
);
|
42163
|
-
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
42164
|
-
|
42165
|
-
|
41950
|
+
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
41951
|
+
transactionRequest,
|
41952
|
+
forwardingQuantities
|
41953
|
+
);
|
42166
41954
|
const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
|
42167
41955
|
return {
|
42168
41956
|
resources,
|
@@ -42186,6 +41974,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42186
41974
|
assetId: coin.assetId,
|
42187
41975
|
amount: bn(coin.amount),
|
42188
41976
|
owner: Address.fromAddressOrString(coin.owner),
|
41977
|
+
maturity: bn(coin.maturity).toNumber(),
|
42189
41978
|
blockCreated: bn(coin.blockCreated),
|
42190
41979
|
txCreatedIdx: bn(coin.txCreatedIdx)
|
42191
41980
|
}));
|
@@ -42237,6 +42026,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42237
42026
|
amount: bn(coin.amount),
|
42238
42027
|
assetId: coin.assetId,
|
42239
42028
|
owner: Address.fromAddressOrString(coin.owner),
|
42029
|
+
maturity: bn(coin.maturity).toNumber(),
|
42240
42030
|
blockCreated: bn(coin.blockCreated),
|
42241
42031
|
txCreatedIdx: bn(coin.txCreatedIdx)
|
42242
42032
|
};
|
@@ -42269,7 +42059,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42269
42059
|
}
|
42270
42060
|
return {
|
42271
42061
|
id: block2.id,
|
42272
|
-
height: bn(block2.height),
|
42062
|
+
height: bn(block2.header.height),
|
42273
42063
|
time: block2.header.time,
|
42274
42064
|
transactionIds: block2.transactions.map((tx) => tx.id)
|
42275
42065
|
};
|
@@ -42284,7 +42074,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42284
42074
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
42285
42075
|
const blocks = fetchedData.edges.map(({ node: block2 }) => ({
|
42286
42076
|
id: block2.id,
|
42287
|
-
height: bn(block2.height),
|
42077
|
+
height: bn(block2.header.height),
|
42288
42078
|
time: block2.header.time,
|
42289
42079
|
transactionIds: block2.transactions.map((tx) => tx.id)
|
42290
42080
|
}));
|
@@ -42311,7 +42101,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42311
42101
|
}
|
42312
42102
|
return {
|
42313
42103
|
id: block2.id,
|
42314
|
-
height: bn(block2.height, 10),
|
42104
|
+
height: bn(block2.header.height, 10),
|
42315
42105
|
time: block2.header.time,
|
42316
42106
|
transactionIds: block2.transactions.map((tx) => tx.id),
|
42317
42107
|
transactions: block2.transactions.map(
|
@@ -42491,6 +42281,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42491
42281
|
prevRoot: messageBlockHeader.prevRoot,
|
42492
42282
|
time: messageBlockHeader.time,
|
42493
42283
|
applicationHash: messageBlockHeader.applicationHash,
|
42284
|
+
messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
|
42494
42285
|
messageReceiptCount: bn(messageBlockHeader.messageReceiptCount)
|
42495
42286
|
},
|
42496
42287
|
commitBlockHeader: {
|
@@ -42502,6 +42293,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42502
42293
|
prevRoot: commitBlockHeader.prevRoot,
|
42503
42294
|
time: commitBlockHeader.time,
|
42504
42295
|
applicationHash: commitBlockHeader.applicationHash,
|
42296
|
+
messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
|
42505
42297
|
messageReceiptCount: bn(commitBlockHeader.messageReceiptCount)
|
42506
42298
|
},
|
42507
42299
|
sender: Address.fromAddressOrString(sender),
|
@@ -42511,16 +42303,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42511
42303
|
data
|
42512
42304
|
};
|
42513
42305
|
}
|
42514
|
-
async getLatestGasPrice() {
|
42515
|
-
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
42516
|
-
return bn(latestGasPrice.gasPrice);
|
42517
|
-
}
|
42518
|
-
async estimateGasPrice(blockHorizon) {
|
42519
|
-
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
42520
|
-
blockHorizon: String(blockHorizon)
|
42521
|
-
});
|
42522
|
-
return bn(estimateGasPrice.gasPrice);
|
42523
|
-
}
|
42524
42306
|
/**
|
42525
42307
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
42526
42308
|
*
|
@@ -42581,15 +42363,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42581
42363
|
arrayify(gqlTransaction.rawPayload),
|
42582
42364
|
0
|
42583
42365
|
);
|
42584
|
-
|
42585
|
-
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
42586
|
-
txReceipts = gqlTransaction.status.receipts;
|
42587
|
-
}
|
42588
|
-
const receipts = txReceipts.map(processGqlReceipt);
|
42366
|
+
const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
|
42589
42367
|
const {
|
42590
|
-
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts
|
42368
|
+
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
|
42591
42369
|
} = provider.getChain();
|
42592
|
-
const gasPrice = await provider.getLatestGasPrice();
|
42593
42370
|
const transactionInfo = assembleTransactionSummary({
|
42594
42371
|
id: gqlTransaction.id,
|
42595
42372
|
receipts,
|
@@ -42600,9 +42377,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42600
42377
|
gasPriceFactor: bn(gasPriceFactor),
|
42601
42378
|
abiMap,
|
42602
42379
|
maxInputs,
|
42603
|
-
gasCosts
|
42604
|
-
maxGasPerTx,
|
42605
|
-
gasPrice
|
42380
|
+
gasCosts
|
42606
42381
|
});
|
42607
42382
|
return {
|
42608
42383
|
gqlTransaction,
|
@@ -42612,11 +42387,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42612
42387
|
async function getTransactionSummaryFromRequest(params) {
|
42613
42388
|
const { provider, transactionRequest, abiMap } = params;
|
42614
42389
|
const { receipts } = await provider.call(transactionRequest);
|
42615
|
-
const { gasPerByte, gasPriceFactor, gasCosts
|
42390
|
+
const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
|
42616
42391
|
const maxInputs = provider.getChain().consensusParameters.maxInputs;
|
42617
42392
|
const transaction = transactionRequest.toTransaction();
|
42618
42393
|
const transactionBytes = transactionRequest.toTransactionBytes();
|
42619
|
-
const gasPrice = await provider.getLatestGasPrice();
|
42620
42394
|
const transactionSummary = assembleTransactionSummary({
|
42621
42395
|
receipts,
|
42622
42396
|
transaction,
|
@@ -42625,9 +42399,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42625
42399
|
gasPerByte,
|
42626
42400
|
gasPriceFactor,
|
42627
42401
|
maxInputs,
|
42628
|
-
gasCosts
|
42629
|
-
maxGasPerTx,
|
42630
|
-
gasPrice
|
42402
|
+
gasCosts
|
42631
42403
|
});
|
42632
42404
|
return transactionSummary;
|
42633
42405
|
}
|
@@ -42636,18 +42408,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42636
42408
|
const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
|
42637
42409
|
const { edges, pageInfo } = transactionsByOwner;
|
42638
42410
|
const {
|
42639
|
-
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts
|
42411
|
+
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
|
42640
42412
|
} = provider.getChain();
|
42641
|
-
const gasPrice = await provider.getLatestGasPrice();
|
42642
42413
|
const transactions = edges.map((edge) => {
|
42643
42414
|
const { node: gqlTransaction } = edge;
|
42644
|
-
const { id, rawPayload, status } = gqlTransaction;
|
42415
|
+
const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
|
42645
42416
|
const [decodedTransaction] = new TransactionCoder().decode(arrayify(rawPayload), 0);
|
42646
|
-
|
42647
|
-
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
42648
|
-
txReceipts = gqlTransaction.status.receipts;
|
42649
|
-
}
|
42650
|
-
const receipts = txReceipts.map(processGqlReceipt);
|
42417
|
+
const receipts = gqlReceipts?.map(processGqlReceipt) || [];
|
42651
42418
|
const transactionSummary = assembleTransactionSummary({
|
42652
42419
|
id,
|
42653
42420
|
receipts,
|
@@ -42658,9 +42425,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42658
42425
|
gasPerByte,
|
42659
42426
|
gasPriceFactor,
|
42660
42427
|
maxInputs,
|
42661
|
-
gasCosts
|
42662
|
-
maxGasPerTx,
|
42663
|
-
gasPrice
|
42428
|
+
gasCosts
|
42664
42429
|
});
|
42665
42430
|
const output3 = {
|
42666
42431
|
gqlTransaction,
|
@@ -42989,33 +42754,36 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42989
42754
|
* @param fee - The estimated transaction fee.
|
42990
42755
|
* @returns A promise that resolves when the resources are added to the transaction.
|
42991
42756
|
*/
|
42992
|
-
async fund(request,
|
42993
|
-
const
|
42994
|
-
const txRequest = request;
|
42995
|
-
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
42757
|
+
async fund(request, coinQuantities, fee) {
|
42758
|
+
const updatedQuantities = addAmountToAsset({
|
42996
42759
|
amount: bn(fee),
|
42997
42760
|
assetId: BaseAssetId,
|
42998
|
-
coinQuantities
|
42761
|
+
coinQuantities
|
42999
42762
|
});
|
43000
42763
|
const quantitiesDict = {};
|
43001
|
-
|
42764
|
+
updatedQuantities.forEach(({ amount, assetId }) => {
|
43002
42765
|
quantitiesDict[assetId] = {
|
43003
42766
|
required: amount,
|
43004
42767
|
owned: bn(0)
|
43005
42768
|
};
|
43006
42769
|
});
|
43007
|
-
|
42770
|
+
const cachedUtxos = [];
|
42771
|
+
const cachedMessages = [];
|
42772
|
+
const owner = this.address.toB256();
|
42773
|
+
request.inputs.forEach((input) => {
|
43008
42774
|
const isResource = "amount" in input;
|
43009
42775
|
if (isResource) {
|
43010
42776
|
const isCoin2 = "owner" in input;
|
43011
42777
|
if (isCoin2) {
|
43012
42778
|
const assetId = String(input.assetId);
|
43013
|
-
if (quantitiesDict[assetId]) {
|
42779
|
+
if (input.owner === owner && quantitiesDict[assetId]) {
|
43014
42780
|
const amount = bn(input.amount);
|
43015
42781
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
42782
|
+
cachedUtxos.push(input.id);
|
43016
42783
|
}
|
43017
|
-
} else if (input.amount && quantitiesDict[BaseAssetId]) {
|
42784
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId]) {
|
43018
42785
|
quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
|
42786
|
+
cachedMessages.push(input.nonce);
|
43019
42787
|
}
|
43020
42788
|
}
|
43021
42789
|
});
|
@@ -43030,23 +42798,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43030
42798
|
});
|
43031
42799
|
const needsToBeFunded = missingQuantities.length;
|
43032
42800
|
if (needsToBeFunded) {
|
43033
|
-
const
|
43034
|
-
|
43035
|
-
|
43036
|
-
|
43037
|
-
|
43038
|
-
txRequest.updatePredicateGasUsed(estimatedPredicates);
|
43039
|
-
const requestToBeReEstimate = clone_default(txRequest);
|
43040
|
-
if (addedSignatures) {
|
43041
|
-
Array.from({ length: addedSignatures }).forEach(
|
43042
|
-
() => requestToBeReEstimate.addEmptyWitness()
|
43043
|
-
);
|
42801
|
+
const resources = await this.getResourcesToSpend(missingQuantities, {
|
42802
|
+
messages: cachedMessages,
|
42803
|
+
utxos: cachedUtxos
|
42804
|
+
});
|
42805
|
+
request.addResources(resources);
|
43044
42806
|
}
|
43045
|
-
const { maxFee } = await this.provider.estimateTxGasAndFee({
|
43046
|
-
transactionRequest: requestToBeReEstimate
|
43047
|
-
});
|
43048
|
-
txRequest.maxFee = maxFee;
|
43049
|
-
return txRequest;
|
43050
42807
|
}
|
43051
42808
|
/**
|
43052
42809
|
* A helper that creates a transfer transaction request and returns it.
|
@@ -43054,25 +42811,28 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43054
42811
|
* @param destination - The address of the destination.
|
43055
42812
|
* @param amount - The amount of coins to transfer.
|
43056
42813
|
* @param assetId - The asset ID of the coins to transfer.
|
43057
|
-
* @param txParams - The transaction parameters (gasLimit,
|
42814
|
+
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
43058
42815
|
* @returns A promise that resolves to the prepared transaction request.
|
43059
42816
|
*/
|
43060
42817
|
async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
43061
|
-
const
|
42818
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
42819
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
42820
|
+
const request = new ScriptTransactionRequest(params);
|
43062
42821
|
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
|
43063
|
-
const
|
42822
|
+
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
43064
42823
|
estimateTxDependencies: true,
|
43065
42824
|
resourcesOwner: this
|
43066
42825
|
});
|
43067
|
-
|
43068
|
-
|
43069
|
-
|
43070
|
-
|
43071
|
-
|
43072
|
-
|
43073
|
-
|
43074
|
-
|
43075
|
-
await this.fund(request,
|
42826
|
+
request.gasPrice = bn(txParams.gasPrice ?? minGasPrice);
|
42827
|
+
request.gasLimit = bn(txParams.gasLimit ?? gasUsed);
|
42828
|
+
this.validateGas({
|
42829
|
+
gasUsed,
|
42830
|
+
gasPrice: request.gasPrice,
|
42831
|
+
gasLimit: request.gasLimit,
|
42832
|
+
minGasPrice
|
42833
|
+
});
|
42834
|
+
await this.fund(request, requiredQuantities, maxFee);
|
42835
|
+
request.updatePredicateInputs(estimatedInputs);
|
43076
42836
|
return request;
|
43077
42837
|
}
|
43078
42838
|
/**
|
@@ -43111,30 +42871,31 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43111
42871
|
);
|
43112
42872
|
}
|
43113
42873
|
const contractAddress = Address.fromAddressOrString(contractId);
|
42874
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
42875
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
43114
42876
|
const { script, scriptData } = await assembleTransferToContractScript({
|
43115
42877
|
hexlifiedContractId: contractAddress.toB256(),
|
43116
42878
|
amountToTransfer: bn(amount),
|
43117
42879
|
assetId
|
43118
42880
|
});
|
43119
42881
|
const request = new ScriptTransactionRequest({
|
43120
|
-
...
|
42882
|
+
...params,
|
43121
42883
|
script,
|
43122
42884
|
scriptData
|
43123
42885
|
});
|
43124
42886
|
request.addContractInputAndOutput(contractAddress);
|
43125
|
-
const
|
43126
|
-
|
43127
|
-
|
42887
|
+
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
42888
|
+
request,
|
42889
|
+
[{ amount: bn(amount), assetId: String(assetId) }]
|
42890
|
+
);
|
42891
|
+
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
42892
|
+
this.validateGas({
|
42893
|
+
gasUsed,
|
42894
|
+
gasPrice: request.gasPrice,
|
42895
|
+
gasLimit: request.gasLimit,
|
42896
|
+
minGasPrice
|
43128
42897
|
});
|
43129
|
-
|
43130
|
-
this.validateGas({
|
43131
|
-
gasUsed: txCost.gasUsed,
|
43132
|
-
gasLimit: request.gasLimit
|
43133
|
-
});
|
43134
|
-
}
|
43135
|
-
request.gasLimit = txCost.gasUsed;
|
43136
|
-
request.maxFee = txCost.maxFee;
|
43137
|
-
await this.fund(request, txCost);
|
42898
|
+
await this.fund(request, requiredQuantities, maxFee);
|
43138
42899
|
return this.sendTransaction(request);
|
43139
42900
|
}
|
43140
42901
|
/**
|
@@ -43146,6 +42907,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43146
42907
|
* @returns A promise that resolves to the transaction response.
|
43147
42908
|
*/
|
43148
42909
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
42910
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
43149
42911
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
43150
42912
|
const recipientDataArray = arrayify(
|
43151
42913
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -43158,19 +42920,21 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43158
42920
|
...recipientDataArray,
|
43159
42921
|
...amountDataArray
|
43160
42922
|
]);
|
43161
|
-
const params = { script, ...txParams };
|
42923
|
+
const params = { script, gasPrice: minGasPrice, ...txParams };
|
43162
42924
|
const request = new ScriptTransactionRequest(params);
|
43163
|
-
const
|
43164
|
-
const
|
43165
|
-
|
43166
|
-
|
43167
|
-
|
43168
|
-
|
43169
|
-
|
43170
|
-
|
43171
|
-
|
43172
|
-
|
43173
|
-
|
42925
|
+
const forwardingQuantities = [{ amount: bn(amount), assetId: BaseAssetId }];
|
42926
|
+
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
42927
|
+
request,
|
42928
|
+
forwardingQuantities
|
42929
|
+
);
|
42930
|
+
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
42931
|
+
this.validateGas({
|
42932
|
+
gasUsed,
|
42933
|
+
gasPrice: request.gasPrice,
|
42934
|
+
gasLimit: request.gasLimit,
|
42935
|
+
minGasPrice
|
42936
|
+
});
|
42937
|
+
await this.fund(request, requiredQuantities, maxFee);
|
43174
42938
|
return this.sendTransaction(request);
|
43175
42939
|
}
|
43176
42940
|
async signMessage(message) {
|
@@ -43228,7 +42992,18 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43228
42992
|
}
|
43229
42993
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
43230
42994
|
}
|
43231
|
-
validateGas({
|
42995
|
+
validateGas({
|
42996
|
+
gasUsed,
|
42997
|
+
gasPrice,
|
42998
|
+
gasLimit,
|
42999
|
+
minGasPrice
|
43000
|
+
}) {
|
43001
|
+
if (minGasPrice.gt(gasPrice)) {
|
43002
|
+
throw new FuelError(
|
43003
|
+
ErrorCode.GAS_PRICE_TOO_LOW,
|
43004
|
+
`Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
|
43005
|
+
);
|
43006
|
+
}
|
43232
43007
|
if (gasUsed.gt(gasLimit)) {
|
43233
43008
|
throw new FuelError(
|
43234
43009
|
ErrorCode.GAS_LIMIT_TOO_LOW,
|
@@ -44817,7 +44592,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44817
44592
|
* @param transactionRequestLike - The transaction request to send.
|
44818
44593
|
* @returns A promise that resolves to the TransactionResponse object.
|
44819
44594
|
*/
|
44820
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies =
|
44595
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
|
44821
44596
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
44822
44597
|
if (estimateTxDependencies) {
|
44823
44598
|
await this.provider.estimateTxDependencies(transactionRequest);
|
@@ -48083,7 +47858,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
48083
47858
|
this.interface = predicateInterface;
|
48084
47859
|
if (inputData !== void 0 && inputData.length > 0) {
|
48085
47860
|
this.predicateData = inputData;
|
48086
|
-
this.predicateDataBytes = this.getPredicateData(0);
|
48087
47861
|
}
|
48088
47862
|
}
|
48089
47863
|
/**
|
@@ -48097,8 +47871,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
48097
47871
|
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
48098
47872
|
request.inputs?.forEach((input) => {
|
48099
47873
|
if (input.type === InputType.Coin && hexlify(input.owner) === this.address.toB256()) {
|
48100
|
-
input.predicate =
|
48101
|
-
input.predicateData =
|
47874
|
+
input.predicate = this.bytes;
|
47875
|
+
input.predicateData = this.getPredicateData(policies.length);
|
48102
47876
|
}
|
48103
47877
|
});
|
48104
47878
|
return request;
|
@@ -48113,7 +47887,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
48113
47887
|
* @returns A promise that resolves to the prepared transaction request.
|
48114
47888
|
*/
|
48115
47889
|
async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
48116
|
-
|
47890
|
+
const request = await super.createTransfer(destination, amount, assetId, txParams);
|
47891
|
+
return this.populateTransactionPredicateData(request);
|
48117
47892
|
}
|
48118
47893
|
/**
|
48119
47894
|
* Sends a transaction with the populated predicate data.
|
@@ -48121,9 +47896,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
48121
47896
|
* @param transactionRequestLike - The transaction request-like object.
|
48122
47897
|
* @returns A promise that resolves to the transaction response.
|
48123
47898
|
*/
|
48124
|
-
sendTransaction(transactionRequestLike) {
|
48125
|
-
const transactionRequest =
|
48126
|
-
return super.sendTransaction(transactionRequest,
|
47899
|
+
sendTransaction(transactionRequestLike, options) {
|
47900
|
+
const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
|
47901
|
+
return super.sendTransaction(transactionRequest, options);
|
48127
47902
|
}
|
48128
47903
|
/**
|
48129
47904
|
* Simulates a transaction with the populated predicate data.
|
@@ -48132,8 +47907,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
48132
47907
|
* @returns A promise that resolves to the call result.
|
48133
47908
|
*/
|
48134
47909
|
simulateTransaction(transactionRequestLike) {
|
48135
|
-
const transactionRequest =
|
48136
|
-
return super.simulateTransaction(transactionRequest
|
47910
|
+
const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
|
47911
|
+
return super.simulateTransaction(transactionRequest);
|
48137
47912
|
}
|
48138
47913
|
getPredicateData(policiesLength) {
|
48139
47914
|
if (!this.predicateData.length) {
|
@@ -48179,26 +47954,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
48179
47954
|
predicateInterface: abiInterface
|
48180
47955
|
};
|
48181
47956
|
}
|
48182
|
-
/**
|
48183
|
-
* Retrieves resources satisfying the spend query for the account.
|
48184
|
-
*
|
48185
|
-
* @param quantities - IDs of coins to exclude.
|
48186
|
-
* @param excludedIds - IDs of resources to be excluded from the query.
|
48187
|
-
* @returns A promise that resolves to an array of Resources.
|
48188
|
-
*/
|
48189
|
-
async getResourcesToSpend(quantities, excludedIds) {
|
48190
|
-
const resources = await this.provider.getResourcesToSpend(
|
48191
|
-
this.address,
|
48192
|
-
quantities,
|
48193
|
-
excludedIds
|
48194
|
-
);
|
48195
|
-
return resources.map((resource) => ({
|
48196
|
-
...resource,
|
48197
|
-
predicate: hexlify(this.bytes),
|
48198
|
-
predicateData: hexlify(this.predicateDataBytes),
|
48199
|
-
paddPredicateData: (policiesLength) => hexlify(this.getPredicateData(policiesLength))
|
48200
|
-
}));
|
48201
|
-
}
|
48202
47957
|
/**
|
48203
47958
|
* Sets the configurable constants for the predicate.
|
48204
47959
|
*
|