@fuel-ts/account 0.0.0-rc-2021-20240415193305 → 0.0.0-rc-1976-20240416161016
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 +600 -829
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +600 -835
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +443 -677
- 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 +329 -911
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/coin-quantity.d.ts +3 -3
- package/dist/providers/coin-quantity.d.ts.map +1 -1
- package/dist/providers/coin.d.ts +2 -4
- package/dist/providers/coin.d.ts.map +1 -1
- package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
- package/dist/providers/message.d.ts +1 -7
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +34 -37
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/input.d.ts +2 -2
- package/dist/providers/transaction-request/input.d.ts.map +1 -1
- package/dist/providers/transaction-request/script-transaction-request.d.ts +1 -1
- package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +29 -9
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/utils.d.ts +0 -3
- package/dist/providers/transaction-request/utils.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +0 -2
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +2 -3
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
- package/dist/providers/utils/gas.d.ts +2 -8
- package/dist/providers/utils/gas.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
- package/dist/test-utils.global.js +1114 -1578
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +599 -813
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +455 -669
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/package.json +22 -27
package/dist/index.global.js
CHANGED
@@ -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.80.0"
|
28958
28958
|
};
|
28959
28959
|
}
|
@@ -31272,10 +31272,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31272
31272
|
}
|
31273
31273
|
};
|
31274
31274
|
|
31275
|
-
// ../address/dist/configs.mjs
|
31276
|
-
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
31277
|
-
var BaseAssetId = ZeroBytes32;
|
31278
|
-
|
31279
31275
|
// ../math/dist/index.mjs
|
31280
31276
|
var import_bn = __toESM(require_bn(), 1);
|
31281
31277
|
var DEFAULT_PRECISION = 9;
|
@@ -31495,160 +31491,10 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31495
31491
|
function toBytes3(value, bytesPadding) {
|
31496
31492
|
return bn(value).toBytes(bytesPadding);
|
31497
31493
|
}
|
31498
|
-
|
31499
|
-
|
31500
|
-
function _isPlaceholder(a) {
|
31501
|
-
return a != null && typeof a === "object" && a["@@functional/placeholder"] === true;
|
31502
|
-
}
|
31503
|
-
|
31504
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_curry1.js
|
31505
|
-
function _curry1(fn) {
|
31506
|
-
return function f1(a) {
|
31507
|
-
if (arguments.length === 0 || _isPlaceholder(a)) {
|
31508
|
-
return f1;
|
31509
|
-
} else {
|
31510
|
-
return fn.apply(this, arguments);
|
31511
|
-
}
|
31512
|
-
};
|
31494
|
+
function max(...numbers) {
|
31495
|
+
return numbers.reduce((prev, cur) => bn(cur).gt(prev) ? bn(cur) : prev, bn(0));
|
31513
31496
|
}
|
31514
31497
|
|
31515
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isArray.js
|
31516
|
-
var isArray_default = Array.isArray || function _isArray(val) {
|
31517
|
-
return val != null && val.length >= 0 && Object.prototype.toString.call(val) === "[object Array]";
|
31518
|
-
};
|
31519
|
-
|
31520
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/type.js
|
31521
|
-
var type = /* @__PURE__ */ _curry1(function type2(val) {
|
31522
|
-
return val === null ? "Null" : val === void 0 ? "Undefined" : Object.prototype.toString.call(val).slice(8, -1);
|
31523
|
-
});
|
31524
|
-
var type_default = type;
|
31525
|
-
|
31526
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_toISOString.js
|
31527
|
-
var pad = function pad2(n) {
|
31528
|
-
return (n < 10 ? "0" : "") + n;
|
31529
|
-
};
|
31530
|
-
var _toISOString = typeof Date.prototype.toISOString === "function" ? function _toISOString2(d) {
|
31531
|
-
return d.toISOString();
|
31532
|
-
} : function _toISOString3(d) {
|
31533
|
-
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";
|
31534
|
-
};
|
31535
|
-
|
31536
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isInteger.js
|
31537
|
-
var isInteger_default = Number.isInteger || function _isInteger(n) {
|
31538
|
-
return n << 0 === n;
|
31539
|
-
};
|
31540
|
-
|
31541
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_cloneRegExp.js
|
31542
|
-
function _cloneRegExp(pattern) {
|
31543
|
-
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" : ""));
|
31544
|
-
}
|
31545
|
-
|
31546
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_clone.js
|
31547
|
-
function _clone(value, deep, map) {
|
31548
|
-
map || (map = new _ObjectMap());
|
31549
|
-
if (_isPrimitive(value)) {
|
31550
|
-
return value;
|
31551
|
-
}
|
31552
|
-
var copy = function copy2(copiedValue) {
|
31553
|
-
var cachedCopy = map.get(value);
|
31554
|
-
if (cachedCopy) {
|
31555
|
-
return cachedCopy;
|
31556
|
-
}
|
31557
|
-
map.set(value, copiedValue);
|
31558
|
-
for (var key in value) {
|
31559
|
-
if (Object.prototype.hasOwnProperty.call(value, key)) {
|
31560
|
-
copiedValue[key] = deep ? _clone(value[key], true, map) : value[key];
|
31561
|
-
}
|
31562
|
-
}
|
31563
|
-
return copiedValue;
|
31564
|
-
};
|
31565
|
-
switch (type_default(value)) {
|
31566
|
-
case "Object":
|
31567
|
-
return copy(Object.create(Object.getPrototypeOf(value)));
|
31568
|
-
case "Array":
|
31569
|
-
return copy([]);
|
31570
|
-
case "Date":
|
31571
|
-
return new Date(value.valueOf());
|
31572
|
-
case "RegExp":
|
31573
|
-
return _cloneRegExp(value);
|
31574
|
-
case "Int8Array":
|
31575
|
-
case "Uint8Array":
|
31576
|
-
case "Uint8ClampedArray":
|
31577
|
-
case "Int16Array":
|
31578
|
-
case "Uint16Array":
|
31579
|
-
case "Int32Array":
|
31580
|
-
case "Uint32Array":
|
31581
|
-
case "Float32Array":
|
31582
|
-
case "Float64Array":
|
31583
|
-
case "BigInt64Array":
|
31584
|
-
case "BigUint64Array":
|
31585
|
-
return value.slice();
|
31586
|
-
default:
|
31587
|
-
return value;
|
31588
|
-
}
|
31589
|
-
}
|
31590
|
-
function _isPrimitive(param) {
|
31591
|
-
var type3 = typeof param;
|
31592
|
-
return param == null || type3 != "object" && type3 != "function";
|
31593
|
-
}
|
31594
|
-
var _ObjectMap = /* @__PURE__ */ function() {
|
31595
|
-
function _ObjectMap2() {
|
31596
|
-
this.map = {};
|
31597
|
-
this.length = 0;
|
31598
|
-
}
|
31599
|
-
_ObjectMap2.prototype.set = function(key, value) {
|
31600
|
-
const hashedKey = this.hash(key);
|
31601
|
-
let bucket = this.map[hashedKey];
|
31602
|
-
if (!bucket) {
|
31603
|
-
this.map[hashedKey] = bucket = [];
|
31604
|
-
}
|
31605
|
-
bucket.push([key, value]);
|
31606
|
-
this.length += 1;
|
31607
|
-
};
|
31608
|
-
_ObjectMap2.prototype.hash = function(key) {
|
31609
|
-
let hashedKey = [];
|
31610
|
-
for (var value in key) {
|
31611
|
-
hashedKey.push(Object.prototype.toString.call(key[value]));
|
31612
|
-
}
|
31613
|
-
return hashedKey.join();
|
31614
|
-
};
|
31615
|
-
_ObjectMap2.prototype.get = function(key) {
|
31616
|
-
if (this.length <= 180) {
|
31617
|
-
for (const p in this.map) {
|
31618
|
-
const bucket2 = this.map[p];
|
31619
|
-
for (let i = 0; i < bucket2.length; i += 1) {
|
31620
|
-
const element = bucket2[i];
|
31621
|
-
if (element[0] === key) {
|
31622
|
-
return element[1];
|
31623
|
-
}
|
31624
|
-
}
|
31625
|
-
}
|
31626
|
-
return;
|
31627
|
-
}
|
31628
|
-
const hashedKey = this.hash(key);
|
31629
|
-
const bucket = this.map[hashedKey];
|
31630
|
-
if (!bucket) {
|
31631
|
-
return;
|
31632
|
-
}
|
31633
|
-
for (let i = 0; i < bucket.length; i += 1) {
|
31634
|
-
const element = bucket[i];
|
31635
|
-
if (element[0] === key) {
|
31636
|
-
return element[1];
|
31637
|
-
}
|
31638
|
-
}
|
31639
|
-
};
|
31640
|
-
return _ObjectMap2;
|
31641
|
-
}();
|
31642
|
-
|
31643
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/clone.js
|
31644
|
-
var clone = /* @__PURE__ */ _curry1(function clone2(value) {
|
31645
|
-
return value != null && typeof value.clone === "function" ? value.clone() : _clone(value, true);
|
31646
|
-
});
|
31647
|
-
var clone_default = clone;
|
31648
|
-
|
31649
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/trim.js
|
31650
|
-
var hasProtoTrim = typeof String.prototype.trim === "function";
|
31651
|
-
|
31652
31498
|
// src/providers/coin-quantity.ts
|
31653
31499
|
var coinQuantityfy = (coinQuantityLike) => {
|
31654
31500
|
let assetId;
|
@@ -31656,11 +31502,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31656
31502
|
let max2;
|
31657
31503
|
if (Array.isArray(coinQuantityLike)) {
|
31658
31504
|
amount = coinQuantityLike[0];
|
31659
|
-
assetId = coinQuantityLike[1]
|
31660
|
-
max2 = coinQuantityLike[2]
|
31505
|
+
assetId = coinQuantityLike[1];
|
31506
|
+
max2 = coinQuantityLike[2];
|
31661
31507
|
} else {
|
31662
31508
|
amount = coinQuantityLike.amount;
|
31663
|
-
assetId = coinQuantityLike.assetId
|
31509
|
+
assetId = coinQuantityLike.assetId;
|
31664
31510
|
max2 = coinQuantityLike.max ?? void 0;
|
31665
31511
|
}
|
31666
31512
|
const bnAmount = bn(amount);
|
@@ -31670,7 +31516,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31670
31516
|
max: max2 ? bn(max2) : void 0
|
31671
31517
|
};
|
31672
31518
|
};
|
31673
|
-
var
|
31519
|
+
var addAmountToAsset = (params) => {
|
31674
31520
|
const { amount, assetId } = params;
|
31675
31521
|
const coinQuantities = [...params.coinQuantities];
|
31676
31522
|
const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
|
@@ -31755,7 +31601,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31755
31601
|
var ENCODING_V1 = "1";
|
31756
31602
|
var WORD_SIZE = 8;
|
31757
31603
|
var BYTES_32 = 32;
|
31758
|
-
var UTXO_ID_LEN = BYTES_32 +
|
31604
|
+
var UTXO_ID_LEN = BYTES_32 + 1;
|
31759
31605
|
var ASSET_ID_LEN = BYTES_32;
|
31760
31606
|
var ADDRESS_LEN = BYTES_32;
|
31761
31607
|
var NONCE_LEN = BYTES_32;
|
@@ -31763,9 +31609,9 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31763
31609
|
var TX_POINTER_LEN = WORD_SIZE * 2;
|
31764
31610
|
var MAX_BYTES = 2 ** 32 - 1;
|
31765
31611
|
var calculateVmTxMemory = ({ maxInputs }) => BYTES_32 + // Tx ID
|
31766
|
-
|
31612
|
+
WORD_SIZE + // Tx size
|
31767
31613
|
// Asset ID/Balance coin input pairs
|
31768
|
-
maxInputs * (ASSET_ID_LEN + WORD_SIZE)
|
31614
|
+
maxInputs * (ASSET_ID_LEN + WORD_SIZE);
|
31769
31615
|
var SCRIPT_FIXED_SIZE = WORD_SIZE + // Identifier
|
31770
31616
|
WORD_SIZE + // Gas limit
|
31771
31617
|
WORD_SIZE + // Script size
|
@@ -31783,6 +31629,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31783
31629
|
ASSET_ID_LEN + // Asset id
|
31784
31630
|
TX_POINTER_LEN + // TxPointer
|
31785
31631
|
WORD_SIZE + // Witnesses index
|
31632
|
+
WORD_SIZE + // Maturity
|
31786
31633
|
WORD_SIZE + // Predicate size
|
31787
31634
|
WORD_SIZE + // Predicate data size
|
31788
31635
|
WORD_SIZE;
|
@@ -33520,19 +33367,18 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33520
33367
|
encode(value) {
|
33521
33368
|
const parts = [];
|
33522
33369
|
parts.push(new B256Coder().encode(value.txID));
|
33523
|
-
parts.push(new NumberCoder("
|
33370
|
+
parts.push(new NumberCoder("u8").encode(value.outputIndex));
|
33524
33371
|
parts.push(new B256Coder().encode(value.owner));
|
33525
33372
|
parts.push(new BigNumberCoder("u64").encode(value.amount));
|
33526
33373
|
parts.push(new B256Coder().encode(value.assetId));
|
33527
33374
|
parts.push(new TxPointerCoder().encode(value.txPointer));
|
33528
|
-
parts.push(new NumberCoder("
|
33375
|
+
parts.push(new NumberCoder("u8").encode(value.witnessIndex));
|
33376
|
+
parts.push(new NumberCoder("u32").encode(value.maturity));
|
33529
33377
|
parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
|
33530
|
-
parts.push(new
|
33531
|
-
parts.push(new
|
33532
|
-
parts.push(new ByteArrayCoder(value.predicateLength
|
33533
|
-
parts.push(
|
33534
|
-
new ByteArrayCoder(value.predicateDataLength.toNumber()).encode(value.predicateData)
|
33535
|
-
);
|
33378
|
+
parts.push(new NumberCoder("u32").encode(value.predicateLength));
|
33379
|
+
parts.push(new NumberCoder("u32").encode(value.predicateDataLength));
|
33380
|
+
parts.push(new ByteArrayCoder(value.predicateLength).encode(value.predicate));
|
33381
|
+
parts.push(new ByteArrayCoder(value.predicateDataLength).encode(value.predicateData));
|
33536
33382
|
return concat(parts);
|
33537
33383
|
}
|
33538
33384
|
decode(data, offset) {
|
@@ -33540,7 +33386,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33540
33386
|
let o = offset;
|
33541
33387
|
[decoded, o] = new B256Coder().decode(data, o);
|
33542
33388
|
const txID = decoded;
|
33543
|
-
[decoded, o] = new NumberCoder("
|
33389
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
33544
33390
|
const outputIndex = decoded;
|
33545
33391
|
[decoded, o] = new B256Coder().decode(data, o);
|
33546
33392
|
const owner = decoded;
|
@@ -33550,17 +33396,19 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33550
33396
|
const assetId = decoded;
|
33551
33397
|
[decoded, o] = new TxPointerCoder().decode(data, o);
|
33552
33398
|
const txPointer = decoded;
|
33553
|
-
[decoded, o] = new NumberCoder("
|
33399
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
33554
33400
|
const witnessIndex = Number(decoded);
|
33401
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33402
|
+
const maturity = decoded;
|
33555
33403
|
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33556
33404
|
const predicateGasUsed = decoded;
|
33557
|
-
[decoded, o] = new
|
33405
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33558
33406
|
const predicateLength = decoded;
|
33559
|
-
[decoded, o] = new
|
33407
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33560
33408
|
const predicateDataLength = decoded;
|
33561
|
-
[decoded, o] = new ByteArrayCoder(predicateLength
|
33409
|
+
[decoded, o] = new ByteArrayCoder(predicateLength).decode(data, o);
|
33562
33410
|
const predicate = decoded;
|
33563
|
-
[decoded, o] = new ByteArrayCoder(predicateDataLength
|
33411
|
+
[decoded, o] = new ByteArrayCoder(predicateDataLength).decode(data, o);
|
33564
33412
|
const predicateData = decoded;
|
33565
33413
|
return [
|
33566
33414
|
{
|
@@ -33572,6 +33420,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33572
33420
|
assetId,
|
33573
33421
|
txPointer,
|
33574
33422
|
witnessIndex,
|
33423
|
+
maturity,
|
33575
33424
|
predicateGasUsed,
|
33576
33425
|
predicateLength,
|
33577
33426
|
predicateDataLength,
|
@@ -33589,7 +33438,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33589
33438
|
encode(value) {
|
33590
33439
|
const parts = [];
|
33591
33440
|
parts.push(new B256Coder().encode(value.txID));
|
33592
|
-
parts.push(new NumberCoder("
|
33441
|
+
parts.push(new NumberCoder("u8").encode(value.outputIndex));
|
33593
33442
|
parts.push(new B256Coder().encode(value.balanceRoot));
|
33594
33443
|
parts.push(new B256Coder().encode(value.stateRoot));
|
33595
33444
|
parts.push(new TxPointerCoder().encode(value.txPointer));
|
@@ -33601,7 +33450,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33601
33450
|
let o = offset;
|
33602
33451
|
[decoded, o] = new B256Coder().decode(data, o);
|
33603
33452
|
const txID = decoded;
|
33604
|
-
[decoded, o] = new NumberCoder("
|
33453
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
33605
33454
|
const outputIndex = decoded;
|
33606
33455
|
[decoded, o] = new B256Coder().decode(data, o);
|
33607
33456
|
const balanceRoot = decoded;
|
@@ -33650,16 +33499,14 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33650
33499
|
parts.push(new ByteArrayCoder(32).encode(value.recipient));
|
33651
33500
|
parts.push(new BigNumberCoder("u64").encode(value.amount));
|
33652
33501
|
parts.push(new ByteArrayCoder(32).encode(value.nonce));
|
33653
|
-
parts.push(new NumberCoder("
|
33502
|
+
parts.push(new NumberCoder("u8").encode(value.witnessIndex));
|
33654
33503
|
parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
|
33655
|
-
parts.push(new
|
33656
|
-
parts.push(new
|
33657
|
-
parts.push(new
|
33504
|
+
parts.push(new NumberCoder("u32").encode(data.length));
|
33505
|
+
parts.push(new NumberCoder("u32").encode(value.predicateLength));
|
33506
|
+
parts.push(new NumberCoder("u32").encode(value.predicateDataLength));
|
33658
33507
|
parts.push(new ByteArrayCoder(data.length).encode(data));
|
33659
|
-
parts.push(new ByteArrayCoder(value.predicateLength
|
33660
|
-
parts.push(
|
33661
|
-
new ByteArrayCoder(value.predicateDataLength.toNumber()).encode(value.predicateData)
|
33662
|
-
);
|
33508
|
+
parts.push(new ByteArrayCoder(value.predicateLength).encode(value.predicate));
|
33509
|
+
parts.push(new ByteArrayCoder(value.predicateDataLength).encode(value.predicateData));
|
33663
33510
|
return concat(parts);
|
33664
33511
|
}
|
33665
33512
|
static decodeData(messageData) {
|
@@ -33679,21 +33526,21 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33679
33526
|
const amount = decoded;
|
33680
33527
|
[decoded, o] = new B256Coder().decode(data, o);
|
33681
33528
|
const nonce = decoded;
|
33682
|
-
[decoded, o] = new NumberCoder("
|
33529
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
33683
33530
|
const witnessIndex = Number(decoded);
|
33684
33531
|
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33685
33532
|
const predicateGasUsed = decoded;
|
33686
33533
|
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33687
33534
|
const dataLength2 = decoded;
|
33688
|
-
[decoded, o] = new
|
33535
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33689
33536
|
const predicateLength = decoded;
|
33690
|
-
[decoded, o] = new
|
33537
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33691
33538
|
const predicateDataLength = decoded;
|
33692
33539
|
[decoded, o] = new ByteArrayCoder(dataLength2).decode(data, o);
|
33693
33540
|
const messageData = decoded;
|
33694
|
-
[decoded, o] = new ByteArrayCoder(predicateLength
|
33541
|
+
[decoded, o] = new ByteArrayCoder(predicateLength).decode(data, o);
|
33695
33542
|
const predicate = decoded;
|
33696
|
-
[decoded, o] = new ByteArrayCoder(predicateDataLength
|
33543
|
+
[decoded, o] = new ByteArrayCoder(predicateDataLength).decode(data, o);
|
33697
33544
|
const predicateData = decoded;
|
33698
33545
|
return [
|
33699
33546
|
{
|
@@ -34005,7 +33852,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34005
33852
|
}
|
34006
33853
|
};
|
34007
33854
|
var PolicyType = /* @__PURE__ */ ((PolicyType2) => {
|
34008
|
-
PolicyType2[PolicyType2["
|
33855
|
+
PolicyType2[PolicyType2["GasPrice"] = 1] = "GasPrice";
|
34009
33856
|
PolicyType2[PolicyType2["WitnessLimit"] = 2] = "WitnessLimit";
|
34010
33857
|
PolicyType2[PolicyType2["Maturity"] = 4] = "Maturity";
|
34011
33858
|
PolicyType2[PolicyType2["MaxFee"] = 8] = "MaxFee";
|
@@ -34053,9 +33900,9 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34053
33900
|
let o = offset;
|
34054
33901
|
const policies = [];
|
34055
33902
|
if (policyTypes & 1) {
|
34056
|
-
const [
|
33903
|
+
const [gasPrice, nextOffset] = new BigNumberCoder("u64").decode(data, o);
|
34057
33904
|
o = nextOffset;
|
34058
|
-
policies.push({ type: 1, data:
|
33905
|
+
policies.push({ type: 1, data: gasPrice });
|
34059
33906
|
}
|
34060
33907
|
if (policyTypes & 2) {
|
34061
33908
|
const [witnessLimit, nextOffset] = new BigNumberCoder("u64").decode(data, o);
|
@@ -34287,15 +34134,15 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34287
34134
|
encode(value) {
|
34288
34135
|
const parts = [];
|
34289
34136
|
parts.push(new BigNumberCoder("u64").encode(value.scriptGasLimit));
|
34290
|
-
parts.push(new
|
34291
|
-
parts.push(new
|
34292
|
-
parts.push(new BigNumberCoder("u64").encode(value.scriptDataLength));
|
34137
|
+
parts.push(new NumberCoder("u32").encode(value.scriptLength));
|
34138
|
+
parts.push(new NumberCoder("u32").encode(value.scriptDataLength));
|
34293
34139
|
parts.push(new NumberCoder("u32").encode(value.policyTypes));
|
34294
|
-
parts.push(new NumberCoder("
|
34295
|
-
parts.push(new NumberCoder("
|
34296
|
-
parts.push(new NumberCoder("
|
34297
|
-
parts.push(new
|
34298
|
-
parts.push(new ByteArrayCoder(value.
|
34140
|
+
parts.push(new NumberCoder("u8").encode(value.inputsCount));
|
34141
|
+
parts.push(new NumberCoder("u8").encode(value.outputsCount));
|
34142
|
+
parts.push(new NumberCoder("u8").encode(value.witnessesCount));
|
34143
|
+
parts.push(new B256Coder().encode(value.receiptsRoot));
|
34144
|
+
parts.push(new ByteArrayCoder(value.scriptLength).encode(value.script));
|
34145
|
+
parts.push(new ByteArrayCoder(value.scriptDataLength).encode(value.scriptData));
|
34299
34146
|
parts.push(new PoliciesCoder().encode(value.policies));
|
34300
34147
|
parts.push(new ArrayCoder(new InputCoder(), value.inputsCount).encode(value.inputs));
|
34301
34148
|
parts.push(new ArrayCoder(new OutputCoder(), value.outputsCount).encode(value.outputs));
|
@@ -34307,23 +34154,23 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34307
34154
|
let o = offset;
|
34308
34155
|
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34309
34156
|
const scriptGasLimit = decoded;
|
34310
|
-
[decoded, o] = new
|
34311
|
-
const receiptsRoot = decoded;
|
34312
|
-
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34157
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
34313
34158
|
const scriptLength = decoded;
|
34314
|
-
[decoded, o] = new
|
34159
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
34315
34160
|
const scriptDataLength = decoded;
|
34316
34161
|
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
34317
34162
|
const policyTypes = decoded;
|
34318
|
-
[decoded, o] = new NumberCoder("
|
34163
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34319
34164
|
const inputsCount = decoded;
|
34320
|
-
[decoded, o] = new NumberCoder("
|
34165
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34321
34166
|
const outputsCount = decoded;
|
34322
|
-
[decoded, o] = new NumberCoder("
|
34167
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34323
34168
|
const witnessesCount = decoded;
|
34324
|
-
[decoded, o] = new
|
34169
|
+
[decoded, o] = new B256Coder().decode(data, o);
|
34170
|
+
const receiptsRoot = decoded;
|
34171
|
+
[decoded, o] = new ByteArrayCoder(scriptLength).decode(data, o);
|
34325
34172
|
const script = decoded;
|
34326
|
-
[decoded, o] = new ByteArrayCoder(scriptDataLength
|
34173
|
+
[decoded, o] = new ByteArrayCoder(scriptDataLength).decode(data, o);
|
34327
34174
|
const scriptData = decoded;
|
34328
34175
|
[decoded, o] = new PoliciesCoder().decode(data, o, policyTypes);
|
34329
34176
|
const policies = decoded;
|
@@ -34361,19 +34208,18 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34361
34208
|
}
|
34362
34209
|
encode(value) {
|
34363
34210
|
const parts = [];
|
34364
|
-
parts.push(new NumberCoder("
|
34365
|
-
parts.push(new
|
34366
|
-
parts.push(new BigNumberCoder("u64").encode(value.storageSlotsCount));
|
34211
|
+
parts.push(new NumberCoder("u32").encode(value.bytecodeLength));
|
34212
|
+
parts.push(new NumberCoder("u8").encode(value.bytecodeWitnessIndex));
|
34367
34213
|
parts.push(new NumberCoder("u32").encode(value.policyTypes));
|
34368
|
-
parts.push(new NumberCoder("u16").encode(value.
|
34369
|
-
parts.push(new NumberCoder("
|
34370
|
-
parts.push(new NumberCoder("
|
34214
|
+
parts.push(new NumberCoder("u16").encode(value.storageSlotsCount));
|
34215
|
+
parts.push(new NumberCoder("u8").encode(value.inputsCount));
|
34216
|
+
parts.push(new NumberCoder("u8").encode(value.outputsCount));
|
34217
|
+
parts.push(new NumberCoder("u8").encode(value.witnessesCount));
|
34218
|
+
parts.push(new B256Coder().encode(value.salt));
|
34219
|
+
parts.push(new PoliciesCoder().encode(value.policies));
|
34371
34220
|
parts.push(
|
34372
|
-
new ArrayCoder(new StorageSlotCoder(), value.storageSlotsCount
|
34373
|
-
value.storageSlots
|
34374
|
-
)
|
34221
|
+
new ArrayCoder(new StorageSlotCoder(), value.storageSlotsCount).encode(value.storageSlots)
|
34375
34222
|
);
|
34376
|
-
parts.push(new PoliciesCoder().encode(value.policies));
|
34377
34223
|
parts.push(new ArrayCoder(new InputCoder(), value.inputsCount).encode(value.inputs));
|
34378
34224
|
parts.push(new ArrayCoder(new OutputCoder(), value.outputsCount).encode(value.outputs));
|
34379
34225
|
parts.push(new ArrayCoder(new WitnessCoder(), value.witnessesCount).encode(value.witnesses));
|
@@ -34382,27 +34228,26 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34382
34228
|
decode(data, offset) {
|
34383
34229
|
let decoded;
|
34384
34230
|
let o = offset;
|
34385
|
-
[decoded, o] = new NumberCoder("
|
34231
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
34232
|
+
const bytecodeLength = decoded;
|
34233
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34386
34234
|
const bytecodeWitnessIndex = decoded;
|
34387
|
-
[decoded, o] = new B256Coder().decode(data, o);
|
34388
|
-
const salt = decoded;
|
34389
|
-
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34390
|
-
const storageSlotsCount = decoded;
|
34391
34235
|
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
34392
34236
|
const policyTypes = decoded;
|
34393
34237
|
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
34238
|
+
const storageSlotsCount = decoded;
|
34239
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34394
34240
|
const inputsCount = decoded;
|
34395
|
-
[decoded, o] = new NumberCoder("
|
34241
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34396
34242
|
const outputsCount = decoded;
|
34397
|
-
[decoded, o] = new NumberCoder("
|
34243
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34398
34244
|
const witnessesCount = decoded;
|
34399
|
-
[decoded, o] = new
|
34400
|
-
|
34401
|
-
o
|
34402
|
-
);
|
34403
|
-
const storageSlots = decoded;
|
34245
|
+
[decoded, o] = new B256Coder().decode(data, o);
|
34246
|
+
const salt = decoded;
|
34404
34247
|
[decoded, o] = new PoliciesCoder().decode(data, o, policyTypes);
|
34405
34248
|
const policies = decoded;
|
34249
|
+
[decoded, o] = new ArrayCoder(new StorageSlotCoder(), storageSlotsCount).decode(data, o);
|
34250
|
+
const storageSlots = decoded;
|
34406
34251
|
[decoded, o] = new ArrayCoder(new InputCoder(), inputsCount).decode(data, o);
|
34407
34252
|
const inputs = decoded;
|
34408
34253
|
[decoded, o] = new ArrayCoder(new OutputCoder(), outputsCount).decode(data, o);
|
@@ -34412,6 +34257,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34412
34257
|
return [
|
34413
34258
|
{
|
34414
34259
|
type: 1,
|
34260
|
+
bytecodeLength,
|
34415
34261
|
bytecodeWitnessIndex,
|
34416
34262
|
policyTypes,
|
34417
34263
|
storageSlotsCount,
|
@@ -34440,7 +34286,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34440
34286
|
parts.push(new OutputContractCoder().encode(value.outputContract));
|
34441
34287
|
parts.push(new BigNumberCoder("u64").encode(value.mintAmount));
|
34442
34288
|
parts.push(new B256Coder().encode(value.mintAssetId));
|
34443
|
-
parts.push(new BigNumberCoder("u64").encode(value.gasPrice));
|
34444
34289
|
return concat(parts);
|
34445
34290
|
}
|
34446
34291
|
decode(data, offset) {
|
@@ -34456,8 +34301,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34456
34301
|
const mintAmount = decoded;
|
34457
34302
|
[decoded, o] = new B256Coder().decode(data, o);
|
34458
34303
|
const mintAssetId = decoded;
|
34459
|
-
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34460
|
-
const gasPrice = decoded;
|
34461
34304
|
return [
|
34462
34305
|
{
|
34463
34306
|
type: 2,
|
@@ -34465,8 +34308,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34465
34308
|
inputContract,
|
34466
34309
|
outputContract,
|
34467
34310
|
mintAmount,
|
34468
|
-
mintAssetId
|
34469
|
-
gasPrice
|
34311
|
+
mintAssetId
|
34470
34312
|
},
|
34471
34313
|
o
|
34472
34314
|
];
|
@@ -34773,6 +34615,159 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34773
34615
|
// src/providers/provider.ts
|
34774
34616
|
var import_graphql_request = __toESM(require_dist2());
|
34775
34617
|
|
34618
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isPlaceholder.js
|
34619
|
+
function _isPlaceholder(a) {
|
34620
|
+
return a != null && typeof a === "object" && a["@@functional/placeholder"] === true;
|
34621
|
+
}
|
34622
|
+
|
34623
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_curry1.js
|
34624
|
+
function _curry1(fn) {
|
34625
|
+
return function f1(a) {
|
34626
|
+
if (arguments.length === 0 || _isPlaceholder(a)) {
|
34627
|
+
return f1;
|
34628
|
+
} else {
|
34629
|
+
return fn.apply(this, arguments);
|
34630
|
+
}
|
34631
|
+
};
|
34632
|
+
}
|
34633
|
+
|
34634
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isArray.js
|
34635
|
+
var isArray_default = Array.isArray || function _isArray(val) {
|
34636
|
+
return val != null && val.length >= 0 && Object.prototype.toString.call(val) === "[object Array]";
|
34637
|
+
};
|
34638
|
+
|
34639
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/type.js
|
34640
|
+
var type = /* @__PURE__ */ _curry1(function type2(val) {
|
34641
|
+
return val === null ? "Null" : val === void 0 ? "Undefined" : Object.prototype.toString.call(val).slice(8, -1);
|
34642
|
+
});
|
34643
|
+
var type_default = type;
|
34644
|
+
|
34645
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_toISOString.js
|
34646
|
+
var pad = function pad2(n) {
|
34647
|
+
return (n < 10 ? "0" : "") + n;
|
34648
|
+
};
|
34649
|
+
var _toISOString = typeof Date.prototype.toISOString === "function" ? function _toISOString2(d) {
|
34650
|
+
return d.toISOString();
|
34651
|
+
} : function _toISOString3(d) {
|
34652
|
+
return d.getUTCFullYear() + "-" + pad(d.getUTCMonth() + 1) + "-" + pad(d.getUTCDate()) + "T" + pad(d.getUTCHours()) + ":" + pad(d.getUTCMinutes()) + ":" + pad(d.getUTCSeconds()) + "." + (d.getUTCMilliseconds() / 1e3).toFixed(3).slice(2, 5) + "Z";
|
34653
|
+
};
|
34654
|
+
|
34655
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isInteger.js
|
34656
|
+
var isInteger_default = Number.isInteger || function _isInteger(n) {
|
34657
|
+
return n << 0 === n;
|
34658
|
+
};
|
34659
|
+
|
34660
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_cloneRegExp.js
|
34661
|
+
function _cloneRegExp(pattern) {
|
34662
|
+
return new RegExp(pattern.source, pattern.flags ? pattern.flags : (pattern.global ? "g" : "") + (pattern.ignoreCase ? "i" : "") + (pattern.multiline ? "m" : "") + (pattern.sticky ? "y" : "") + (pattern.unicode ? "u" : "") + (pattern.dotAll ? "s" : ""));
|
34663
|
+
}
|
34664
|
+
|
34665
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_clone.js
|
34666
|
+
function _clone(value, deep, map) {
|
34667
|
+
map || (map = new _ObjectMap());
|
34668
|
+
if (_isPrimitive(value)) {
|
34669
|
+
return value;
|
34670
|
+
}
|
34671
|
+
var copy = function copy2(copiedValue) {
|
34672
|
+
var cachedCopy = map.get(value);
|
34673
|
+
if (cachedCopy) {
|
34674
|
+
return cachedCopy;
|
34675
|
+
}
|
34676
|
+
map.set(value, copiedValue);
|
34677
|
+
for (var key in value) {
|
34678
|
+
if (Object.prototype.hasOwnProperty.call(value, key)) {
|
34679
|
+
copiedValue[key] = deep ? _clone(value[key], true, map) : value[key];
|
34680
|
+
}
|
34681
|
+
}
|
34682
|
+
return copiedValue;
|
34683
|
+
};
|
34684
|
+
switch (type_default(value)) {
|
34685
|
+
case "Object":
|
34686
|
+
return copy(Object.create(Object.getPrototypeOf(value)));
|
34687
|
+
case "Array":
|
34688
|
+
return copy([]);
|
34689
|
+
case "Date":
|
34690
|
+
return new Date(value.valueOf());
|
34691
|
+
case "RegExp":
|
34692
|
+
return _cloneRegExp(value);
|
34693
|
+
case "Int8Array":
|
34694
|
+
case "Uint8Array":
|
34695
|
+
case "Uint8ClampedArray":
|
34696
|
+
case "Int16Array":
|
34697
|
+
case "Uint16Array":
|
34698
|
+
case "Int32Array":
|
34699
|
+
case "Uint32Array":
|
34700
|
+
case "Float32Array":
|
34701
|
+
case "Float64Array":
|
34702
|
+
case "BigInt64Array":
|
34703
|
+
case "BigUint64Array":
|
34704
|
+
return value.slice();
|
34705
|
+
default:
|
34706
|
+
return value;
|
34707
|
+
}
|
34708
|
+
}
|
34709
|
+
function _isPrimitive(param) {
|
34710
|
+
var type3 = typeof param;
|
34711
|
+
return param == null || type3 != "object" && type3 != "function";
|
34712
|
+
}
|
34713
|
+
var _ObjectMap = /* @__PURE__ */ function() {
|
34714
|
+
function _ObjectMap2() {
|
34715
|
+
this.map = {};
|
34716
|
+
this.length = 0;
|
34717
|
+
}
|
34718
|
+
_ObjectMap2.prototype.set = function(key, value) {
|
34719
|
+
const hashedKey = this.hash(key);
|
34720
|
+
let bucket = this.map[hashedKey];
|
34721
|
+
if (!bucket) {
|
34722
|
+
this.map[hashedKey] = bucket = [];
|
34723
|
+
}
|
34724
|
+
bucket.push([key, value]);
|
34725
|
+
this.length += 1;
|
34726
|
+
};
|
34727
|
+
_ObjectMap2.prototype.hash = function(key) {
|
34728
|
+
let hashedKey = [];
|
34729
|
+
for (var value in key) {
|
34730
|
+
hashedKey.push(Object.prototype.toString.call(key[value]));
|
34731
|
+
}
|
34732
|
+
return hashedKey.join();
|
34733
|
+
};
|
34734
|
+
_ObjectMap2.prototype.get = function(key) {
|
34735
|
+
if (this.length <= 180) {
|
34736
|
+
for (const p in this.map) {
|
34737
|
+
const bucket2 = this.map[p];
|
34738
|
+
for (let i = 0; i < bucket2.length; i += 1) {
|
34739
|
+
const element = bucket2[i];
|
34740
|
+
if (element[0] === key) {
|
34741
|
+
return element[1];
|
34742
|
+
}
|
34743
|
+
}
|
34744
|
+
}
|
34745
|
+
return;
|
34746
|
+
}
|
34747
|
+
const hashedKey = this.hash(key);
|
34748
|
+
const bucket = this.map[hashedKey];
|
34749
|
+
if (!bucket) {
|
34750
|
+
return;
|
34751
|
+
}
|
34752
|
+
for (let i = 0; i < bucket.length; i += 1) {
|
34753
|
+
const element = bucket[i];
|
34754
|
+
if (element[0] === key) {
|
34755
|
+
return element[1];
|
34756
|
+
}
|
34757
|
+
}
|
34758
|
+
};
|
34759
|
+
return _ObjectMap2;
|
34760
|
+
}();
|
34761
|
+
|
34762
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/clone.js
|
34763
|
+
var clone2 = /* @__PURE__ */ _curry1(function clone3(value) {
|
34764
|
+
return value != null && typeof value.clone === "function" ? value.clone() : _clone(value, true);
|
34765
|
+
});
|
34766
|
+
var clone_default = clone2;
|
34767
|
+
|
34768
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/trim.js
|
34769
|
+
var hasProtoTrim = typeof String.prototype.trim === "function";
|
34770
|
+
|
34776
34771
|
// ../../node_modules/.pnpm/tslib@2.6.0/node_modules/tslib/tslib.es6.mjs
|
34777
34772
|
var __assign = function() {
|
34778
34773
|
__assign = Object.assign || function __assign2(t) {
|
@@ -37940,10 +37935,14 @@ spurious results.`);
|
|
37940
37935
|
// src/providers/__generated__/operations.ts
|
37941
37936
|
var ReceiptFragmentFragmentDoc = lib_default2`
|
37942
37937
|
fragment receiptFragment on Receipt {
|
37943
|
-
|
37938
|
+
contract {
|
37939
|
+
id
|
37940
|
+
}
|
37944
37941
|
pc
|
37945
37942
|
is
|
37946
|
-
to
|
37943
|
+
to {
|
37944
|
+
id
|
37945
|
+
}
|
37947
37946
|
toAddress
|
37948
37947
|
amount
|
37949
37948
|
assetId
|
@@ -37981,16 +37980,10 @@ spurious results.`);
|
|
37981
37980
|
id
|
37982
37981
|
}
|
37983
37982
|
time
|
37984
|
-
receipts {
|
37985
|
-
...receiptFragment
|
37986
|
-
}
|
37987
37983
|
programState {
|
37988
37984
|
returnType
|
37989
37985
|
data
|
37990
37986
|
}
|
37991
|
-
receipts {
|
37992
|
-
...receiptFragment
|
37993
|
-
}
|
37994
37987
|
}
|
37995
37988
|
... on FailureStatus {
|
37996
37989
|
block {
|
@@ -37998,24 +37991,26 @@ spurious results.`);
|
|
37998
37991
|
}
|
37999
37992
|
time
|
38000
37993
|
reason
|
38001
|
-
receipts {
|
38002
|
-
...receiptFragment
|
38003
|
-
}
|
38004
37994
|
}
|
38005
37995
|
... on SqueezedOutStatus {
|
38006
37996
|
reason
|
38007
37997
|
}
|
38008
37998
|
}
|
38009
|
-
|
37999
|
+
`;
|
38010
38000
|
var TransactionFragmentFragmentDoc = lib_default2`
|
38011
38001
|
fragment transactionFragment on Transaction {
|
38012
38002
|
id
|
38013
38003
|
rawPayload
|
38004
|
+
gasPrice
|
38005
|
+
receipts {
|
38006
|
+
...receiptFragment
|
38007
|
+
}
|
38014
38008
|
status {
|
38015
38009
|
...transactionStatusFragment
|
38016
38010
|
}
|
38017
38011
|
}
|
38018
|
-
${
|
38012
|
+
${ReceiptFragmentFragmentDoc}
|
38013
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
38019
38014
|
var InputEstimatePredicatesFragmentFragmentDoc = lib_default2`
|
38020
38015
|
fragment inputEstimatePredicatesFragment on Input {
|
38021
38016
|
... on InputCoin {
|
@@ -38033,46 +38028,6 @@ spurious results.`);
|
|
38033
38028
|
}
|
38034
38029
|
}
|
38035
38030
|
${InputEstimatePredicatesFragmentFragmentDoc}`;
|
38036
|
-
var DryRunFailureStatusFragmentFragmentDoc = lib_default2`
|
38037
|
-
fragment dryRunFailureStatusFragment on DryRunFailureStatus {
|
38038
|
-
reason
|
38039
|
-
programState {
|
38040
|
-
returnType
|
38041
|
-
data
|
38042
|
-
}
|
38043
|
-
}
|
38044
|
-
`;
|
38045
|
-
var DryRunSuccessStatusFragmentFragmentDoc = lib_default2`
|
38046
|
-
fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
|
38047
|
-
programState {
|
38048
|
-
returnType
|
38049
|
-
data
|
38050
|
-
}
|
38051
|
-
}
|
38052
|
-
`;
|
38053
|
-
var DryRunTransactionStatusFragmentFragmentDoc = lib_default2`
|
38054
|
-
fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
|
38055
|
-
... on DryRunFailureStatus {
|
38056
|
-
...dryRunFailureStatusFragment
|
38057
|
-
}
|
38058
|
-
... on DryRunSuccessStatus {
|
38059
|
-
...dryRunSuccessStatusFragment
|
38060
|
-
}
|
38061
|
-
}
|
38062
|
-
${DryRunFailureStatusFragmentFragmentDoc}
|
38063
|
-
${DryRunSuccessStatusFragmentFragmentDoc}`;
|
38064
|
-
var DryRunTransactionExecutionStatusFragmentFragmentDoc = lib_default2`
|
38065
|
-
fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
|
38066
|
-
id
|
38067
|
-
status {
|
38068
|
-
...dryRunTransactionStatusFragment
|
38069
|
-
}
|
38070
|
-
receipts {
|
38071
|
-
...receiptFragment
|
38072
|
-
}
|
38073
|
-
}
|
38074
|
-
${DryRunTransactionStatusFragmentFragmentDoc}
|
38075
|
-
${ReceiptFragmentFragmentDoc}`;
|
38076
38031
|
var CoinFragmentFragmentDoc = lib_default2`
|
38077
38032
|
fragment coinFragment on Coin {
|
38078
38033
|
__typename
|
@@ -38080,6 +38035,7 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38080
38035
|
owner
|
38081
38036
|
amount
|
38082
38037
|
assetId
|
38038
|
+
maturity
|
38083
38039
|
blockCreated
|
38084
38040
|
txCreatedIdx
|
38085
38041
|
}
|
@@ -38118,32 +38074,26 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38118
38074
|
messageBlockHeader {
|
38119
38075
|
id
|
38120
38076
|
daHeight
|
38121
|
-
consensusParametersVersion
|
38122
|
-
stateTransitionBytecodeVersion
|
38123
38077
|
transactionsCount
|
38124
|
-
messageReceiptCount
|
38125
38078
|
transactionsRoot
|
38126
|
-
messageOutboxRoot
|
38127
|
-
eventInboxRoot
|
38128
38079
|
height
|
38129
38080
|
prevRoot
|
38130
38081
|
time
|
38131
38082
|
applicationHash
|
38083
|
+
messageReceiptRoot
|
38084
|
+
messageReceiptCount
|
38132
38085
|
}
|
38133
38086
|
commitBlockHeader {
|
38134
38087
|
id
|
38135
38088
|
daHeight
|
38136
|
-
consensusParametersVersion
|
38137
|
-
stateTransitionBytecodeVersion
|
38138
38089
|
transactionsCount
|
38139
|
-
messageReceiptCount
|
38140
38090
|
transactionsRoot
|
38141
|
-
messageOutboxRoot
|
38142
|
-
eventInboxRoot
|
38143
38091
|
height
|
38144
38092
|
prevRoot
|
38145
38093
|
time
|
38146
38094
|
applicationHash
|
38095
|
+
messageReceiptRoot
|
38096
|
+
messageReceiptCount
|
38147
38097
|
}
|
38148
38098
|
sender
|
38149
38099
|
recipient
|
@@ -38162,8 +38112,8 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38162
38112
|
var BlockFragmentFragmentDoc = lib_default2`
|
38163
38113
|
fragment blockFragment on Block {
|
38164
38114
|
id
|
38165
|
-
height
|
38166
38115
|
header {
|
38116
|
+
height
|
38167
38117
|
time
|
38168
38118
|
}
|
38169
38119
|
transactions {
|
@@ -38221,11 +38171,6 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38221
38171
|
`;
|
38222
38172
|
var GasCostsFragmentFragmentDoc = lib_default2`
|
38223
38173
|
fragment GasCostsFragment on GasCosts {
|
38224
|
-
version {
|
38225
|
-
... on Version {
|
38226
|
-
value
|
38227
|
-
}
|
38228
|
-
}
|
38229
38174
|
add
|
38230
38175
|
addi
|
38231
38176
|
aloc
|
@@ -38238,6 +38183,7 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38238
38183
|
cb
|
38239
38184
|
cfei
|
38240
38185
|
cfsi
|
38186
|
+
croo
|
38241
38187
|
div
|
38242
38188
|
divi
|
38243
38189
|
ecr1
|
@@ -38320,9 +38266,6 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38320
38266
|
ccp {
|
38321
38267
|
...DependentCostFragment
|
38322
38268
|
}
|
38323
|
-
croo {
|
38324
|
-
...DependentCostFragment
|
38325
|
-
}
|
38326
38269
|
csiz {
|
38327
38270
|
...DependentCostFragment
|
38328
38271
|
}
|
@@ -38382,11 +38325,6 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38382
38325
|
${DependentCostFragmentFragmentDoc}`;
|
38383
38326
|
var ConsensusParametersFragmentFragmentDoc = lib_default2`
|
38384
38327
|
fragment consensusParametersFragment on ConsensusParameters {
|
38385
|
-
version {
|
38386
|
-
... on Version {
|
38387
|
-
value
|
38388
|
-
}
|
38389
|
-
}
|
38390
38328
|
txParams {
|
38391
38329
|
...TxParametersFragment
|
38392
38330
|
}
|
@@ -38446,9 +38384,18 @@ ${ConsensusParametersFragmentFragmentDoc}`;
|
|
38446
38384
|
fragment nodeInfoFragment on NodeInfo {
|
38447
38385
|
utxoValidation
|
38448
38386
|
vmBacktrace
|
38387
|
+
minGasPrice
|
38449
38388
|
maxTx
|
38450
38389
|
maxDepth
|
38451
38390
|
nodeVersion
|
38391
|
+
peers {
|
38392
|
+
id
|
38393
|
+
addresses
|
38394
|
+
clientVersion
|
38395
|
+
blockHeight
|
38396
|
+
lastHeartbeatMs
|
38397
|
+
appScore
|
38398
|
+
}
|
38452
38399
|
}
|
38453
38400
|
`;
|
38454
38401
|
var GetVersionDocument = lib_default2`
|
@@ -38483,9 +38430,13 @@ ${ConsensusParametersFragmentFragmentDoc}`;
|
|
38483
38430
|
query getTransactionWithReceipts($transactionId: TransactionId!) {
|
38484
38431
|
transaction(id: $transactionId) {
|
38485
38432
|
...transactionFragment
|
38433
|
+
receipts {
|
38434
|
+
...receiptFragment
|
38435
|
+
}
|
38486
38436
|
}
|
38487
38437
|
}
|
38488
|
-
${TransactionFragmentFragmentDoc}
|
38438
|
+
${TransactionFragmentFragmentDoc}
|
38439
|
+
${ReceiptFragmentFragmentDoc}`;
|
38489
38440
|
var GetTransactionsDocument = lib_default2`
|
38490
38441
|
query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
|
38491
38442
|
transactions(after: $after, before: $before, first: $first, last: $last) {
|
@@ -38613,20 +38564,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38613
38564
|
}
|
38614
38565
|
}
|
38615
38566
|
${BalanceFragmentFragmentDoc}`;
|
38616
|
-
var GetLatestGasPriceDocument = lib_default2`
|
38617
|
-
query getLatestGasPrice {
|
38618
|
-
latestGasPrice {
|
38619
|
-
gasPrice
|
38620
|
-
}
|
38621
|
-
}
|
38622
|
-
`;
|
38623
|
-
var EstimateGasPriceDocument = lib_default2`
|
38624
|
-
query estimateGasPrice($blockHorizon: U32!) {
|
38625
|
-
estimateGasPrice(blockHorizon: $blockHorizon) {
|
38626
|
-
gasPrice
|
38627
|
-
}
|
38628
|
-
}
|
38629
|
-
`;
|
38630
38567
|
var GetBalancesDocument = lib_default2`
|
38631
38568
|
query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
38632
38569
|
balances(
|
@@ -38681,12 +38618,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38681
38618
|
}
|
38682
38619
|
`;
|
38683
38620
|
var DryRunDocument = lib_default2`
|
38684
|
-
mutation dryRun($
|
38685
|
-
dryRun(
|
38686
|
-
...
|
38621
|
+
mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
|
38622
|
+
dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
|
38623
|
+
...receiptFragment
|
38687
38624
|
}
|
38688
38625
|
}
|
38689
|
-
${
|
38626
|
+
${ReceiptFragmentFragmentDoc}`;
|
38690
38627
|
var SubmitDocument = lib_default2`
|
38691
38628
|
mutation submit($encodedTransaction: HexString!) {
|
38692
38629
|
submit(tx: $encodedTransaction) {
|
@@ -38769,12 +38706,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38769
38706
|
getBalance(variables, options) {
|
38770
38707
|
return requester(GetBalanceDocument, variables, options);
|
38771
38708
|
},
|
38772
|
-
getLatestGasPrice(variables, options) {
|
38773
|
-
return requester(GetLatestGasPriceDocument, variables, options);
|
38774
|
-
},
|
38775
|
-
estimateGasPrice(variables, options) {
|
38776
|
-
return requester(EstimateGasPriceDocument, variables, options);
|
38777
|
-
},
|
38778
38709
|
getBalances(variables, options) {
|
38779
38710
|
return requester(GetBalancesDocument, variables, options);
|
38780
38711
|
},
|
@@ -38842,14 +38773,11 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38842
38773
|
let data;
|
38843
38774
|
let errors;
|
38844
38775
|
try {
|
38845
|
-
|
38846
|
-
({ data, errors } = JSON.parse(sanitizedText.replace(/^data:/, "")));
|
38776
|
+
({ data, errors } = JSON.parse(text.replace(/^data:/, "")));
|
38847
38777
|
} catch (e) {
|
38848
38778
|
throw new FuelError(
|
38849
38779
|
ErrorCode.STREAM_PARSING_ERROR,
|
38850
|
-
`Error while parsing stream data response: ${text}
|
38851
|
-
|
38852
|
-
Thrown error: ${e}`
|
38780
|
+
`Error while parsing stream data response: ${text}`
|
38853
38781
|
);
|
38854
38782
|
}
|
38855
38783
|
if (Array.isArray(errors)) {
|
@@ -38933,6 +38861,9 @@ Thrown error: ${e}`
|
|
38933
38861
|
}
|
38934
38862
|
};
|
38935
38863
|
|
38864
|
+
// ../address/dist/configs.mjs
|
38865
|
+
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
38866
|
+
|
38936
38867
|
// src/providers/transaction-request/input.ts
|
38937
38868
|
var inputify = (value) => {
|
38938
38869
|
const { type: type3 } = value;
|
@@ -38952,9 +38883,10 @@ Thrown error: ${e}`
|
|
38952
38883
|
txIndex: toNumber2(arrayify(value.txPointer).slice(8, 16))
|
38953
38884
|
},
|
38954
38885
|
witnessIndex: value.witnessIndex,
|
38886
|
+
maturity: value.maturity ?? 0,
|
38955
38887
|
predicateGasUsed: bn(value.predicateGasUsed),
|
38956
|
-
predicateLength:
|
38957
|
-
predicateDataLength:
|
38888
|
+
predicateLength: predicate.length,
|
38889
|
+
predicateDataLength: predicateData.length,
|
38958
38890
|
predicate: hexlify(predicate),
|
38959
38891
|
predicateData: hexlify(predicateData)
|
38960
38892
|
};
|
@@ -38985,8 +38917,8 @@ Thrown error: ${e}`
|
|
38985
38917
|
nonce: hexlify(value.nonce),
|
38986
38918
|
witnessIndex: value.witnessIndex,
|
38987
38919
|
predicateGasUsed: bn(value.predicateGasUsed),
|
38988
|
-
predicateLength:
|
38989
|
-
predicateDataLength:
|
38920
|
+
predicateLength: predicate.length,
|
38921
|
+
predicateDataLength: predicateData.length,
|
38990
38922
|
predicate: hexlify(predicate),
|
38991
38923
|
predicateData: hexlify(predicateData),
|
38992
38924
|
data: hexlify(data),
|
@@ -39146,8 +39078,8 @@ Thrown error: ${e}`
|
|
39146
39078
|
case "CALL" /* Call */: {
|
39147
39079
|
const callReceipt = {
|
39148
39080
|
type: ReceiptType.Call,
|
39149
|
-
from: hexOrZero(receipt.id
|
39150
|
-
to: hexOrZero(receipt?.to),
|
39081
|
+
from: hexOrZero(receipt.contract?.id),
|
39082
|
+
to: hexOrZero(receipt?.to?.id),
|
39151
39083
|
amount: bn(receipt.amount),
|
39152
39084
|
assetId: hexOrZero(receipt.assetId),
|
39153
39085
|
gas: bn(receipt.gas),
|
@@ -39161,7 +39093,7 @@ Thrown error: ${e}`
|
|
39161
39093
|
case "RETURN" /* Return */: {
|
39162
39094
|
const returnReceipt = {
|
39163
39095
|
type: ReceiptType.Return,
|
39164
|
-
id: hexOrZero(receipt.id
|
39096
|
+
id: hexOrZero(receipt.contract?.id),
|
39165
39097
|
val: bn(receipt.val),
|
39166
39098
|
pc: bn(receipt.pc),
|
39167
39099
|
is: bn(receipt.is)
|
@@ -39171,7 +39103,7 @@ Thrown error: ${e}`
|
|
39171
39103
|
case "RETURN_DATA" /* ReturnData */: {
|
39172
39104
|
const returnDataReceipt = {
|
39173
39105
|
type: ReceiptType.ReturnData,
|
39174
|
-
id: hexOrZero(receipt.id
|
39106
|
+
id: hexOrZero(receipt.contract?.id),
|
39175
39107
|
ptr: bn(receipt.ptr),
|
39176
39108
|
len: bn(receipt.len),
|
39177
39109
|
digest: hexOrZero(receipt.digest),
|
@@ -39183,7 +39115,7 @@ Thrown error: ${e}`
|
|
39183
39115
|
case "PANIC" /* Panic */: {
|
39184
39116
|
const panicReceipt = {
|
39185
39117
|
type: ReceiptType.Panic,
|
39186
|
-
id: hexOrZero(receipt.id),
|
39118
|
+
id: hexOrZero(receipt.contract?.id),
|
39187
39119
|
reason: bn(receipt.reason),
|
39188
39120
|
pc: bn(receipt.pc),
|
39189
39121
|
is: bn(receipt.is),
|
@@ -39194,7 +39126,7 @@ Thrown error: ${e}`
|
|
39194
39126
|
case "REVERT" /* Revert */: {
|
39195
39127
|
const revertReceipt = {
|
39196
39128
|
type: ReceiptType.Revert,
|
39197
|
-
id: hexOrZero(receipt.id
|
39129
|
+
id: hexOrZero(receipt.contract?.id),
|
39198
39130
|
val: bn(receipt.ra),
|
39199
39131
|
pc: bn(receipt.pc),
|
39200
39132
|
is: bn(receipt.is)
|
@@ -39204,7 +39136,7 @@ Thrown error: ${e}`
|
|
39204
39136
|
case "LOG" /* Log */: {
|
39205
39137
|
const logReceipt = {
|
39206
39138
|
type: ReceiptType.Log,
|
39207
|
-
id: hexOrZero(receipt.id
|
39139
|
+
id: hexOrZero(receipt.contract?.id),
|
39208
39140
|
val0: bn(receipt.ra),
|
39209
39141
|
val1: bn(receipt.rb),
|
39210
39142
|
val2: bn(receipt.rc),
|
@@ -39217,7 +39149,7 @@ Thrown error: ${e}`
|
|
39217
39149
|
case "LOG_DATA" /* LogData */: {
|
39218
39150
|
const logDataReceipt = {
|
39219
39151
|
type: ReceiptType.LogData,
|
39220
|
-
id: hexOrZero(receipt.id
|
39152
|
+
id: hexOrZero(receipt.contract?.id),
|
39221
39153
|
val0: bn(receipt.ra),
|
39222
39154
|
val1: bn(receipt.rb),
|
39223
39155
|
ptr: bn(receipt.ptr),
|
@@ -39231,8 +39163,8 @@ Thrown error: ${e}`
|
|
39231
39163
|
case "TRANSFER" /* Transfer */: {
|
39232
39164
|
const transferReceipt = {
|
39233
39165
|
type: ReceiptType.Transfer,
|
39234
|
-
from: hexOrZero(receipt.id
|
39235
|
-
to: hexOrZero(receipt.toAddress || receipt?.to),
|
39166
|
+
from: hexOrZero(receipt.contract?.id),
|
39167
|
+
to: hexOrZero(receipt.toAddress || receipt?.to?.id),
|
39236
39168
|
amount: bn(receipt.amount),
|
39237
39169
|
assetId: hexOrZero(receipt.assetId),
|
39238
39170
|
pc: bn(receipt.pc),
|
@@ -39243,8 +39175,8 @@ Thrown error: ${e}`
|
|
39243
39175
|
case "TRANSFER_OUT" /* TransferOut */: {
|
39244
39176
|
const transferOutReceipt = {
|
39245
39177
|
type: ReceiptType.TransferOut,
|
39246
|
-
from: hexOrZero(receipt.id
|
39247
|
-
to: hexOrZero(receipt.toAddress || receipt.to),
|
39178
|
+
from: hexOrZero(receipt.contract?.id),
|
39179
|
+
to: hexOrZero(receipt.toAddress || receipt.to?.id),
|
39248
39180
|
amount: bn(receipt.amount),
|
39249
39181
|
assetId: hexOrZero(receipt.assetId),
|
39250
39182
|
pc: bn(receipt.pc),
|
@@ -39287,7 +39219,7 @@ Thrown error: ${e}`
|
|
39287
39219
|
return receiptMessageOut;
|
39288
39220
|
}
|
39289
39221
|
case "MINT" /* Mint */: {
|
39290
|
-
const contractId = hexOrZero(receipt.id
|
39222
|
+
const contractId = hexOrZero(receipt.contract?.id);
|
39291
39223
|
const subId = hexOrZero(receipt.subId);
|
39292
39224
|
const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
|
39293
39225
|
const mintReceipt = {
|
@@ -39302,7 +39234,7 @@ Thrown error: ${e}`
|
|
39302
39234
|
return mintReceipt;
|
39303
39235
|
}
|
39304
39236
|
case "BURN" /* Burn */: {
|
39305
|
-
const contractId = hexOrZero(receipt.id
|
39237
|
+
const contractId = hexOrZero(receipt.contract?.id);
|
39306
39238
|
const subId = hexOrZero(receipt.subId);
|
39307
39239
|
const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
|
39308
39240
|
const burnReceipt = {
|
@@ -39383,6 +39315,7 @@ Thrown error: ${e}`
|
|
39383
39315
|
};
|
39384
39316
|
|
39385
39317
|
// src/providers/utils/gas.ts
|
39318
|
+
var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
|
39386
39319
|
var getGasUsedFromReceipts = (receipts) => {
|
39387
39320
|
const scriptResult = receipts.filter(
|
39388
39321
|
(receipt) => receipt.type === ReceiptType.ScriptResult
|
@@ -39403,28 +39336,18 @@ Thrown error: ${e}`
|
|
39403
39336
|
}
|
39404
39337
|
function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
39405
39338
|
const witnessCache = [];
|
39406
|
-
const
|
39407
|
-
const isCoinOrMessage = "owner" in input || "sender" in input;
|
39408
|
-
if (isCoinOrMessage) {
|
39409
|
-
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
39410
|
-
return true;
|
39411
|
-
}
|
39412
|
-
if (!witnessCache.includes(input.witnessIndex)) {
|
39413
|
-
witnessCache.push(input.witnessIndex);
|
39414
|
-
return true;
|
39415
|
-
}
|
39416
|
-
}
|
39417
|
-
return false;
|
39418
|
-
});
|
39419
|
-
const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
|
39420
|
-
const totalGas = chargeableInputs.reduce((total, input) => {
|
39339
|
+
const totalGas = inputs.reduce((total, input) => {
|
39421
39340
|
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
39422
39341
|
return total.add(
|
39423
|
-
|
39342
|
+
resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify(input.predicate).length, gasCosts.contractRoot)).add(bn(input.predicateGasUsed))
|
39424
39343
|
);
|
39425
39344
|
}
|
39426
|
-
|
39427
|
-
|
39345
|
+
if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
|
39346
|
+
witnessCache.push(input.witnessIndex);
|
39347
|
+
return total.add(gasCosts.ecr1);
|
39348
|
+
}
|
39349
|
+
return total;
|
39350
|
+
}, bn());
|
39428
39351
|
return totalGas;
|
39429
39352
|
}
|
39430
39353
|
function getMinGas(params) {
|
@@ -39436,20 +39359,12 @@ Thrown error: ${e}`
|
|
39436
39359
|
return minGas;
|
39437
39360
|
}
|
39438
39361
|
function getMaxGas(params) {
|
39439
|
-
const {
|
39440
|
-
gasPerByte,
|
39441
|
-
witnessesLength,
|
39442
|
-
witnessLimit,
|
39443
|
-
minGas,
|
39444
|
-
gasLimit = bn(0),
|
39445
|
-
maxGasPerTx
|
39446
|
-
} = params;
|
39362
|
+
const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = bn(0) } = params;
|
39447
39363
|
let remainingAllowedWitnessGas = bn(0);
|
39448
39364
|
if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
|
39449
39365
|
remainingAllowedWitnessGas = bn(witnessLimit).sub(witnessesLength).mul(gasPerByte);
|
39450
39366
|
}
|
39451
|
-
|
39452
|
-
return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
|
39367
|
+
return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
|
39453
39368
|
}
|
39454
39369
|
function calculateMetadataGasForTxCreate({
|
39455
39370
|
gasCosts,
|
@@ -39471,10 +39386,6 @@ Thrown error: ${e}`
|
|
39471
39386
|
}) {
|
39472
39387
|
return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
39473
39388
|
}
|
39474
|
-
var calculateGasFee = (params) => {
|
39475
|
-
const { gas, gasPrice, priceFactor, tip } = params;
|
39476
|
-
return gas.mul(gasPrice).div(priceFactor).add(tip);
|
39477
|
-
};
|
39478
39389
|
|
39479
39390
|
// src/providers/utils/json.ts
|
39480
39391
|
function normalize2(object) {
|
@@ -39616,7 +39527,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39616
39527
|
// src/providers/transaction-request/transaction-request.ts
|
39617
39528
|
var BaseTransactionRequest = class {
|
39618
39529
|
/** Gas price for transaction */
|
39619
|
-
|
39530
|
+
gasPrice;
|
39620
39531
|
/** Block until which tx cannot be included */
|
39621
39532
|
maturity;
|
39622
39533
|
/** The maximum fee payable by this transaction using BASE_ASSET. */
|
@@ -39629,34 +39540,38 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39629
39540
|
outputs = [];
|
39630
39541
|
/** List of witnesses */
|
39631
39542
|
witnesses = [];
|
39543
|
+
/** Base asset ID - should be fetched from the chain */
|
39544
|
+
baseAssetId;
|
39632
39545
|
/**
|
39633
39546
|
* Constructor for initializing a base transaction request.
|
39634
39547
|
*
|
39635
39548
|
* @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
|
39636
39549
|
*/
|
39637
39550
|
constructor({
|
39638
|
-
|
39551
|
+
gasPrice,
|
39639
39552
|
maturity,
|
39640
39553
|
maxFee,
|
39641
39554
|
witnessLimit,
|
39642
39555
|
inputs,
|
39643
39556
|
outputs,
|
39644
|
-
witnesses
|
39645
|
-
|
39646
|
-
|
39557
|
+
witnesses,
|
39558
|
+
baseAssetId
|
39559
|
+
}) {
|
39560
|
+
this.gasPrice = bn(gasPrice);
|
39647
39561
|
this.maturity = maturity ?? 0;
|
39648
39562
|
this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
|
39649
39563
|
this.maxFee = maxFee ? bn(maxFee) : void 0;
|
39650
39564
|
this.inputs = inputs ?? [];
|
39651
39565
|
this.outputs = outputs ?? [];
|
39652
39566
|
this.witnesses = witnesses ?? [];
|
39567
|
+
this.baseAssetId = baseAssetId;
|
39653
39568
|
}
|
39654
39569
|
static getPolicyMeta(req) {
|
39655
39570
|
let policyTypes = 0;
|
39656
39571
|
const policies = [];
|
39657
|
-
if (req.
|
39658
|
-
policyTypes += PolicyType.
|
39659
|
-
policies.push({ data: req.
|
39572
|
+
if (req.gasPrice) {
|
39573
|
+
policyTypes += PolicyType.GasPrice;
|
39574
|
+
policies.push({ data: req.gasPrice, type: PolicyType.GasPrice });
|
39660
39575
|
}
|
39661
39576
|
if (req.witnessLimit) {
|
39662
39577
|
policyTypes += PolicyType.WitnessLimit;
|
@@ -39843,10 +39758,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39843
39758
|
* @param predicate - Predicate bytes.
|
39844
39759
|
* @param predicateData - Predicate data bytes.
|
39845
39760
|
*/
|
39846
|
-
addCoinInput(coin) {
|
39761
|
+
addCoinInput(coin, predicate) {
|
39847
39762
|
const { assetId, owner, amount } = coin;
|
39848
39763
|
let witnessIndex;
|
39849
|
-
if (
|
39764
|
+
if (predicate) {
|
39850
39765
|
witnessIndex = 0;
|
39851
39766
|
} else {
|
39852
39767
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
|
@@ -39861,7 +39776,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39861
39776
|
amount,
|
39862
39777
|
assetId,
|
39863
39778
|
txPointer: "0x00000000000000000000000000000000",
|
39864
|
-
witnessIndex
|
39779
|
+
witnessIndex,
|
39780
|
+
predicate: predicate?.bytes
|
39865
39781
|
};
|
39866
39782
|
this.pushInput(input);
|
39867
39783
|
this.addChangeOutput(owner, assetId);
|
@@ -39872,13 +39788,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39872
39788
|
*
|
39873
39789
|
* @param message - Message resource.
|
39874
39790
|
* @param predicate - Predicate bytes.
|
39875
|
-
* @param predicateData - Predicate data bytes.
|
39876
39791
|
*/
|
39877
|
-
addMessageInput(message) {
|
39792
|
+
addMessageInput(message, predicate) {
|
39878
39793
|
const { recipient, sender, amount } = message;
|
39879
|
-
const assetId = BaseAssetId;
|
39880
39794
|
let witnessIndex;
|
39881
|
-
if (
|
39795
|
+
if (predicate) {
|
39882
39796
|
witnessIndex = 0;
|
39883
39797
|
} else {
|
39884
39798
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
|
@@ -39892,10 +39806,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39892
39806
|
sender: sender.toB256(),
|
39893
39807
|
recipient: recipient.toB256(),
|
39894
39808
|
amount,
|
39895
|
-
witnessIndex
|
39809
|
+
witnessIndex,
|
39810
|
+
predicate: predicate?.bytes
|
39896
39811
|
};
|
39897
39812
|
this.pushInput(input);
|
39898
|
-
this.addChangeOutput(recipient,
|
39813
|
+
this.addChangeOutput(recipient, this.baseAssetId);
|
39899
39814
|
}
|
39900
39815
|
/**
|
39901
39816
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -39923,6 +39838,32 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39923
39838
|
resources.forEach((resource) => this.addResource(resource));
|
39924
39839
|
return this;
|
39925
39840
|
}
|
39841
|
+
/**
|
39842
|
+
* Adds multiple resources to the transaction by adding coin/message inputs and change
|
39843
|
+
* outputs from the related assetIds.
|
39844
|
+
*
|
39845
|
+
* @param resources - The resources to add.
|
39846
|
+
* @returns This transaction.
|
39847
|
+
*/
|
39848
|
+
addPredicateResource(resource, predicate) {
|
39849
|
+
if (isCoin(resource)) {
|
39850
|
+
this.addCoinInput(resource, predicate);
|
39851
|
+
} else {
|
39852
|
+
this.addMessageInput(resource, predicate);
|
39853
|
+
}
|
39854
|
+
return this;
|
39855
|
+
}
|
39856
|
+
/**
|
39857
|
+
* Adds multiple predicate coin/message inputs to the transaction and change outputs
|
39858
|
+
* from the related assetIds.
|
39859
|
+
*
|
39860
|
+
* @param resources - The resources to add.
|
39861
|
+
* @returns This transaction.
|
39862
|
+
*/
|
39863
|
+
addPredicateResources(resources, predicate) {
|
39864
|
+
resources.forEach((resource) => this.addPredicateResource(resource, predicate));
|
39865
|
+
return this;
|
39866
|
+
}
|
39926
39867
|
/**
|
39927
39868
|
* Adds a coin output to the transaction.
|
39928
39869
|
*
|
@@ -39930,12 +39871,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39930
39871
|
* @param amount - Amount of coin.
|
39931
39872
|
* @param assetId - Asset ID of coin.
|
39932
39873
|
*/
|
39933
|
-
addCoinOutput(to, amount, assetId
|
39874
|
+
addCoinOutput(to, amount, assetId) {
|
39934
39875
|
this.pushOutput({
|
39935
39876
|
type: OutputType.Coin,
|
39936
39877
|
to: addressify(to).toB256(),
|
39937
39878
|
amount,
|
39938
|
-
assetId
|
39879
|
+
assetId: assetId ?? this.baseAssetId
|
39939
39880
|
});
|
39940
39881
|
return this;
|
39941
39882
|
}
|
@@ -39962,7 +39903,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39962
39903
|
* @param to - Address of the owner.
|
39963
39904
|
* @param assetId - Asset ID of coin.
|
39964
39905
|
*/
|
39965
|
-
addChangeOutput(to, assetId
|
39906
|
+
addChangeOutput(to, assetId) {
|
39966
39907
|
const changeOutput = this.getChangeOutputs().find(
|
39967
39908
|
(output3) => hexlify(output3.assetId) === assetId
|
39968
39909
|
);
|
@@ -39970,7 +39911,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39970
39911
|
this.pushOutput({
|
39971
39912
|
type: OutputType.Change,
|
39972
39913
|
to: addressify(to).toB256(),
|
39973
|
-
assetId
|
39914
|
+
assetId: assetId ?? this.baseAssetId
|
39974
39915
|
});
|
39975
39916
|
}
|
39976
39917
|
}
|
@@ -40002,7 +39943,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40002
39943
|
}
|
40003
39944
|
calculateMaxGas(chainInfo, minGas) {
|
40004
39945
|
const { consensusParameters } = chainInfo;
|
40005
|
-
const { gasPerByte
|
39946
|
+
const { gasPerByte } = consensusParameters;
|
40006
39947
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
40007
39948
|
(acc, wit) => acc + wit.dataLength,
|
40008
39949
|
0
|
@@ -40011,8 +39952,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40011
39952
|
gasPerByte,
|
40012
39953
|
minGas,
|
40013
39954
|
witnessesLength,
|
40014
|
-
witnessLimit: this.witnessLimit
|
40015
|
-
maxGasPerTx
|
39955
|
+
witnessLimit: this.witnessLimit
|
40016
39956
|
});
|
40017
39957
|
}
|
40018
39958
|
/**
|
@@ -40030,27 +39970,24 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40030
39970
|
});
|
40031
39971
|
const updateAssetInput = (assetId, quantity) => {
|
40032
39972
|
const assetInput = findAssetInput(assetId);
|
40033
|
-
let usedQuantity = quantity;
|
40034
|
-
if (assetId === BaseAssetId) {
|
40035
|
-
usedQuantity = bn("1000000000000000000");
|
40036
|
-
}
|
40037
39973
|
if (assetInput && "assetId" in assetInput) {
|
40038
39974
|
assetInput.id = hexlify(randomBytes22(UTXO_ID_LEN));
|
40039
|
-
assetInput.amount =
|
39975
|
+
assetInput.amount = quantity;
|
40040
39976
|
} else {
|
40041
39977
|
this.addResources([
|
40042
39978
|
{
|
40043
39979
|
id: hexlify(randomBytes22(UTXO_ID_LEN)),
|
40044
|
-
amount:
|
39980
|
+
amount: quantity,
|
40045
39981
|
assetId,
|
40046
39982
|
owner: resourcesOwner || Address.fromRandom(),
|
39983
|
+
maturity: 0,
|
40047
39984
|
blockCreated: bn(1),
|
40048
39985
|
txCreatedIdx: bn(1)
|
40049
39986
|
}
|
40050
39987
|
]);
|
40051
39988
|
}
|
40052
39989
|
};
|
40053
|
-
updateAssetInput(
|
39990
|
+
updateAssetInput(this.baseAssetId, bn(1e11));
|
40054
39991
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
40055
39992
|
}
|
40056
39993
|
/**
|
@@ -40075,7 +40012,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40075
40012
|
toJSON() {
|
40076
40013
|
return normalizeJSON(this);
|
40077
40014
|
}
|
40078
|
-
|
40015
|
+
updatePredicateInputs(inputs) {
|
40079
40016
|
this.inputs.forEach((i) => {
|
40080
40017
|
let correspondingInput;
|
40081
40018
|
switch (i.type) {
|
@@ -40097,15 +40034,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40097
40034
|
}
|
40098
40035
|
});
|
40099
40036
|
}
|
40100
|
-
shiftPredicateData() {
|
40101
|
-
this.inputs.forEach((input) => {
|
40102
|
-
if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
|
40103
|
-
input.predicateData = input.paddPredicateData(
|
40104
|
-
BaseTransactionRequest.getPolicyMeta(this).policies.length
|
40105
|
-
);
|
40106
|
-
}
|
40107
|
-
});
|
40108
|
-
}
|
40109
40037
|
};
|
40110
40038
|
|
40111
40039
|
// src/providers/transaction-request/hash-transaction.ts
|
@@ -40216,12 +40144,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40216
40144
|
*
|
40217
40145
|
* @param createTransactionRequestLike - The initial values for the instance
|
40218
40146
|
*/
|
40219
|
-
constructor({
|
40220
|
-
bytecodeWitnessIndex,
|
40221
|
-
salt,
|
40222
|
-
storageSlots,
|
40223
|
-
...rest
|
40224
|
-
} = {}) {
|
40147
|
+
constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
|
40225
40148
|
super(rest);
|
40226
40149
|
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
40227
40150
|
this.salt = hexlify(salt ?? ZeroBytes32);
|
@@ -40239,8 +40162,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40239
40162
|
return {
|
40240
40163
|
type: TransactionType.Create,
|
40241
40164
|
...baseTransaction,
|
40165
|
+
bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
|
40242
40166
|
bytecodeWitnessIndex,
|
40243
|
-
storageSlotsCount:
|
40167
|
+
storageSlotsCount: storageSlots.length,
|
40244
40168
|
salt: this.salt ? hexlify(this.salt) : ZeroBytes32,
|
40245
40169
|
storageSlots
|
40246
40170
|
};
|
@@ -40335,7 +40259,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40335
40259
|
*
|
40336
40260
|
* @param scriptTransactionRequestLike - The initial values for the instance.
|
40337
40261
|
*/
|
40338
|
-
constructor({ script, scriptData, gasLimit, ...rest }
|
40262
|
+
constructor({ script, scriptData, gasLimit, ...rest }) {
|
40339
40263
|
super(rest);
|
40340
40264
|
this.gasLimit = bn(gasLimit);
|
40341
40265
|
this.script = arrayify(script ?? returnZeroScript.bytes);
|
@@ -40354,8 +40278,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40354
40278
|
type: TransactionType.Script,
|
40355
40279
|
scriptGasLimit: this.gasLimit,
|
40356
40280
|
...super.getBaseTransaction(),
|
40357
|
-
scriptLength:
|
40358
|
-
scriptDataLength:
|
40281
|
+
scriptLength: script.length,
|
40282
|
+
scriptDataLength: scriptData.length,
|
40359
40283
|
receiptsRoot: ZeroBytes32,
|
40360
40284
|
script: hexlify(script),
|
40361
40285
|
scriptData: hexlify(scriptData)
|
@@ -40419,7 +40343,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40419
40343
|
}
|
40420
40344
|
calculateMaxGas(chainInfo, minGas) {
|
40421
40345
|
const { consensusParameters } = chainInfo;
|
40422
|
-
const { gasPerByte
|
40346
|
+
const { gasPerByte } = consensusParameters;
|
40423
40347
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
40424
40348
|
(acc, wit) => acc + wit.dataLength,
|
40425
40349
|
0
|
@@ -40429,8 +40353,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40429
40353
|
minGas,
|
40430
40354
|
witnessesLength,
|
40431
40355
|
witnessLimit: this.witnessLimit,
|
40432
|
-
gasLimit: this.gasLimit
|
40433
|
-
maxGasPerTx
|
40356
|
+
gasLimit: this.gasLimit
|
40434
40357
|
});
|
40435
40358
|
}
|
40436
40359
|
/**
|
@@ -40503,29 +40426,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40503
40426
|
}
|
40504
40427
|
}
|
40505
40428
|
};
|
40506
|
-
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
40507
|
-
(acc, input) => {
|
40508
|
-
if (input.type === InputType.Coin && input.owner === owner) {
|
40509
|
-
acc.utxos.push(input.id);
|
40510
|
-
}
|
40511
|
-
if (input.type === InputType.Message && input.recipient === owner) {
|
40512
|
-
acc.messages.push(input.nonce);
|
40513
|
-
}
|
40514
|
-
return acc;
|
40515
|
-
},
|
40516
|
-
{
|
40517
|
-
utxos: [],
|
40518
|
-
messages: []
|
40519
|
-
}
|
40520
|
-
);
|
40521
40429
|
|
40522
40430
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
40523
40431
|
var calculateTransactionFee = (params) => {
|
40524
40432
|
const {
|
40525
|
-
|
40433
|
+
gasUsed,
|
40526
40434
|
rawPayload,
|
40527
|
-
|
40528
|
-
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
40435
|
+
consensusParameters: { gasCosts, feeParams }
|
40529
40436
|
} = params;
|
40530
40437
|
const gasPerByte = bn(feeParams.gasPerByte);
|
40531
40438
|
const gasPriceFactor = bn(feeParams.gasPriceFactor);
|
@@ -40535,7 +40442,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40535
40442
|
return {
|
40536
40443
|
fee: bn(0),
|
40537
40444
|
minFee: bn(0),
|
40538
|
-
maxFee: bn(0)
|
40445
|
+
maxFee: bn(0),
|
40446
|
+
feeFromGasUsed: bn(0)
|
40539
40447
|
};
|
40540
40448
|
}
|
40541
40449
|
const { type: type3, witnesses, inputs, policies } = transaction;
|
@@ -40567,6 +40475,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40567
40475
|
metadataGas,
|
40568
40476
|
txBytesSize: transactionBytes.length
|
40569
40477
|
});
|
40478
|
+
const gasPrice = bn(policies.find((policy) => policy.type === PolicyType.GasPrice)?.data);
|
40570
40479
|
const witnessLimit = policies.find((policy) => policy.type === PolicyType.WitnessLimit)?.data;
|
40571
40480
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
40572
40481
|
const maxGas = getMaxGas({
|
@@ -40574,25 +40483,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40574
40483
|
minGas,
|
40575
40484
|
witnessesLength,
|
40576
40485
|
gasLimit,
|
40577
|
-
witnessLimit
|
40578
|
-
maxGasPerTx
|
40579
|
-
});
|
40580
|
-
const minFee = calculateGasFee({
|
40581
|
-
gasPrice,
|
40582
|
-
gas: minGas,
|
40583
|
-
priceFactor: gasPriceFactor,
|
40584
|
-
tip
|
40585
|
-
});
|
40586
|
-
const maxFee = calculateGasFee({
|
40587
|
-
gasPrice,
|
40588
|
-
gas: maxGas,
|
40589
|
-
priceFactor: gasPriceFactor,
|
40590
|
-
tip
|
40486
|
+
witnessLimit
|
40591
40487
|
});
|
40488
|
+
const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
|
40489
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
|
40490
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
|
40491
|
+
const fee = minFee.add(feeFromGasUsed);
|
40592
40492
|
return {
|
40493
|
+
fee,
|
40593
40494
|
minFee,
|
40594
40495
|
maxFee,
|
40595
|
-
|
40496
|
+
feeFromGasUsed
|
40596
40497
|
};
|
40597
40498
|
};
|
40598
40499
|
|
@@ -41193,9 +41094,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41193
41094
|
gqlTransactionStatus,
|
41194
41095
|
abiMap = {},
|
41195
41096
|
maxInputs,
|
41196
|
-
gasCosts
|
41197
|
-
maxGasPerTx,
|
41198
|
-
gasPrice
|
41097
|
+
gasCosts
|
41199
41098
|
} = params;
|
41200
41099
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
41201
41100
|
const rawPayload = hexlify(transactionBytes);
|
@@ -41209,14 +41108,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41209
41108
|
maxInputs
|
41210
41109
|
});
|
41211
41110
|
const typeName = getTransactionTypeName(transaction.type);
|
41212
|
-
const tip = bn(transaction.policies?.find((policy) => policy.type === PolicyType.Tip)?.data);
|
41213
41111
|
const { fee } = calculateTransactionFee({
|
41214
|
-
|
41112
|
+
gasUsed,
|
41215
41113
|
rawPayload,
|
41216
|
-
tip,
|
41217
41114
|
consensusParameters: {
|
41218
41115
|
gasCosts,
|
41219
|
-
maxGasPerTx,
|
41220
41116
|
feeParams: {
|
41221
41117
|
gasPerByte,
|
41222
41118
|
gasPriceFactor
|
@@ -41352,13 +41248,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41352
41248
|
const decodedTransaction = this.decodeTransaction(
|
41353
41249
|
transaction
|
41354
41250
|
);
|
41355
|
-
|
41356
|
-
|
41357
|
-
txReceipts = transaction.status.receipts;
|
41358
|
-
}
|
41359
|
-
const receipts = txReceipts.map(processGqlReceipt) || [];
|
41360
|
-
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
41361
|
-
const gasPrice = await this.provider.getLatestGasPrice();
|
41251
|
+
const receipts = transaction.receipts?.map(processGqlReceipt) || [];
|
41252
|
+
const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
|
41362
41253
|
const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
|
41363
41254
|
const transactionSummary = assembleTransactionSummary({
|
41364
41255
|
id: this.id,
|
@@ -41370,9 +41261,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41370
41261
|
gasPriceFactor,
|
41371
41262
|
abiMap: contractsAbiMap,
|
41372
41263
|
maxInputs,
|
41373
|
-
gasCosts
|
41374
|
-
maxGasPerTx,
|
41375
|
-
gasPrice
|
41264
|
+
gasCosts
|
41376
41265
|
});
|
41377
41266
|
return transactionSummary;
|
41378
41267
|
}
|
@@ -41516,12 +41405,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41516
41405
|
gasPerByte: bn(feeParams.gasPerByte),
|
41517
41406
|
maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
|
41518
41407
|
chainId: bn(consensusParameters.chainId),
|
41408
|
+
baseAssetId: consensusParameters.baseAssetId,
|
41519
41409
|
gasCosts
|
41520
41410
|
},
|
41521
41411
|
gasCosts,
|
41522
41412
|
latestBlock: {
|
41523
41413
|
id: latestBlock.id,
|
41524
|
-
height: bn(latestBlock.height),
|
41414
|
+
height: bn(latestBlock.header.height),
|
41525
41415
|
time: latestBlock.header.time,
|
41526
41416
|
transactions: latestBlock.transactions.map((i) => ({
|
41527
41417
|
id: i.id
|
@@ -41615,8 +41505,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41615
41505
|
* Returns some helpful parameters related to gas fees.
|
41616
41506
|
*/
|
41617
41507
|
getGasConfig() {
|
41508
|
+
const { minGasPrice } = this.getNode();
|
41618
41509
|
const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
|
41619
41510
|
return {
|
41511
|
+
minGasPrice,
|
41620
41512
|
maxGasPerTx,
|
41621
41513
|
maxGasPerPredicate,
|
41622
41514
|
gasPriceFactor,
|
@@ -41714,7 +41606,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41714
41606
|
*/
|
41715
41607
|
async getBlockNumber() {
|
41716
41608
|
const { chain } = await this.operations.getChain();
|
41717
|
-
return bn(chain.latestBlock.height, 10);
|
41609
|
+
return bn(chain.latestBlock.header.height, 10);
|
41718
41610
|
}
|
41719
41611
|
/**
|
41720
41612
|
* Returns the chain information.
|
@@ -41726,9 +41618,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41726
41618
|
const processedNodeInfo = {
|
41727
41619
|
maxDepth: bn(nodeInfo.maxDepth),
|
41728
41620
|
maxTx: bn(nodeInfo.maxTx),
|
41621
|
+
minGasPrice: bn(nodeInfo.minGasPrice),
|
41729
41622
|
nodeVersion: nodeInfo.nodeVersion,
|
41730
41623
|
utxoValidation: nodeInfo.utxoValidation,
|
41731
|
-
vmBacktrace: nodeInfo.vmBacktrace
|
41624
|
+
vmBacktrace: nodeInfo.vmBacktrace,
|
41625
|
+
peers: nodeInfo.peers
|
41732
41626
|
};
|
41733
41627
|
_Provider.nodeInfoCache[this.url] = processedNodeInfo;
|
41734
41628
|
return processedNodeInfo;
|
@@ -41754,6 +41648,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41754
41648
|
} = this.getChain();
|
41755
41649
|
return chainId.toNumber();
|
41756
41650
|
}
|
41651
|
+
/**
|
41652
|
+
* Returns the base asset ID
|
41653
|
+
*
|
41654
|
+
* @returns A promise that resolves to the base asset ID
|
41655
|
+
*/
|
41656
|
+
getBaseAssetId() {
|
41657
|
+
const {
|
41658
|
+
consensusParameters: { baseAssetId }
|
41659
|
+
} = this.getChain();
|
41660
|
+
return baseAssetId;
|
41661
|
+
}
|
41757
41662
|
/**
|
41758
41663
|
* Submits a transaction to the chain to be executed.
|
41759
41664
|
*
|
@@ -41814,13 +41719,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41814
41719
|
return this.estimateTxDependencies(transactionRequest);
|
41815
41720
|
}
|
41816
41721
|
const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
|
41817
|
-
const { dryRun:
|
41818
|
-
|
41722
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
41723
|
+
encodedTransaction,
|
41819
41724
|
utxoValidation: utxoValidation || false
|
41820
41725
|
});
|
41821
|
-
const
|
41822
|
-
|
41823
|
-
|
41726
|
+
const receipts = gqlReceipts.map(processGqlReceipt);
|
41727
|
+
return {
|
41728
|
+
receipts
|
41729
|
+
};
|
41824
41730
|
}
|
41825
41731
|
/**
|
41826
41732
|
* Verifies whether enough gas is available to complete transaction.
|
@@ -41859,6 +41765,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41859
41765
|
* If there are missing variable outputs,
|
41860
41766
|
* `addVariableOutputs` is called on the transaction.
|
41861
41767
|
*
|
41768
|
+
* @privateRemarks
|
41769
|
+
* TODO: Investigate support for missing contract IDs
|
41770
|
+
* TODO: Add support for missing output messages
|
41862
41771
|
*
|
41863
41772
|
* @param transactionRequest - The transaction request object.
|
41864
41773
|
* @returns A promise.
|
@@ -41871,19 +41780,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41871
41780
|
missingContractIds: []
|
41872
41781
|
};
|
41873
41782
|
}
|
41783
|
+
await this.estimatePredicates(transactionRequest);
|
41874
41784
|
let receipts = [];
|
41875
41785
|
const missingContractIds = [];
|
41876
41786
|
let outputVariables = 0;
|
41877
|
-
let dryrunStatus;
|
41878
41787
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
41879
|
-
const {
|
41880
|
-
|
41881
|
-
} = await this.operations.dryRun({
|
41882
|
-
encodedTransactions: [hexlify(transactionRequest.toTransactionBytes())],
|
41788
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
41789
|
+
encodedTransaction: hexlify(transactionRequest.toTransactionBytes()),
|
41883
41790
|
utxoValidation: false
|
41884
41791
|
});
|
41885
|
-
receipts =
|
41886
|
-
dryrunStatus = status;
|
41792
|
+
receipts = gqlReceipts.map(processGqlReceipt);
|
41887
41793
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
41888
41794
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
41889
41795
|
if (hasMissingOutputs) {
|
@@ -41893,10 +41799,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41893
41799
|
transactionRequest.addContractInputAndOutput(Address.fromString(contractId));
|
41894
41800
|
missingContractIds.push(contractId);
|
41895
41801
|
});
|
41896
|
-
const { maxFee } = await this.estimateTxGasAndFee({
|
41897
|
-
transactionRequest
|
41898
|
-
});
|
41899
|
-
transactionRequest.maxFee = maxFee;
|
41900
41802
|
} else {
|
41901
41803
|
break;
|
41902
41804
|
}
|
@@ -41904,139 +41806,37 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41904
41806
|
return {
|
41905
41807
|
receipts,
|
41906
41808
|
outputVariables,
|
41907
|
-
missingContractIds
|
41908
|
-
dryrunStatus
|
41809
|
+
missingContractIds
|
41909
41810
|
};
|
41910
41811
|
}
|
41911
|
-
/**
|
41912
|
-
* Dry runs multiple transactions and checks for missing dependencies in batches.
|
41913
|
-
*
|
41914
|
-
* Transactions are dry run in batches. After each dry run, transactions requiring
|
41915
|
-
* further modifications are identified. The method iteratively updates these transactions
|
41916
|
-
* and performs subsequent dry runs until all dependencies for each transaction are satisfied.
|
41917
|
-
*
|
41918
|
-
* @param transactionRequests - Array of transaction request objects.
|
41919
|
-
* @returns A promise that resolves to an array of results for each transaction.
|
41920
|
-
*/
|
41921
|
-
async estimateMultipleTxDependencies(transactionRequests) {
|
41922
|
-
const results = transactionRequests.map(() => ({
|
41923
|
-
receipts: [],
|
41924
|
-
outputVariables: 0,
|
41925
|
-
missingContractIds: [],
|
41926
|
-
dryrunStatus: void 0
|
41927
|
-
}));
|
41928
|
-
const allRequests = clone_default(transactionRequests);
|
41929
|
-
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
41930
|
-
allRequests.forEach((req, index) => {
|
41931
|
-
if (req.type === TransactionType.Script) {
|
41932
|
-
serializedTransactionsMap.set(index, hexlify(req.toTransactionBytes()));
|
41933
|
-
}
|
41934
|
-
});
|
41935
|
-
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
41936
|
-
let attempt = 0;
|
41937
|
-
while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
|
41938
|
-
const encodedTransactions = transactionsToProcess.map(
|
41939
|
-
(index) => serializedTransactionsMap.get(index)
|
41940
|
-
);
|
41941
|
-
const dryRunResults = await this.operations.dryRun({
|
41942
|
-
encodedTransactions,
|
41943
|
-
utxoValidation: false
|
41944
|
-
});
|
41945
|
-
const nextRoundTransactions = [];
|
41946
|
-
for (let i = 0; i < dryRunResults.dryRun.length; i++) {
|
41947
|
-
const currentResultIndex = transactionsToProcess[i];
|
41948
|
-
const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
|
41949
|
-
results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
|
41950
|
-
results[currentResultIndex].dryrunStatus = status;
|
41951
|
-
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
|
41952
|
-
results[currentResultIndex].receipts
|
41953
|
-
);
|
41954
|
-
const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
|
41955
|
-
const requestToProcess = allRequests[currentResultIndex];
|
41956
|
-
if (hasMissingOutputs && requestToProcess?.type === TransactionType.Script) {
|
41957
|
-
results[currentResultIndex].outputVariables += missingOutputVariables.length;
|
41958
|
-
requestToProcess.addVariableOutputs(missingOutputVariables.length);
|
41959
|
-
missingOutputContractIds.forEach(({ contractId }) => {
|
41960
|
-
requestToProcess.addContractInputAndOutput(Address.fromString(contractId));
|
41961
|
-
results[currentResultIndex].missingContractIds.push(contractId);
|
41962
|
-
});
|
41963
|
-
const { maxFee } = await this.estimateTxGasAndFee({
|
41964
|
-
transactionRequest: requestToProcess
|
41965
|
-
});
|
41966
|
-
requestToProcess.maxFee = maxFee;
|
41967
|
-
serializedTransactionsMap.set(
|
41968
|
-
currentResultIndex,
|
41969
|
-
hexlify(requestToProcess.toTransactionBytes())
|
41970
|
-
);
|
41971
|
-
nextRoundTransactions.push(currentResultIndex);
|
41972
|
-
allRequests[currentResultIndex] = requestToProcess;
|
41973
|
-
}
|
41974
|
-
}
|
41975
|
-
transactionsToProcess = nextRoundTransactions;
|
41976
|
-
attempt += 1;
|
41977
|
-
}
|
41978
|
-
return results;
|
41979
|
-
}
|
41980
|
-
async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
|
41981
|
-
if (estimateTxDependencies) {
|
41982
|
-
return this.estimateMultipleTxDependencies(transactionRequests);
|
41983
|
-
}
|
41984
|
-
const encodedTransactions = transactionRequests.map((tx) => hexlify(tx.toTransactionBytes()));
|
41985
|
-
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
41986
|
-
encodedTransactions,
|
41987
|
-
utxoValidation: utxoValidation || false
|
41988
|
-
});
|
41989
|
-
const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
|
41990
|
-
const receipts = rawReceipts.map(processGqlReceipt);
|
41991
|
-
return { receipts, dryrunStatus: status };
|
41992
|
-
});
|
41993
|
-
return results;
|
41994
|
-
}
|
41995
41812
|
/**
|
41996
41813
|
* Estimates the transaction gas and fee based on the provided transaction request.
|
41997
41814
|
* @param transactionRequest - The transaction request object.
|
41998
41815
|
* @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
|
41999
41816
|
*/
|
42000
|
-
|
41817
|
+
estimateTxGasAndFee(params) {
|
42001
41818
|
const { transactionRequest } = params;
|
42002
|
-
|
41819
|
+
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
42003
41820
|
const chainInfo = this.getChain();
|
42004
|
-
const
|
41821
|
+
const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
|
41822
|
+
transactionRequest.gasPrice = gasPrice;
|
42005
41823
|
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
42006
|
-
|
42007
|
-
gasPrice = await this.estimateGasPrice(10);
|
42008
|
-
}
|
42009
|
-
const minFee = calculateGasFee({
|
42010
|
-
gasPrice: bn(gasPrice),
|
42011
|
-
gas: minGas,
|
42012
|
-
priceFactor: gasPriceFactor,
|
42013
|
-
tip: transactionRequest.tip
|
42014
|
-
}).add(1);
|
42015
|
-
let gasLimit = bn(0);
|
41824
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
42016
41825
|
if (transactionRequest.type === TransactionType.Script) {
|
42017
|
-
gasLimit = transactionRequest.gasLimit;
|
42018
41826
|
if (transactionRequest.gasLimit.eq(0)) {
|
42019
41827
|
transactionRequest.gasLimit = minGas;
|
42020
41828
|
transactionRequest.gasLimit = maxGasPerTx.sub(
|
42021
41829
|
transactionRequest.calculateMaxGas(chainInfo, minGas)
|
42022
41830
|
);
|
42023
|
-
gasLimit = transactionRequest.gasLimit;
|
42024
41831
|
}
|
42025
41832
|
}
|
42026
41833
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
42027
|
-
const maxFee =
|
42028
|
-
gasPrice: bn(gasPrice),
|
42029
|
-
gas: maxGas,
|
42030
|
-
priceFactor: gasPriceFactor,
|
42031
|
-
tip: transactionRequest.tip
|
42032
|
-
}).add(1);
|
41834
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
42033
41835
|
return {
|
42034
41836
|
minGas,
|
42035
41837
|
minFee,
|
42036
41838
|
maxGas,
|
42037
|
-
maxFee
|
42038
|
-
gasPrice,
|
42039
|
-
gasLimit
|
41839
|
+
maxFee
|
42040
41840
|
};
|
42041
41841
|
}
|
42042
41842
|
/**
|
@@ -42054,17 +41854,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42054
41854
|
if (estimateTxDependencies) {
|
42055
41855
|
return this.estimateTxDependencies(transactionRequest);
|
42056
41856
|
}
|
42057
|
-
const
|
42058
|
-
const { dryRun:
|
42059
|
-
|
41857
|
+
const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
|
41858
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
41859
|
+
encodedTransaction,
|
42060
41860
|
utxoValidation: true
|
42061
41861
|
});
|
42062
|
-
const
|
42063
|
-
|
42064
|
-
|
42065
|
-
|
42066
|
-
});
|
42067
|
-
return { receipts: callResult[0].receipts };
|
41862
|
+
const receipts = gqlReceipts.map(processGqlReceipt);
|
41863
|
+
return {
|
41864
|
+
receipts
|
41865
|
+
};
|
42068
41866
|
}
|
42069
41867
|
/**
|
42070
41868
|
* Returns a transaction cost to enable user
|
@@ -42081,79 +41879,77 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42081
41879
|
* @param tolerance - The tolerance to add on top of the gasUsed.
|
42082
41880
|
* @returns A promise that resolves to the transaction cost object.
|
42083
41881
|
*/
|
42084
|
-
async getTransactionCost(transactionRequestLike,
|
41882
|
+
async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
|
41883
|
+
estimateTxDependencies = true,
|
41884
|
+
estimatePredicates = true,
|
41885
|
+
resourcesOwner,
|
41886
|
+
signatureCallback
|
41887
|
+
} = {}) {
|
42085
41888
|
const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
|
41889
|
+
const { minGasPrice } = this.getGasConfig();
|
41890
|
+
const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
42086
41891
|
const isScriptTransaction = txRequestClone.type === TransactionType.Script;
|
42087
41892
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
42088
|
-
const allQuantities = mergeQuantities(coinOutputsQuantities,
|
41893
|
+
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
42089
41894
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
42090
|
-
txRequestClone.maxFee = bn(0);
|
42091
41895
|
if (isScriptTransaction) {
|
42092
41896
|
txRequestClone.gasLimit = bn(0);
|
42093
41897
|
}
|
42094
|
-
if (
|
42095
|
-
resourcesOwner
|
41898
|
+
if (estimatePredicates) {
|
41899
|
+
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
41900
|
+
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
41901
|
+
}
|
41902
|
+
await this.estimatePredicates(txRequestClone);
|
42096
41903
|
}
|
42097
|
-
const signedRequest = clone_default(txRequestClone);
|
42098
|
-
let addedSignatures = 0;
|
42099
41904
|
if (signatureCallback && isScriptTransaction) {
|
42100
|
-
|
42101
|
-
await signatureCallback(signedRequest);
|
42102
|
-
addedSignatures = signedRequest.witnesses.length - lengthBefore;
|
41905
|
+
await signatureCallback(txRequestClone);
|
42103
41906
|
}
|
42104
|
-
|
42105
|
-
|
42106
|
-
transactionRequest: signedRequest
|
41907
|
+
let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
41908
|
+
transactionRequest: txRequestClone
|
42107
41909
|
});
|
42108
41910
|
let receipts = [];
|
42109
41911
|
let missingContractIds = [];
|
42110
41912
|
let outputVariables = 0;
|
42111
41913
|
let gasUsed = bn(0);
|
42112
|
-
|
42113
|
-
|
42114
|
-
if (isScriptTransaction) {
|
42115
|
-
txRequestClone.gasLimit = gasLimit;
|
42116
|
-
if (signatureCallback) {
|
42117
|
-
await signatureCallback(txRequestClone);
|
42118
|
-
}
|
41914
|
+
if (isScriptTransaction && estimateTxDependencies) {
|
41915
|
+
txRequestClone.gasPrice = bn(0);
|
42119
41916
|
const result = await this.estimateTxDependencies(txRequestClone);
|
42120
41917
|
receipts = result.receipts;
|
42121
41918
|
outputVariables = result.outputVariables;
|
42122
41919
|
missingContractIds = result.missingContractIds;
|
42123
41920
|
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
42124
41921
|
txRequestClone.gasLimit = gasUsed;
|
42125
|
-
|
42126
|
-
|
42127
|
-
|
41922
|
+
txRequestClone.gasPrice = setGasPrice;
|
41923
|
+
({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
41924
|
+
transactionRequest: txRequestClone
|
42128
41925
|
}));
|
42129
41926
|
}
|
42130
41927
|
return {
|
42131
41928
|
requiredQuantities: allQuantities,
|
42132
41929
|
receipts,
|
42133
41930
|
gasUsed,
|
42134
|
-
|
41931
|
+
minGasPrice,
|
41932
|
+
gasPrice: setGasPrice,
|
42135
41933
|
minGas,
|
42136
41934
|
maxGas,
|
42137
41935
|
minFee,
|
42138
41936
|
maxFee,
|
41937
|
+
estimatedInputs: txRequestClone.inputs,
|
42139
41938
|
outputVariables,
|
42140
|
-
missingContractIds
|
42141
|
-
addedSignatures,
|
42142
|
-
estimatedPredicates: txRequestClone.inputs
|
41939
|
+
missingContractIds
|
42143
41940
|
};
|
42144
41941
|
}
|
42145
|
-
async getResourcesForTransaction(owner, transactionRequestLike,
|
41942
|
+
async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
|
42146
41943
|
const ownerAddress = Address.fromAddressOrString(owner);
|
42147
41944
|
const transactionRequest = transactionRequestify(clone_default(transactionRequestLike));
|
42148
|
-
const transactionCost = await this.getTransactionCost(transactionRequest,
|
42149
|
-
quantitiesToContract
|
42150
|
-
});
|
41945
|
+
const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
|
42151
41946
|
transactionRequest.addResources(
|
42152
41947
|
await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
|
42153
41948
|
);
|
42154
|
-
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
42155
|
-
|
42156
|
-
|
41949
|
+
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
41950
|
+
transactionRequest,
|
41951
|
+
forwardingQuantities
|
41952
|
+
);
|
42157
41953
|
const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
|
42158
41954
|
return {
|
42159
41955
|
resources,
|
@@ -42177,6 +41973,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42177
41973
|
assetId: coin.assetId,
|
42178
41974
|
amount: bn(coin.amount),
|
42179
41975
|
owner: Address.fromAddressOrString(coin.owner),
|
41976
|
+
maturity: bn(coin.maturity).toNumber(),
|
42180
41977
|
blockCreated: bn(coin.blockCreated),
|
42181
41978
|
txCreatedIdx: bn(coin.txCreatedIdx)
|
42182
41979
|
}));
|
@@ -42228,6 +42025,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42228
42025
|
amount: bn(coin.amount),
|
42229
42026
|
assetId: coin.assetId,
|
42230
42027
|
owner: Address.fromAddressOrString(coin.owner),
|
42028
|
+
maturity: bn(coin.maturity).toNumber(),
|
42231
42029
|
blockCreated: bn(coin.blockCreated),
|
42232
42030
|
txCreatedIdx: bn(coin.txCreatedIdx)
|
42233
42031
|
};
|
@@ -42260,7 +42058,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42260
42058
|
}
|
42261
42059
|
return {
|
42262
42060
|
id: block2.id,
|
42263
|
-
height: bn(block2.height),
|
42061
|
+
height: bn(block2.header.height),
|
42264
42062
|
time: block2.header.time,
|
42265
42063
|
transactionIds: block2.transactions.map((tx) => tx.id)
|
42266
42064
|
};
|
@@ -42275,7 +42073,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42275
42073
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
42276
42074
|
const blocks = fetchedData.edges.map(({ node: block2 }) => ({
|
42277
42075
|
id: block2.id,
|
42278
|
-
height: bn(block2.height),
|
42076
|
+
height: bn(block2.header.height),
|
42279
42077
|
time: block2.header.time,
|
42280
42078
|
transactionIds: block2.transactions.map((tx) => tx.id)
|
42281
42079
|
}));
|
@@ -42302,7 +42100,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42302
42100
|
}
|
42303
42101
|
return {
|
42304
42102
|
id: block2.id,
|
42305
|
-
height: bn(block2.height, 10),
|
42103
|
+
height: bn(block2.header.height, 10),
|
42306
42104
|
time: block2.header.time,
|
42307
42105
|
transactionIds: block2.transactions.map((tx) => tx.id),
|
42308
42106
|
transactions: block2.transactions.map(
|
@@ -42482,11 +42280,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42482
42280
|
prevRoot: messageBlockHeader.prevRoot,
|
42483
42281
|
time: messageBlockHeader.time,
|
42484
42282
|
applicationHash: messageBlockHeader.applicationHash,
|
42485
|
-
|
42486
|
-
|
42487
|
-
consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
|
42488
|
-
eventInboxRoot: messageBlockHeader.eventInboxRoot,
|
42489
|
-
stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
|
42283
|
+
messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
|
42284
|
+
messageReceiptCount: bn(messageBlockHeader.messageReceiptCount)
|
42490
42285
|
},
|
42491
42286
|
commitBlockHeader: {
|
42492
42287
|
id: commitBlockHeader.id,
|
@@ -42497,11 +42292,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42497
42292
|
prevRoot: commitBlockHeader.prevRoot,
|
42498
42293
|
time: commitBlockHeader.time,
|
42499
42294
|
applicationHash: commitBlockHeader.applicationHash,
|
42500
|
-
|
42501
|
-
|
42502
|
-
consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
|
42503
|
-
eventInboxRoot: commitBlockHeader.eventInboxRoot,
|
42504
|
-
stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
|
42295
|
+
messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
|
42296
|
+
messageReceiptCount: bn(commitBlockHeader.messageReceiptCount)
|
42505
42297
|
},
|
42506
42298
|
sender: Address.fromAddressOrString(sender),
|
42507
42299
|
recipient: Address.fromAddressOrString(recipient),
|
@@ -42510,16 +42302,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42510
42302
|
data
|
42511
42303
|
};
|
42512
42304
|
}
|
42513
|
-
async getLatestGasPrice() {
|
42514
|
-
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
42515
|
-
return bn(latestGasPrice.gasPrice);
|
42516
|
-
}
|
42517
|
-
async estimateGasPrice(blockHorizon) {
|
42518
|
-
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
42519
|
-
blockHorizon: String(blockHorizon)
|
42520
|
-
});
|
42521
|
-
return bn(estimateGasPrice.gasPrice);
|
42522
|
-
}
|
42523
42305
|
/**
|
42524
42306
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
42525
42307
|
*
|
@@ -42580,15 +42362,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42580
42362
|
arrayify(gqlTransaction.rawPayload),
|
42581
42363
|
0
|
42582
42364
|
);
|
42583
|
-
|
42584
|
-
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
42585
|
-
txReceipts = gqlTransaction.status.receipts;
|
42586
|
-
}
|
42587
|
-
const receipts = txReceipts.map(processGqlReceipt);
|
42365
|
+
const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
|
42588
42366
|
const {
|
42589
|
-
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts
|
42367
|
+
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
|
42590
42368
|
} = provider.getChain();
|
42591
|
-
const gasPrice = await provider.getLatestGasPrice();
|
42592
42369
|
const transactionInfo = assembleTransactionSummary({
|
42593
42370
|
id: gqlTransaction.id,
|
42594
42371
|
receipts,
|
@@ -42599,9 +42376,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42599
42376
|
gasPriceFactor: bn(gasPriceFactor),
|
42600
42377
|
abiMap,
|
42601
42378
|
maxInputs,
|
42602
|
-
gasCosts
|
42603
|
-
maxGasPerTx,
|
42604
|
-
gasPrice
|
42379
|
+
gasCosts
|
42605
42380
|
});
|
42606
42381
|
return {
|
42607
42382
|
gqlTransaction,
|
@@ -42611,11 +42386,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42611
42386
|
async function getTransactionSummaryFromRequest(params) {
|
42612
42387
|
const { provider, transactionRequest, abiMap } = params;
|
42613
42388
|
const { receipts } = await provider.call(transactionRequest);
|
42614
|
-
const { gasPerByte, gasPriceFactor, gasCosts
|
42389
|
+
const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
|
42615
42390
|
const maxInputs = provider.getChain().consensusParameters.maxInputs;
|
42616
42391
|
const transaction = transactionRequest.toTransaction();
|
42617
42392
|
const transactionBytes = transactionRequest.toTransactionBytes();
|
42618
|
-
const gasPrice = await provider.getLatestGasPrice();
|
42619
42393
|
const transactionSummary = assembleTransactionSummary({
|
42620
42394
|
receipts,
|
42621
42395
|
transaction,
|
@@ -42624,9 +42398,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42624
42398
|
gasPerByte,
|
42625
42399
|
gasPriceFactor,
|
42626
42400
|
maxInputs,
|
42627
|
-
gasCosts
|
42628
|
-
maxGasPerTx,
|
42629
|
-
gasPrice
|
42401
|
+
gasCosts
|
42630
42402
|
});
|
42631
42403
|
return transactionSummary;
|
42632
42404
|
}
|
@@ -42635,18 +42407,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42635
42407
|
const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
|
42636
42408
|
const { edges, pageInfo } = transactionsByOwner;
|
42637
42409
|
const {
|
42638
|
-
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts
|
42410
|
+
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
|
42639
42411
|
} = provider.getChain();
|
42640
|
-
const gasPrice = await provider.getLatestGasPrice();
|
42641
42412
|
const transactions = edges.map((edge) => {
|
42642
42413
|
const { node: gqlTransaction } = edge;
|
42643
|
-
const { id, rawPayload, status } = gqlTransaction;
|
42414
|
+
const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
|
42644
42415
|
const [decodedTransaction] = new TransactionCoder().decode(arrayify(rawPayload), 0);
|
42645
|
-
|
42646
|
-
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
42647
|
-
txReceipts = gqlTransaction.status.receipts;
|
42648
|
-
}
|
42649
|
-
const receipts = txReceipts.map(processGqlReceipt);
|
42416
|
+
const receipts = gqlReceipts?.map(processGqlReceipt) || [];
|
42650
42417
|
const transactionSummary = assembleTransactionSummary({
|
42651
42418
|
id,
|
42652
42419
|
receipts,
|
@@ -42657,9 +42424,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42657
42424
|
gasPerByte,
|
42658
42425
|
gasPriceFactor,
|
42659
42426
|
maxInputs,
|
42660
|
-
gasCosts
|
42661
|
-
maxGasPerTx,
|
42662
|
-
gasPrice
|
42427
|
+
gasCosts
|
42663
42428
|
});
|
42664
42429
|
const output3 = {
|
42665
42430
|
gqlTransaction,
|
@@ -42950,8 +42715,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42950
42715
|
* @param assetId - The asset ID to check the balance for.
|
42951
42716
|
* @returns A promise that resolves to the balance amount.
|
42952
42717
|
*/
|
42953
|
-
async getBalance(assetId
|
42954
|
-
const
|
42718
|
+
async getBalance(assetId) {
|
42719
|
+
const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
|
42720
|
+
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
42955
42721
|
return amount;
|
42956
42722
|
}
|
42957
42723
|
/**
|
@@ -42988,33 +42754,37 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42988
42754
|
* @param fee - The estimated transaction fee.
|
42989
42755
|
* @returns A promise that resolves when the resources are added to the transaction.
|
42990
42756
|
*/
|
42991
|
-
async fund(request,
|
42992
|
-
const
|
42993
|
-
const
|
42994
|
-
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
42757
|
+
async fund(request, coinQuantities, fee) {
|
42758
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42759
|
+
const updatedQuantities = addAmountToAsset({
|
42995
42760
|
amount: bn(fee),
|
42996
|
-
assetId:
|
42997
|
-
coinQuantities
|
42761
|
+
assetId: baseAssetId,
|
42762
|
+
coinQuantities
|
42998
42763
|
});
|
42999
42764
|
const quantitiesDict = {};
|
43000
|
-
|
42765
|
+
updatedQuantities.forEach(({ amount, assetId }) => {
|
43001
42766
|
quantitiesDict[assetId] = {
|
43002
42767
|
required: amount,
|
43003
42768
|
owned: bn(0)
|
43004
42769
|
};
|
43005
42770
|
});
|
43006
|
-
|
42771
|
+
const cachedUtxos = [];
|
42772
|
+
const cachedMessages = [];
|
42773
|
+
const owner = this.address.toB256();
|
42774
|
+
request.inputs.forEach((input) => {
|
43007
42775
|
const isResource = "amount" in input;
|
43008
42776
|
if (isResource) {
|
43009
42777
|
const isCoin2 = "owner" in input;
|
43010
42778
|
if (isCoin2) {
|
43011
42779
|
const assetId = String(input.assetId);
|
43012
|
-
if (quantitiesDict[assetId]) {
|
42780
|
+
if (input.owner === owner && quantitiesDict[assetId]) {
|
43013
42781
|
const amount = bn(input.amount);
|
43014
42782
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
42783
|
+
cachedUtxos.push(input.id);
|
43015
42784
|
}
|
43016
|
-
} else if (input.amount && quantitiesDict[
|
43017
|
-
quantitiesDict[
|
42785
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
|
42786
|
+
quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
|
42787
|
+
cachedMessages.push(input.nonce);
|
43018
42788
|
}
|
43019
42789
|
}
|
43020
42790
|
});
|
@@ -43029,23 +42799,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43029
42799
|
});
|
43030
42800
|
const needsToBeFunded = missingQuantities.length;
|
43031
42801
|
if (needsToBeFunded) {
|
43032
|
-
const
|
43033
|
-
|
43034
|
-
|
43035
|
-
|
43036
|
-
|
43037
|
-
txRequest.updatePredicateGasUsed(estimatedPredicates);
|
43038
|
-
const requestToBeReEstimate = clone_default(txRequest);
|
43039
|
-
if (addedSignatures) {
|
43040
|
-
Array.from({ length: addedSignatures }).forEach(
|
43041
|
-
() => requestToBeReEstimate.addEmptyWitness()
|
43042
|
-
);
|
42802
|
+
const resources = await this.getResourcesToSpend(missingQuantities, {
|
42803
|
+
messages: cachedMessages,
|
42804
|
+
utxos: cachedUtxos
|
42805
|
+
});
|
42806
|
+
request.addResources(resources);
|
43043
42807
|
}
|
43044
|
-
const { maxFee } = await this.provider.estimateTxGasAndFee({
|
43045
|
-
transactionRequest: requestToBeReEstimate
|
43046
|
-
});
|
43047
|
-
txRequest.maxFee = maxFee;
|
43048
|
-
return txRequest;
|
43049
42808
|
}
|
43050
42809
|
/**
|
43051
42810
|
* A helper that creates a transfer transaction request and returns it.
|
@@ -43053,25 +42812,30 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43053
42812
|
* @param destination - The address of the destination.
|
43054
42813
|
* @param amount - The amount of coins to transfer.
|
43055
42814
|
* @param assetId - The asset ID of the coins to transfer.
|
43056
|
-
* @param txParams - The transaction parameters (gasLimit,
|
42815
|
+
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
43057
42816
|
* @returns A promise that resolves to the prepared transaction request.
|
43058
42817
|
*/
|
43059
|
-
async createTransfer(destination, amount, assetId
|
43060
|
-
const
|
43061
|
-
|
43062
|
-
const
|
42818
|
+
async createTransfer(destination, amount, assetId, txParams = {}) {
|
42819
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
42820
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42821
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42822
|
+
const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
|
42823
|
+
const request = new ScriptTransactionRequest(params);
|
42824
|
+
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetIdToTransfer);
|
42825
|
+
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
43063
42826
|
estimateTxDependencies: true,
|
43064
42827
|
resourcesOwner: this
|
43065
42828
|
});
|
43066
|
-
|
43067
|
-
|
43068
|
-
|
43069
|
-
|
43070
|
-
|
43071
|
-
|
43072
|
-
|
43073
|
-
|
43074
|
-
await this.fund(request,
|
42829
|
+
request.gasPrice = bn(txParams.gasPrice ?? minGasPrice);
|
42830
|
+
request.gasLimit = bn(txParams.gasLimit ?? gasUsed);
|
42831
|
+
this.validateGas({
|
42832
|
+
gasUsed,
|
42833
|
+
gasPrice: request.gasPrice,
|
42834
|
+
gasLimit: request.gasLimit,
|
42835
|
+
minGasPrice
|
42836
|
+
});
|
42837
|
+
await this.fund(request, requiredQuantities, maxFee);
|
42838
|
+
request.updatePredicateInputs(estimatedInputs);
|
43075
42839
|
return request;
|
43076
42840
|
}
|
43077
42841
|
/**
|
@@ -43083,14 +42847,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43083
42847
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
43084
42848
|
* @returns A promise that resolves to the transaction response.
|
43085
42849
|
*/
|
43086
|
-
async transfer(destination, amount, assetId
|
42850
|
+
async transfer(destination, amount, assetId, txParams = {}) {
|
43087
42851
|
if (bn(amount).lte(0)) {
|
43088
42852
|
throw new FuelError(
|
43089
42853
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
43090
42854
|
"Transfer amount must be a positive number."
|
43091
42855
|
);
|
43092
42856
|
}
|
43093
|
-
const
|
42857
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42858
|
+
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
43094
42859
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
43095
42860
|
}
|
43096
42861
|
/**
|
@@ -43102,7 +42867,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43102
42867
|
* @param txParams - The optional transaction parameters.
|
43103
42868
|
* @returns A promise that resolves to the transaction response.
|
43104
42869
|
*/
|
43105
|
-
async transferToContract(contractId, amount, assetId
|
42870
|
+
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
43106
42871
|
if (bn(amount).lte(0)) {
|
43107
42872
|
throw new FuelError(
|
43108
42873
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -43110,30 +42875,33 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43110
42875
|
);
|
43111
42876
|
}
|
43112
42877
|
const contractAddress = Address.fromAddressOrString(contractId);
|
42878
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
42879
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42880
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42881
|
+
const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
|
43113
42882
|
const { script, scriptData } = await assembleTransferToContractScript({
|
43114
42883
|
hexlifiedContractId: contractAddress.toB256(),
|
43115
42884
|
amountToTransfer: bn(amount),
|
43116
|
-
assetId
|
42885
|
+
assetId: assetIdToTransfer
|
43117
42886
|
});
|
43118
42887
|
const request = new ScriptTransactionRequest({
|
43119
|
-
...
|
42888
|
+
...params,
|
43120
42889
|
script,
|
43121
42890
|
scriptData
|
43122
42891
|
});
|
43123
42892
|
request.addContractInputAndOutput(contractAddress);
|
43124
|
-
const
|
43125
|
-
|
43126
|
-
|
42893
|
+
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
42894
|
+
request,
|
42895
|
+
[{ amount: bn(amount), assetId: String(assetIdToTransfer) }]
|
42896
|
+
);
|
42897
|
+
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
42898
|
+
this.validateGas({
|
42899
|
+
gasUsed,
|
42900
|
+
gasPrice: request.gasPrice,
|
42901
|
+
gasLimit: request.gasLimit,
|
42902
|
+
minGasPrice
|
43127
42903
|
});
|
43128
|
-
|
43129
|
-
this.validateGas({
|
43130
|
-
gasUsed: txCost.gasUsed,
|
43131
|
-
gasLimit: request.gasLimit
|
43132
|
-
});
|
43133
|
-
}
|
43134
|
-
request.gasLimit = txCost.gasUsed;
|
43135
|
-
request.maxFee = txCost.maxFee;
|
43136
|
-
await this.fund(request, txCost);
|
42904
|
+
await this.fund(request, requiredQuantities, maxFee);
|
43137
42905
|
return this.sendTransaction(request);
|
43138
42906
|
}
|
43139
42907
|
/**
|
@@ -43145,6 +42913,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43145
42913
|
* @returns A promise that resolves to the transaction response.
|
43146
42914
|
*/
|
43147
42915
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
42916
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
42917
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
43148
42918
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
43149
42919
|
const recipientDataArray = arrayify(
|
43150
42920
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -43157,19 +42927,26 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43157
42927
|
...recipientDataArray,
|
43158
42928
|
...amountDataArray
|
43159
42929
|
]);
|
43160
|
-
const params = {
|
42930
|
+
const params = {
|
42931
|
+
script,
|
42932
|
+
gasPrice: minGasPrice,
|
42933
|
+
baseAssetId,
|
42934
|
+
...txParams
|
42935
|
+
};
|
43161
42936
|
const request = new ScriptTransactionRequest(params);
|
43162
|
-
const
|
43163
|
-
const
|
43164
|
-
|
43165
|
-
|
43166
|
-
|
43167
|
-
|
43168
|
-
|
43169
|
-
|
43170
|
-
|
43171
|
-
|
43172
|
-
|
42937
|
+
const forwardingQuantities = [{ amount: bn(amount), assetId: baseAssetId }];
|
42938
|
+
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
42939
|
+
request,
|
42940
|
+
forwardingQuantities
|
42941
|
+
);
|
42942
|
+
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
42943
|
+
this.validateGas({
|
42944
|
+
gasUsed,
|
42945
|
+
gasPrice: request.gasPrice,
|
42946
|
+
gasLimit: request.gasLimit,
|
42947
|
+
minGasPrice
|
42948
|
+
});
|
42949
|
+
await this.fund(request, requiredQuantities, maxFee);
|
43173
42950
|
return this.sendTransaction(request);
|
43174
42951
|
}
|
43175
42952
|
async signMessage(message) {
|
@@ -43227,7 +43004,18 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43227
43004
|
}
|
43228
43005
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
43229
43006
|
}
|
43230
|
-
validateGas({
|
43007
|
+
validateGas({
|
43008
|
+
gasUsed,
|
43009
|
+
gasPrice,
|
43010
|
+
gasLimit,
|
43011
|
+
minGasPrice
|
43012
|
+
}) {
|
43013
|
+
if (minGasPrice.gt(gasPrice)) {
|
43014
|
+
throw new FuelError(
|
43015
|
+
ErrorCode.GAS_PRICE_TOO_LOW,
|
43016
|
+
`Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
|
43017
|
+
);
|
43018
|
+
}
|
43231
43019
|
if (gasUsed.gt(gasLimit)) {
|
43232
43020
|
throw new FuelError(
|
43233
43021
|
ErrorCode.GAS_LIMIT_TOO_LOW,
|
@@ -44816,7 +44604,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44816
44604
|
* @param transactionRequestLike - The transaction request to send.
|
44817
44605
|
* @returns A promise that resolves to the TransactionResponse object.
|
44818
44606
|
*/
|
44819
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies =
|
44607
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
|
44820
44608
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
44821
44609
|
if (estimateTxDependencies) {
|
44822
44610
|
await this.provider.estimateTxDependencies(transactionRequest);
|
@@ -48094,8 +47882,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
48094
47882
|
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
48095
47883
|
request.inputs?.forEach((input) => {
|
48096
47884
|
if (input.type === InputType.Coin && hexlify(input.owner) === this.address.toB256()) {
|
48097
|
-
input.predicate =
|
48098
|
-
input.predicateData =
|
47885
|
+
input.predicate = this.bytes;
|
47886
|
+
input.predicateData = this.getPredicateData(policies.length);
|
48099
47887
|
}
|
48100
47888
|
});
|
48101
47889
|
return request;
|
@@ -48109,8 +47897,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
48109
47897
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
48110
47898
|
* @returns A promise that resolves to the prepared transaction request.
|
48111
47899
|
*/
|
48112
|
-
async createTransfer(destination, amount, assetId
|
48113
|
-
|
47900
|
+
async createTransfer(destination, amount, assetId, txParams = {}) {
|
47901
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
47902
|
+
const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
47903
|
+
return this.populateTransactionPredicateData(request);
|
48114
47904
|
}
|
48115
47905
|
/**
|
48116
47906
|
* Sends a transaction with the populated predicate data.
|
@@ -48118,9 +47908,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
48118
47908
|
* @param transactionRequestLike - The transaction request-like object.
|
48119
47909
|
* @returns A promise that resolves to the transaction response.
|
48120
47910
|
*/
|
48121
|
-
sendTransaction(transactionRequestLike) {
|
48122
|
-
const transactionRequest =
|
48123
|
-
return super.sendTransaction(transactionRequest,
|
47911
|
+
sendTransaction(transactionRequestLike, options) {
|
47912
|
+
const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
|
47913
|
+
return super.sendTransaction(transactionRequest, options);
|
48124
47914
|
}
|
48125
47915
|
/**
|
48126
47916
|
* Simulates a transaction with the populated predicate data.
|
@@ -48129,8 +47919,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
48129
47919
|
* @returns A promise that resolves to the call result.
|
48130
47920
|
*/
|
48131
47921
|
simulateTransaction(transactionRequestLike) {
|
48132
|
-
const transactionRequest =
|
48133
|
-
return super.simulateTransaction(transactionRequest
|
47922
|
+
const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
|
47923
|
+
return super.simulateTransaction(transactionRequest);
|
48134
47924
|
}
|
48135
47925
|
getPredicateData(policiesLength) {
|
48136
47926
|
if (!this.predicateData.length) {
|
@@ -48176,25 +47966,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
48176
47966
|
predicateInterface: abiInterface
|
48177
47967
|
};
|
48178
47968
|
}
|
48179
|
-
/**
|
48180
|
-
* Retrieves resources satisfying the spend query for the account.
|
48181
|
-
*
|
48182
|
-
* @param quantities - IDs of coins to exclude.
|
48183
|
-
* @param excludedIds - IDs of resources to be excluded from the query.
|
48184
|
-
* @returns A promise that resolves to an array of Resources.
|
48185
|
-
*/
|
48186
|
-
async getResourcesToSpend(quantities, excludedIds) {
|
48187
|
-
const resources = await this.provider.getResourcesToSpend(
|
48188
|
-
this.address,
|
48189
|
-
quantities,
|
48190
|
-
excludedIds
|
48191
|
-
);
|
48192
|
-
return resources.map((resource) => ({
|
48193
|
-
...resource,
|
48194
|
-
predicate: hexlify(this.bytes),
|
48195
|
-
paddPredicateData: (policiesLength) => hexlify(this.getPredicateData(policiesLength))
|
48196
|
-
}));
|
48197
|
-
}
|
48198
47969
|
/**
|
48199
47970
|
* Sets the configurable constants for the predicate.
|
48200
47971
|
*
|