@fuel-ts/account 0.0.0-rc-1976-20240419101644 → 0.0.0-rc-2021-20240419145341
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @fuel-ts/account might be problematic. Click here for more details.
- package/README.md +1 -1
- package/dist/account.d.ts +5 -4
- package/dist/account.d.ts.map +1 -1
- package/dist/configs.d.ts.map +1 -1
- package/dist/configs.global.js +1 -1
- package/dist/configs.global.js.map +1 -1
- package/dist/configs.js +1 -1
- package/dist/configs.js.map +1 -1
- package/dist/configs.mjs +1 -1
- package/dist/configs.mjs.map +1 -1
- package/dist/index.global.js +830 -604
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +833 -601
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +675 -444
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +10 -2
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +906 -324
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/coin-quantity.d.ts +3 -3
- package/dist/providers/coin-quantity.d.ts.map +1 -1
- package/dist/providers/coin.d.ts +4 -2
- package/dist/providers/coin.d.ts.map +1 -1
- package/dist/providers/message.d.ts +7 -1
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +37 -34
- 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 +9 -29
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/utils.d.ts +3 -0
- package/dist/providers/transaction-request/utils.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +2 -0
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +3 -2
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
- package/dist/providers/utils/gas.d.ts +8 -2
- 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 +1579 -1118
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +811 -600
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +667 -456
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/package.json +16 -16
package/dist/index.global.js
CHANGED
@@ -289,7 +289,7 @@
|
|
289
289
|
}
|
290
290
|
return num !== null && typeof num === "object" && num.constructor.wordSize === BN2.wordSize && Array.isArray(num.words);
|
291
291
|
};
|
292
|
-
BN2.max = function
|
292
|
+
BN2.max = function max(left, right) {
|
293
293
|
if (left.cmp(right) > 0)
|
294
294
|
return left;
|
295
295
|
return right;
|
@@ -5113,7 +5113,7 @@
|
|
5113
5113
|
function isBlob(obj) {
|
5114
5114
|
return typeof obj === "object" && typeof obj.arrayBuffer === "function" && typeof obj.type === "string" && typeof obj.stream === "function" && typeof obj.constructor === "function" && typeof obj.constructor.name === "string" && /^(Blob|File)$/.test(obj.constructor.name) && /^(Blob|File)$/.test(obj[Symbol.toStringTag]);
|
5115
5115
|
}
|
5116
|
-
function
|
5116
|
+
function clone3(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(clone3(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 ? clone3(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.51.1",
|
28956
|
+
FUEL_CORE: "0.24.2",
|
28957
28957
|
FUELS: "0.81.0"
|
28958
28958
|
};
|
28959
28959
|
}
|
@@ -31272,6 +31272,10 @@ 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
|
+
|
31275
31279
|
// ../math/dist/index.mjs
|
31276
31280
|
var import_bn = __toESM(require_bn(), 1);
|
31277
31281
|
var DEFAULT_PRECISION = 9;
|
@@ -31491,32 +31495,182 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31491
31495
|
function toBytes3(value, bytesPadding) {
|
31492
31496
|
return bn(value).toBytes(bytesPadding);
|
31493
31497
|
}
|
31494
|
-
|
31495
|
-
|
31498
|
+
|
31499
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isPlaceholder.js
|
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
|
+
};
|
31513
|
+
}
|
31514
|
+
|
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";
|
31496
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";
|
31497
31651
|
|
31498
31652
|
// src/providers/coin-quantity.ts
|
31499
31653
|
var coinQuantityfy = (coinQuantityLike) => {
|
31500
31654
|
let assetId;
|
31501
31655
|
let amount;
|
31502
|
-
let
|
31656
|
+
let max;
|
31503
31657
|
if (Array.isArray(coinQuantityLike)) {
|
31504
31658
|
amount = coinQuantityLike[0];
|
31505
|
-
assetId = coinQuantityLike[1];
|
31506
|
-
|
31659
|
+
assetId = coinQuantityLike[1] ?? BaseAssetId;
|
31660
|
+
max = coinQuantityLike[2] ?? void 0;
|
31507
31661
|
} else {
|
31508
31662
|
amount = coinQuantityLike.amount;
|
31509
|
-
assetId = coinQuantityLike.assetId;
|
31510
|
-
|
31663
|
+
assetId = coinQuantityLike.assetId ?? BaseAssetId;
|
31664
|
+
max = coinQuantityLike.max ?? void 0;
|
31511
31665
|
}
|
31512
31666
|
const bnAmount = bn(amount);
|
31513
31667
|
return {
|
31514
31668
|
assetId: hexlify(assetId),
|
31515
31669
|
amount: bnAmount.lt(1) ? bn(1) : bnAmount,
|
31516
|
-
max:
|
31670
|
+
max: max ? bn(max) : void 0
|
31517
31671
|
};
|
31518
31672
|
};
|
31519
|
-
var
|
31673
|
+
var addAmountToCoinQuantities = (params) => {
|
31520
31674
|
const { amount, assetId } = params;
|
31521
31675
|
const coinQuantities = [...params.coinQuantities];
|
31522
31676
|
const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
|
@@ -31601,7 +31755,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31601
31755
|
var ENCODING_V1 = "1";
|
31602
31756
|
var WORD_SIZE = 8;
|
31603
31757
|
var BYTES_32 = 32;
|
31604
|
-
var UTXO_ID_LEN = BYTES_32 +
|
31758
|
+
var UTXO_ID_LEN = BYTES_32 + 2;
|
31605
31759
|
var ASSET_ID_LEN = BYTES_32;
|
31606
31760
|
var ADDRESS_LEN = BYTES_32;
|
31607
31761
|
var NONCE_LEN = BYTES_32;
|
@@ -31609,9 +31763,9 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31609
31763
|
var TX_POINTER_LEN = WORD_SIZE * 2;
|
31610
31764
|
var MAX_BYTES = 2 ** 32 - 1;
|
31611
31765
|
var calculateVmTxMemory = ({ maxInputs }) => BYTES_32 + // Tx ID
|
31612
|
-
|
31766
|
+
ASSET_ID_LEN + // Base asset ID
|
31613
31767
|
// Asset ID/Balance coin input pairs
|
31614
|
-
maxInputs * (ASSET_ID_LEN + WORD_SIZE);
|
31768
|
+
maxInputs * (ASSET_ID_LEN + WORD_SIZE) + WORD_SIZE;
|
31615
31769
|
var SCRIPT_FIXED_SIZE = WORD_SIZE + // Identifier
|
31616
31770
|
WORD_SIZE + // Gas limit
|
31617
31771
|
WORD_SIZE + // Script size
|
@@ -31629,7 +31783,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31629
31783
|
ASSET_ID_LEN + // Asset id
|
31630
31784
|
TX_POINTER_LEN + // TxPointer
|
31631
31785
|
WORD_SIZE + // Witnesses index
|
31632
|
-
WORD_SIZE + // Maturity
|
31633
31786
|
WORD_SIZE + // Predicate size
|
31634
31787
|
WORD_SIZE + // Predicate data size
|
31635
31788
|
WORD_SIZE;
|
@@ -31951,7 +32104,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31951
32104
|
constructor(name, coders) {
|
31952
32105
|
const caseIndexCoder = new BigNumberCoder("u64");
|
31953
32106
|
const encodedValueSize = Object.values(coders).reduce(
|
31954
|
-
(
|
32107
|
+
(max, coder) => Math.max(max, coder.encodedLength),
|
31955
32108
|
0
|
31956
32109
|
);
|
31957
32110
|
super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
|
@@ -32655,7 +32808,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32655
32808
|
constructor(name, coders) {
|
32656
32809
|
const caseIndexCoder = new BigNumberCoder("u64");
|
32657
32810
|
const encodedValueSize = Object.values(coders).reduce(
|
32658
|
-
(
|
32811
|
+
(max, coder) => Math.max(max, coder.encodedLength),
|
32659
32812
|
0
|
32660
32813
|
);
|
32661
32814
|
super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
|
@@ -33367,18 +33520,19 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33367
33520
|
encode(value) {
|
33368
33521
|
const parts = [];
|
33369
33522
|
parts.push(new B256Coder().encode(value.txID));
|
33370
|
-
parts.push(new NumberCoder("
|
33523
|
+
parts.push(new NumberCoder("u16").encode(value.outputIndex));
|
33371
33524
|
parts.push(new B256Coder().encode(value.owner));
|
33372
33525
|
parts.push(new BigNumberCoder("u64").encode(value.amount));
|
33373
33526
|
parts.push(new B256Coder().encode(value.assetId));
|
33374
33527
|
parts.push(new TxPointerCoder().encode(value.txPointer));
|
33375
|
-
parts.push(new NumberCoder("
|
33376
|
-
parts.push(new NumberCoder("u32").encode(value.maturity));
|
33528
|
+
parts.push(new NumberCoder("u16").encode(value.witnessIndex));
|
33377
33529
|
parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
|
33378
|
-
parts.push(new
|
33379
|
-
parts.push(new
|
33380
|
-
parts.push(new ByteArrayCoder(value.predicateLength).encode(value.predicate));
|
33381
|
-
parts.push(
|
33530
|
+
parts.push(new BigNumberCoder("u64").encode(value.predicateLength));
|
33531
|
+
parts.push(new BigNumberCoder("u64").encode(value.predicateDataLength));
|
33532
|
+
parts.push(new ByteArrayCoder(value.predicateLength.toNumber()).encode(value.predicate));
|
33533
|
+
parts.push(
|
33534
|
+
new ByteArrayCoder(value.predicateDataLength.toNumber()).encode(value.predicateData)
|
33535
|
+
);
|
33382
33536
|
return concat(parts);
|
33383
33537
|
}
|
33384
33538
|
decode(data, offset) {
|
@@ -33386,7 +33540,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33386
33540
|
let o = offset;
|
33387
33541
|
[decoded, o] = new B256Coder().decode(data, o);
|
33388
33542
|
const txID = decoded;
|
33389
|
-
[decoded, o] = new NumberCoder("
|
33543
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
33390
33544
|
const outputIndex = decoded;
|
33391
33545
|
[decoded, o] = new B256Coder().decode(data, o);
|
33392
33546
|
const owner = decoded;
|
@@ -33396,19 +33550,17 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33396
33550
|
const assetId = decoded;
|
33397
33551
|
[decoded, o] = new TxPointerCoder().decode(data, o);
|
33398
33552
|
const txPointer = decoded;
|
33399
|
-
[decoded, o] = new NumberCoder("
|
33553
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
33400
33554
|
const witnessIndex = Number(decoded);
|
33401
|
-
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33402
|
-
const maturity = decoded;
|
33403
33555
|
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33404
33556
|
const predicateGasUsed = decoded;
|
33405
|
-
[decoded, o] = new
|
33557
|
+
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33406
33558
|
const predicateLength = decoded;
|
33407
|
-
[decoded, o] = new
|
33559
|
+
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33408
33560
|
const predicateDataLength = decoded;
|
33409
|
-
[decoded, o] = new ByteArrayCoder(predicateLength).decode(data, o);
|
33561
|
+
[decoded, o] = new ByteArrayCoder(predicateLength.toNumber()).decode(data, o);
|
33410
33562
|
const predicate = decoded;
|
33411
|
-
[decoded, o] = new ByteArrayCoder(predicateDataLength).decode(data, o);
|
33563
|
+
[decoded, o] = new ByteArrayCoder(predicateDataLength.toNumber()).decode(data, o);
|
33412
33564
|
const predicateData = decoded;
|
33413
33565
|
return [
|
33414
33566
|
{
|
@@ -33420,7 +33572,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33420
33572
|
assetId,
|
33421
33573
|
txPointer,
|
33422
33574
|
witnessIndex,
|
33423
|
-
maturity,
|
33424
33575
|
predicateGasUsed,
|
33425
33576
|
predicateLength,
|
33426
33577
|
predicateDataLength,
|
@@ -33438,7 +33589,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33438
33589
|
encode(value) {
|
33439
33590
|
const parts = [];
|
33440
33591
|
parts.push(new B256Coder().encode(value.txID));
|
33441
|
-
parts.push(new NumberCoder("
|
33592
|
+
parts.push(new NumberCoder("u16").encode(value.outputIndex));
|
33442
33593
|
parts.push(new B256Coder().encode(value.balanceRoot));
|
33443
33594
|
parts.push(new B256Coder().encode(value.stateRoot));
|
33444
33595
|
parts.push(new TxPointerCoder().encode(value.txPointer));
|
@@ -33450,7 +33601,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33450
33601
|
let o = offset;
|
33451
33602
|
[decoded, o] = new B256Coder().decode(data, o);
|
33452
33603
|
const txID = decoded;
|
33453
|
-
[decoded, o] = new NumberCoder("
|
33604
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
33454
33605
|
const outputIndex = decoded;
|
33455
33606
|
[decoded, o] = new B256Coder().decode(data, o);
|
33456
33607
|
const balanceRoot = decoded;
|
@@ -33499,14 +33650,16 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33499
33650
|
parts.push(new ByteArrayCoder(32).encode(value.recipient));
|
33500
33651
|
parts.push(new BigNumberCoder("u64").encode(value.amount));
|
33501
33652
|
parts.push(new ByteArrayCoder(32).encode(value.nonce));
|
33502
|
-
parts.push(new NumberCoder("
|
33653
|
+
parts.push(new NumberCoder("u16").encode(value.witnessIndex));
|
33503
33654
|
parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
|
33504
|
-
parts.push(new
|
33505
|
-
parts.push(new
|
33506
|
-
parts.push(new
|
33655
|
+
parts.push(new BigNumberCoder("u64").encode(data.length));
|
33656
|
+
parts.push(new BigNumberCoder("u64").encode(value.predicateLength));
|
33657
|
+
parts.push(new BigNumberCoder("u64").encode(value.predicateDataLength));
|
33507
33658
|
parts.push(new ByteArrayCoder(data.length).encode(data));
|
33508
|
-
parts.push(new ByteArrayCoder(value.predicateLength).encode(value.predicate));
|
33509
|
-
parts.push(
|
33659
|
+
parts.push(new ByteArrayCoder(value.predicateLength.toNumber()).encode(value.predicate));
|
33660
|
+
parts.push(
|
33661
|
+
new ByteArrayCoder(value.predicateDataLength.toNumber()).encode(value.predicateData)
|
33662
|
+
);
|
33510
33663
|
return concat(parts);
|
33511
33664
|
}
|
33512
33665
|
static decodeData(messageData) {
|
@@ -33526,21 +33679,21 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33526
33679
|
const amount = decoded;
|
33527
33680
|
[decoded, o] = new B256Coder().decode(data, o);
|
33528
33681
|
const nonce = decoded;
|
33529
|
-
[decoded, o] = new NumberCoder("
|
33682
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
33530
33683
|
const witnessIndex = Number(decoded);
|
33531
33684
|
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33532
33685
|
const predicateGasUsed = decoded;
|
33533
33686
|
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33534
33687
|
const dataLength2 = decoded;
|
33535
|
-
[decoded, o] = new
|
33688
|
+
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33536
33689
|
const predicateLength = decoded;
|
33537
|
-
[decoded, o] = new
|
33690
|
+
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33538
33691
|
const predicateDataLength = decoded;
|
33539
33692
|
[decoded, o] = new ByteArrayCoder(dataLength2).decode(data, o);
|
33540
33693
|
const messageData = decoded;
|
33541
|
-
[decoded, o] = new ByteArrayCoder(predicateLength).decode(data, o);
|
33694
|
+
[decoded, o] = new ByteArrayCoder(predicateLength.toNumber()).decode(data, o);
|
33542
33695
|
const predicate = decoded;
|
33543
|
-
[decoded, o] = new ByteArrayCoder(predicateDataLength).decode(data, o);
|
33696
|
+
[decoded, o] = new ByteArrayCoder(predicateDataLength.toNumber()).decode(data, o);
|
33544
33697
|
const predicateData = decoded;
|
33545
33698
|
return [
|
33546
33699
|
{
|
@@ -33852,7 +34005,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33852
34005
|
}
|
33853
34006
|
};
|
33854
34007
|
var PolicyType = /* @__PURE__ */ ((PolicyType2) => {
|
33855
|
-
PolicyType2[PolicyType2["
|
34008
|
+
PolicyType2[PolicyType2["Tip"] = 1] = "Tip";
|
33856
34009
|
PolicyType2[PolicyType2["WitnessLimit"] = 2] = "WitnessLimit";
|
33857
34010
|
PolicyType2[PolicyType2["Maturity"] = 4] = "Maturity";
|
33858
34011
|
PolicyType2[PolicyType2["MaxFee"] = 8] = "MaxFee";
|
@@ -33900,9 +34053,9 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33900
34053
|
let o = offset;
|
33901
34054
|
const policies = [];
|
33902
34055
|
if (policyTypes & 1) {
|
33903
|
-
const [
|
34056
|
+
const [tip, nextOffset] = new BigNumberCoder("u64").decode(data, o);
|
33904
34057
|
o = nextOffset;
|
33905
|
-
policies.push({ type: 1, data:
|
34058
|
+
policies.push({ type: 1, data: tip });
|
33906
34059
|
}
|
33907
34060
|
if (policyTypes & 2) {
|
33908
34061
|
const [witnessLimit, nextOffset] = new BigNumberCoder("u64").decode(data, o);
|
@@ -34134,15 +34287,15 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34134
34287
|
encode(value) {
|
34135
34288
|
const parts = [];
|
34136
34289
|
parts.push(new BigNumberCoder("u64").encode(value.scriptGasLimit));
|
34137
|
-
parts.push(new NumberCoder("u32").encode(value.scriptLength));
|
34138
|
-
parts.push(new NumberCoder("u32").encode(value.scriptDataLength));
|
34139
|
-
parts.push(new NumberCoder("u32").encode(value.policyTypes));
|
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
34290
|
parts.push(new B256Coder().encode(value.receiptsRoot));
|
34144
|
-
parts.push(new
|
34145
|
-
parts.push(new
|
34291
|
+
parts.push(new BigNumberCoder("u64").encode(value.scriptLength));
|
34292
|
+
parts.push(new BigNumberCoder("u64").encode(value.scriptDataLength));
|
34293
|
+
parts.push(new NumberCoder("u32").encode(value.policyTypes));
|
34294
|
+
parts.push(new NumberCoder("u16").encode(value.inputsCount));
|
34295
|
+
parts.push(new NumberCoder("u16").encode(value.outputsCount));
|
34296
|
+
parts.push(new NumberCoder("u16").encode(value.witnessesCount));
|
34297
|
+
parts.push(new ByteArrayCoder(value.scriptLength.toNumber()).encode(value.script));
|
34298
|
+
parts.push(new ByteArrayCoder(value.scriptDataLength.toNumber()).encode(value.scriptData));
|
34146
34299
|
parts.push(new PoliciesCoder().encode(value.policies));
|
34147
34300
|
parts.push(new ArrayCoder(new InputCoder(), value.inputsCount).encode(value.inputs));
|
34148
34301
|
parts.push(new ArrayCoder(new OutputCoder(), value.outputsCount).encode(value.outputs));
|
@@ -34154,23 +34307,23 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34154
34307
|
let o = offset;
|
34155
34308
|
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34156
34309
|
const scriptGasLimit = decoded;
|
34157
|
-
[decoded, o] = new
|
34310
|
+
[decoded, o] = new B256Coder().decode(data, o);
|
34311
|
+
const receiptsRoot = decoded;
|
34312
|
+
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34158
34313
|
const scriptLength = decoded;
|
34159
|
-
[decoded, o] = new
|
34314
|
+
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34160
34315
|
const scriptDataLength = decoded;
|
34161
34316
|
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
34162
34317
|
const policyTypes = decoded;
|
34163
|
-
[decoded, o] = new NumberCoder("
|
34318
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
34164
34319
|
const inputsCount = decoded;
|
34165
|
-
[decoded, o] = new NumberCoder("
|
34320
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
34166
34321
|
const outputsCount = decoded;
|
34167
|
-
[decoded, o] = new NumberCoder("
|
34322
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
34168
34323
|
const witnessesCount = decoded;
|
34169
|
-
[decoded, o] = new
|
34170
|
-
const receiptsRoot = decoded;
|
34171
|
-
[decoded, o] = new ByteArrayCoder(scriptLength).decode(data, o);
|
34324
|
+
[decoded, o] = new ByteArrayCoder(scriptLength.toNumber()).decode(data, o);
|
34172
34325
|
const script = decoded;
|
34173
|
-
[decoded, o] = new ByteArrayCoder(scriptDataLength).decode(data, o);
|
34326
|
+
[decoded, o] = new ByteArrayCoder(scriptDataLength.toNumber()).decode(data, o);
|
34174
34327
|
const scriptData = decoded;
|
34175
34328
|
[decoded, o] = new PoliciesCoder().decode(data, o, policyTypes);
|
34176
34329
|
const policies = decoded;
|
@@ -34208,18 +34361,19 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34208
34361
|
}
|
34209
34362
|
encode(value) {
|
34210
34363
|
const parts = [];
|
34211
|
-
parts.push(new NumberCoder("
|
34212
|
-
parts.push(new NumberCoder("u8").encode(value.bytecodeWitnessIndex));
|
34213
|
-
parts.push(new NumberCoder("u32").encode(value.policyTypes));
|
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));
|
34364
|
+
parts.push(new NumberCoder("u16").encode(value.bytecodeWitnessIndex));
|
34218
34365
|
parts.push(new B256Coder().encode(value.salt));
|
34219
|
-
parts.push(new
|
34366
|
+
parts.push(new BigNumberCoder("u64").encode(value.storageSlotsCount));
|
34367
|
+
parts.push(new NumberCoder("u32").encode(value.policyTypes));
|
34368
|
+
parts.push(new NumberCoder("u16").encode(value.inputsCount));
|
34369
|
+
parts.push(new NumberCoder("u16").encode(value.outputsCount));
|
34370
|
+
parts.push(new NumberCoder("u16").encode(value.witnessesCount));
|
34220
34371
|
parts.push(
|
34221
|
-
new ArrayCoder(new StorageSlotCoder(), value.storageSlotsCount).encode(
|
34372
|
+
new ArrayCoder(new StorageSlotCoder(), value.storageSlotsCount.toNumber()).encode(
|
34373
|
+
value.storageSlots
|
34374
|
+
)
|
34222
34375
|
);
|
34376
|
+
parts.push(new PoliciesCoder().encode(value.policies));
|
34223
34377
|
parts.push(new ArrayCoder(new InputCoder(), value.inputsCount).encode(value.inputs));
|
34224
34378
|
parts.push(new ArrayCoder(new OutputCoder(), value.outputsCount).encode(value.outputs));
|
34225
34379
|
parts.push(new ArrayCoder(new WitnessCoder(), value.witnessesCount).encode(value.witnesses));
|
@@ -34228,26 +34382,27 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34228
34382
|
decode(data, offset) {
|
34229
34383
|
let decoded;
|
34230
34384
|
let o = offset;
|
34231
|
-
[decoded, o] = new NumberCoder("
|
34232
|
-
const bytecodeLength = decoded;
|
34233
|
-
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34385
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
34234
34386
|
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;
|
34235
34391
|
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
34236
34392
|
const policyTypes = decoded;
|
34237
34393
|
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
34238
|
-
const storageSlotsCount = decoded;
|
34239
|
-
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34240
34394
|
const inputsCount = decoded;
|
34241
|
-
[decoded, o] = new NumberCoder("
|
34395
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
34242
34396
|
const outputsCount = decoded;
|
34243
|
-
[decoded, o] = new NumberCoder("
|
34397
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
34244
34398
|
const witnessesCount = decoded;
|
34245
|
-
[decoded, o] = new
|
34246
|
-
|
34399
|
+
[decoded, o] = new ArrayCoder(new StorageSlotCoder(), storageSlotsCount.toNumber()).decode(
|
34400
|
+
data,
|
34401
|
+
o
|
34402
|
+
);
|
34403
|
+
const storageSlots = decoded;
|
34247
34404
|
[decoded, o] = new PoliciesCoder().decode(data, o, policyTypes);
|
34248
34405
|
const policies = decoded;
|
34249
|
-
[decoded, o] = new ArrayCoder(new StorageSlotCoder(), storageSlotsCount).decode(data, o);
|
34250
|
-
const storageSlots = decoded;
|
34251
34406
|
[decoded, o] = new ArrayCoder(new InputCoder(), inputsCount).decode(data, o);
|
34252
34407
|
const inputs = decoded;
|
34253
34408
|
[decoded, o] = new ArrayCoder(new OutputCoder(), outputsCount).decode(data, o);
|
@@ -34257,7 +34412,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34257
34412
|
return [
|
34258
34413
|
{
|
34259
34414
|
type: 1,
|
34260
|
-
bytecodeLength,
|
34261
34415
|
bytecodeWitnessIndex,
|
34262
34416
|
policyTypes,
|
34263
34417
|
storageSlotsCount,
|
@@ -34286,6 +34440,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34286
34440
|
parts.push(new OutputContractCoder().encode(value.outputContract));
|
34287
34441
|
parts.push(new BigNumberCoder("u64").encode(value.mintAmount));
|
34288
34442
|
parts.push(new B256Coder().encode(value.mintAssetId));
|
34443
|
+
parts.push(new BigNumberCoder("u64").encode(value.gasPrice));
|
34289
34444
|
return concat(parts);
|
34290
34445
|
}
|
34291
34446
|
decode(data, offset) {
|
@@ -34301,6 +34456,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34301
34456
|
const mintAmount = decoded;
|
34302
34457
|
[decoded, o] = new B256Coder().decode(data, o);
|
34303
34458
|
const mintAssetId = decoded;
|
34459
|
+
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34460
|
+
const gasPrice = decoded;
|
34304
34461
|
return [
|
34305
34462
|
{
|
34306
34463
|
type: 2,
|
@@ -34308,7 +34465,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34308
34465
|
inputContract,
|
34309
34466
|
outputContract,
|
34310
34467
|
mintAmount,
|
34311
|
-
mintAssetId
|
34468
|
+
mintAssetId,
|
34469
|
+
gasPrice
|
34312
34470
|
},
|
34313
34471
|
o
|
34314
34472
|
];
|
@@ -34615,159 +34773,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34615
34773
|
// src/providers/provider.ts
|
34616
34774
|
var import_graphql_request = __toESM(require_dist2());
|
34617
34775
|
|
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
|
-
|
34771
34776
|
// ../../node_modules/.pnpm/tslib@2.6.0/node_modules/tslib/tslib.es6.mjs
|
34772
34777
|
var __assign = function() {
|
34773
34778
|
__assign = Object.assign || function __assign2(t) {
|
@@ -37935,14 +37940,10 @@ spurious results.`);
|
|
37935
37940
|
// src/providers/__generated__/operations.ts
|
37936
37941
|
var ReceiptFragmentFragmentDoc = lib_default2`
|
37937
37942
|
fragment receiptFragment on Receipt {
|
37938
|
-
|
37939
|
-
id
|
37940
|
-
}
|
37943
|
+
id
|
37941
37944
|
pc
|
37942
37945
|
is
|
37943
|
-
to
|
37944
|
-
id
|
37945
|
-
}
|
37946
|
+
to
|
37946
37947
|
toAddress
|
37947
37948
|
amount
|
37948
37949
|
assetId
|
@@ -37980,10 +37981,16 @@ spurious results.`);
|
|
37980
37981
|
id
|
37981
37982
|
}
|
37982
37983
|
time
|
37984
|
+
receipts {
|
37985
|
+
...receiptFragment
|
37986
|
+
}
|
37983
37987
|
programState {
|
37984
37988
|
returnType
|
37985
37989
|
data
|
37986
37990
|
}
|
37991
|
+
receipts {
|
37992
|
+
...receiptFragment
|
37993
|
+
}
|
37987
37994
|
}
|
37988
37995
|
... on FailureStatus {
|
37989
37996
|
block {
|
@@ -37991,26 +37998,24 @@ spurious results.`);
|
|
37991
37998
|
}
|
37992
37999
|
time
|
37993
38000
|
reason
|
38001
|
+
receipts {
|
38002
|
+
...receiptFragment
|
38003
|
+
}
|
37994
38004
|
}
|
37995
38005
|
... on SqueezedOutStatus {
|
37996
38006
|
reason
|
37997
38007
|
}
|
37998
38008
|
}
|
37999
|
-
`;
|
38009
|
+
${ReceiptFragmentFragmentDoc}`;
|
38000
38010
|
var TransactionFragmentFragmentDoc = lib_default2`
|
38001
38011
|
fragment transactionFragment on Transaction {
|
38002
38012
|
id
|
38003
38013
|
rawPayload
|
38004
|
-
gasPrice
|
38005
|
-
receipts {
|
38006
|
-
...receiptFragment
|
38007
|
-
}
|
38008
38014
|
status {
|
38009
38015
|
...transactionStatusFragment
|
38010
38016
|
}
|
38011
38017
|
}
|
38012
|
-
${
|
38013
|
-
${TransactionStatusFragmentFragmentDoc}`;
|
38018
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
38014
38019
|
var InputEstimatePredicatesFragmentFragmentDoc = lib_default2`
|
38015
38020
|
fragment inputEstimatePredicatesFragment on Input {
|
38016
38021
|
... on InputCoin {
|
@@ -38028,6 +38033,46 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
38028
38033
|
}
|
38029
38034
|
}
|
38030
38035
|
${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}`;
|
38031
38076
|
var CoinFragmentFragmentDoc = lib_default2`
|
38032
38077
|
fragment coinFragment on Coin {
|
38033
38078
|
__typename
|
@@ -38035,7 +38080,6 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
38035
38080
|
owner
|
38036
38081
|
amount
|
38037
38082
|
assetId
|
38038
|
-
maturity
|
38039
38083
|
blockCreated
|
38040
38084
|
txCreatedIdx
|
38041
38085
|
}
|
@@ -38074,26 +38118,32 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
38074
38118
|
messageBlockHeader {
|
38075
38119
|
id
|
38076
38120
|
daHeight
|
38121
|
+
consensusParametersVersion
|
38122
|
+
stateTransitionBytecodeVersion
|
38077
38123
|
transactionsCount
|
38124
|
+
messageReceiptCount
|
38078
38125
|
transactionsRoot
|
38126
|
+
messageOutboxRoot
|
38127
|
+
eventInboxRoot
|
38079
38128
|
height
|
38080
38129
|
prevRoot
|
38081
38130
|
time
|
38082
38131
|
applicationHash
|
38083
|
-
messageReceiptRoot
|
38084
|
-
messageReceiptCount
|
38085
38132
|
}
|
38086
38133
|
commitBlockHeader {
|
38087
38134
|
id
|
38088
38135
|
daHeight
|
38136
|
+
consensusParametersVersion
|
38137
|
+
stateTransitionBytecodeVersion
|
38089
38138
|
transactionsCount
|
38139
|
+
messageReceiptCount
|
38090
38140
|
transactionsRoot
|
38141
|
+
messageOutboxRoot
|
38142
|
+
eventInboxRoot
|
38091
38143
|
height
|
38092
38144
|
prevRoot
|
38093
38145
|
time
|
38094
38146
|
applicationHash
|
38095
|
-
messageReceiptRoot
|
38096
|
-
messageReceiptCount
|
38097
38147
|
}
|
38098
38148
|
sender
|
38099
38149
|
recipient
|
@@ -38112,8 +38162,8 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
38112
38162
|
var BlockFragmentFragmentDoc = lib_default2`
|
38113
38163
|
fragment blockFragment on Block {
|
38114
38164
|
id
|
38165
|
+
height
|
38115
38166
|
header {
|
38116
|
-
height
|
38117
38167
|
time
|
38118
38168
|
}
|
38119
38169
|
transactions {
|
@@ -38171,6 +38221,11 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
38171
38221
|
`;
|
38172
38222
|
var GasCostsFragmentFragmentDoc = lib_default2`
|
38173
38223
|
fragment GasCostsFragment on GasCosts {
|
38224
|
+
version {
|
38225
|
+
... on Version {
|
38226
|
+
value
|
38227
|
+
}
|
38228
|
+
}
|
38174
38229
|
add
|
38175
38230
|
addi
|
38176
38231
|
aloc
|
@@ -38183,7 +38238,6 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
38183
38238
|
cb
|
38184
38239
|
cfei
|
38185
38240
|
cfsi
|
38186
|
-
croo
|
38187
38241
|
div
|
38188
38242
|
divi
|
38189
38243
|
ecr1
|
@@ -38266,6 +38320,9 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
38266
38320
|
ccp {
|
38267
38321
|
...DependentCostFragment
|
38268
38322
|
}
|
38323
|
+
croo {
|
38324
|
+
...DependentCostFragment
|
38325
|
+
}
|
38269
38326
|
csiz {
|
38270
38327
|
...DependentCostFragment
|
38271
38328
|
}
|
@@ -38325,6 +38382,11 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
38325
38382
|
${DependentCostFragmentFragmentDoc}`;
|
38326
38383
|
var ConsensusParametersFragmentFragmentDoc = lib_default2`
|
38327
38384
|
fragment consensusParametersFragment on ConsensusParameters {
|
38385
|
+
version {
|
38386
|
+
... on Version {
|
38387
|
+
value
|
38388
|
+
}
|
38389
|
+
}
|
38328
38390
|
txParams {
|
38329
38391
|
...TxParametersFragment
|
38330
38392
|
}
|
@@ -38384,18 +38446,9 @@ ${ConsensusParametersFragmentFragmentDoc}`;
|
|
38384
38446
|
fragment nodeInfoFragment on NodeInfo {
|
38385
38447
|
utxoValidation
|
38386
38448
|
vmBacktrace
|
38387
|
-
minGasPrice
|
38388
38449
|
maxTx
|
38389
38450
|
maxDepth
|
38390
38451
|
nodeVersion
|
38391
|
-
peers {
|
38392
|
-
id
|
38393
|
-
addresses
|
38394
|
-
clientVersion
|
38395
|
-
blockHeight
|
38396
|
-
lastHeartbeatMs
|
38397
|
-
appScore
|
38398
|
-
}
|
38399
38452
|
}
|
38400
38453
|
`;
|
38401
38454
|
var GetVersionDocument = lib_default2`
|
@@ -38430,13 +38483,9 @@ ${ConsensusParametersFragmentFragmentDoc}`;
|
|
38430
38483
|
query getTransactionWithReceipts($transactionId: TransactionId!) {
|
38431
38484
|
transaction(id: $transactionId) {
|
38432
38485
|
...transactionFragment
|
38433
|
-
receipts {
|
38434
|
-
...receiptFragment
|
38435
|
-
}
|
38436
38486
|
}
|
38437
38487
|
}
|
38438
|
-
${TransactionFragmentFragmentDoc}
|
38439
|
-
${ReceiptFragmentFragmentDoc}`;
|
38488
|
+
${TransactionFragmentFragmentDoc}`;
|
38440
38489
|
var GetTransactionsDocument = lib_default2`
|
38441
38490
|
query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
|
38442
38491
|
transactions(after: $after, before: $before, first: $first, last: $last) {
|
@@ -38564,6 +38613,20 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38564
38613
|
}
|
38565
38614
|
}
|
38566
38615
|
${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
|
+
`;
|
38567
38630
|
var GetBalancesDocument = lib_default2`
|
38568
38631
|
query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
38569
38632
|
balances(
|
@@ -38618,12 +38681,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38618
38681
|
}
|
38619
38682
|
`;
|
38620
38683
|
var DryRunDocument = lib_default2`
|
38621
|
-
mutation dryRun($
|
38622
|
-
dryRun(
|
38623
|
-
...
|
38684
|
+
mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
|
38685
|
+
dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
|
38686
|
+
...dryRunTransactionExecutionStatusFragment
|
38624
38687
|
}
|
38625
38688
|
}
|
38626
|
-
${
|
38689
|
+
${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
|
38627
38690
|
var SubmitDocument = lib_default2`
|
38628
38691
|
mutation submit($encodedTransaction: HexString!) {
|
38629
38692
|
submit(tx: $encodedTransaction) {
|
@@ -38706,6 +38769,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38706
38769
|
getBalance(variables, options) {
|
38707
38770
|
return requester(GetBalanceDocument, variables, options);
|
38708
38771
|
},
|
38772
|
+
getLatestGasPrice(variables, options) {
|
38773
|
+
return requester(GetLatestGasPriceDocument, variables, options);
|
38774
|
+
},
|
38775
|
+
estimateGasPrice(variables, options) {
|
38776
|
+
return requester(EstimateGasPriceDocument, variables, options);
|
38777
|
+
},
|
38709
38778
|
getBalances(variables, options) {
|
38710
38779
|
return requester(GetBalancesDocument, variables, options);
|
38711
38780
|
},
|
@@ -38870,9 +38939,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38870
38939
|
}
|
38871
38940
|
};
|
38872
38941
|
|
38873
|
-
// ../address/dist/configs.mjs
|
38874
|
-
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
38875
|
-
|
38876
38942
|
// src/providers/transaction-request/input.ts
|
38877
38943
|
var inputify = (value) => {
|
38878
38944
|
const { type: type3 } = value;
|
@@ -38892,10 +38958,9 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38892
38958
|
txIndex: toNumber2(arrayify(value.txPointer).slice(8, 16))
|
38893
38959
|
},
|
38894
38960
|
witnessIndex: value.witnessIndex,
|
38895
|
-
maturity: value.maturity ?? 0,
|
38896
38961
|
predicateGasUsed: bn(value.predicateGasUsed),
|
38897
|
-
predicateLength: predicate.length,
|
38898
|
-
predicateDataLength: predicateData.length,
|
38962
|
+
predicateLength: bn(predicate.length),
|
38963
|
+
predicateDataLength: bn(predicateData.length),
|
38899
38964
|
predicate: hexlify(predicate),
|
38900
38965
|
predicateData: hexlify(predicateData)
|
38901
38966
|
};
|
@@ -38926,8 +38991,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38926
38991
|
nonce: hexlify(value.nonce),
|
38927
38992
|
witnessIndex: value.witnessIndex,
|
38928
38993
|
predicateGasUsed: bn(value.predicateGasUsed),
|
38929
|
-
predicateLength: predicate.length,
|
38930
|
-
predicateDataLength: predicateData.length,
|
38994
|
+
predicateLength: bn(predicate.length),
|
38995
|
+
predicateDataLength: bn(predicateData.length),
|
38931
38996
|
predicate: hexlify(predicate),
|
38932
38997
|
predicateData: hexlify(predicateData),
|
38933
38998
|
data: hexlify(data),
|
@@ -39087,8 +39152,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39087
39152
|
case "CALL" /* Call */: {
|
39088
39153
|
const callReceipt = {
|
39089
39154
|
type: ReceiptType.Call,
|
39090
|
-
from: hexOrZero(receipt.
|
39091
|
-
to: hexOrZero(receipt?.to
|
39155
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
39156
|
+
to: hexOrZero(receipt?.to),
|
39092
39157
|
amount: bn(receipt.amount),
|
39093
39158
|
assetId: hexOrZero(receipt.assetId),
|
39094
39159
|
gas: bn(receipt.gas),
|
@@ -39102,7 +39167,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39102
39167
|
case "RETURN" /* Return */: {
|
39103
39168
|
const returnReceipt = {
|
39104
39169
|
type: ReceiptType.Return,
|
39105
|
-
id: hexOrZero(receipt.
|
39170
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
39106
39171
|
val: bn(receipt.val),
|
39107
39172
|
pc: bn(receipt.pc),
|
39108
39173
|
is: bn(receipt.is)
|
@@ -39112,7 +39177,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39112
39177
|
case "RETURN_DATA" /* ReturnData */: {
|
39113
39178
|
const returnDataReceipt = {
|
39114
39179
|
type: ReceiptType.ReturnData,
|
39115
|
-
id: hexOrZero(receipt.
|
39180
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
39116
39181
|
ptr: bn(receipt.ptr),
|
39117
39182
|
len: bn(receipt.len),
|
39118
39183
|
digest: hexOrZero(receipt.digest),
|
@@ -39124,7 +39189,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39124
39189
|
case "PANIC" /* Panic */: {
|
39125
39190
|
const panicReceipt = {
|
39126
39191
|
type: ReceiptType.Panic,
|
39127
|
-
id: hexOrZero(receipt.
|
39192
|
+
id: hexOrZero(receipt.id),
|
39128
39193
|
reason: bn(receipt.reason),
|
39129
39194
|
pc: bn(receipt.pc),
|
39130
39195
|
is: bn(receipt.is),
|
@@ -39135,7 +39200,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39135
39200
|
case "REVERT" /* Revert */: {
|
39136
39201
|
const revertReceipt = {
|
39137
39202
|
type: ReceiptType.Revert,
|
39138
|
-
id: hexOrZero(receipt.
|
39203
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
39139
39204
|
val: bn(receipt.ra),
|
39140
39205
|
pc: bn(receipt.pc),
|
39141
39206
|
is: bn(receipt.is)
|
@@ -39145,7 +39210,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39145
39210
|
case "LOG" /* Log */: {
|
39146
39211
|
const logReceipt = {
|
39147
39212
|
type: ReceiptType.Log,
|
39148
|
-
id: hexOrZero(receipt.
|
39213
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
39149
39214
|
val0: bn(receipt.ra),
|
39150
39215
|
val1: bn(receipt.rb),
|
39151
39216
|
val2: bn(receipt.rc),
|
@@ -39158,7 +39223,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39158
39223
|
case "LOG_DATA" /* LogData */: {
|
39159
39224
|
const logDataReceipt = {
|
39160
39225
|
type: ReceiptType.LogData,
|
39161
|
-
id: hexOrZero(receipt.
|
39226
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
39162
39227
|
val0: bn(receipt.ra),
|
39163
39228
|
val1: bn(receipt.rb),
|
39164
39229
|
ptr: bn(receipt.ptr),
|
@@ -39172,8 +39237,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39172
39237
|
case "TRANSFER" /* Transfer */: {
|
39173
39238
|
const transferReceipt = {
|
39174
39239
|
type: ReceiptType.Transfer,
|
39175
|
-
from: hexOrZero(receipt.
|
39176
|
-
to: hexOrZero(receipt.toAddress || receipt?.to
|
39240
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
39241
|
+
to: hexOrZero(receipt.toAddress || receipt?.to),
|
39177
39242
|
amount: bn(receipt.amount),
|
39178
39243
|
assetId: hexOrZero(receipt.assetId),
|
39179
39244
|
pc: bn(receipt.pc),
|
@@ -39184,8 +39249,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39184
39249
|
case "TRANSFER_OUT" /* TransferOut */: {
|
39185
39250
|
const transferOutReceipt = {
|
39186
39251
|
type: ReceiptType.TransferOut,
|
39187
|
-
from: hexOrZero(receipt.
|
39188
|
-
to: hexOrZero(receipt.toAddress || receipt.to
|
39252
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
39253
|
+
to: hexOrZero(receipt.toAddress || receipt.to),
|
39189
39254
|
amount: bn(receipt.amount),
|
39190
39255
|
assetId: hexOrZero(receipt.assetId),
|
39191
39256
|
pc: bn(receipt.pc),
|
@@ -39228,7 +39293,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39228
39293
|
return receiptMessageOut;
|
39229
39294
|
}
|
39230
39295
|
case "MINT" /* Mint */: {
|
39231
|
-
const contractId = hexOrZero(receipt.
|
39296
|
+
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
39232
39297
|
const subId = hexOrZero(receipt.subId);
|
39233
39298
|
const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
|
39234
39299
|
const mintReceipt = {
|
@@ -39243,7 +39308,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39243
39308
|
return mintReceipt;
|
39244
39309
|
}
|
39245
39310
|
case "BURN" /* Burn */: {
|
39246
|
-
const contractId = hexOrZero(receipt.
|
39311
|
+
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
39247
39312
|
const subId = hexOrZero(receipt.subId);
|
39248
39313
|
const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
|
39249
39314
|
const burnReceipt = {
|
@@ -39324,7 +39389,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39324
39389
|
};
|
39325
39390
|
|
39326
39391
|
// src/providers/utils/gas.ts
|
39327
|
-
var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
|
39328
39392
|
var getGasUsedFromReceipts = (receipts) => {
|
39329
39393
|
const scriptResult = receipts.filter(
|
39330
39394
|
(receipt) => receipt.type === ReceiptType.ScriptResult
|
@@ -39345,18 +39409,28 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39345
39409
|
}
|
39346
39410
|
function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
39347
39411
|
const witnessCache = [];
|
39348
|
-
const
|
39412
|
+
const chargeableInputs = inputs.filter((input) => {
|
39413
|
+
const isCoinOrMessage = "owner" in input || "sender" in input;
|
39414
|
+
if (isCoinOrMessage) {
|
39415
|
+
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
39416
|
+
return true;
|
39417
|
+
}
|
39418
|
+
if (!witnessCache.includes(input.witnessIndex)) {
|
39419
|
+
witnessCache.push(input.witnessIndex);
|
39420
|
+
return true;
|
39421
|
+
}
|
39422
|
+
}
|
39423
|
+
return false;
|
39424
|
+
});
|
39425
|
+
const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
|
39426
|
+
const totalGas = chargeableInputs.reduce((total, input) => {
|
39349
39427
|
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
39350
39428
|
return total.add(
|
39351
|
-
|
39429
|
+
vmInitializationCost.add(resolveGasDependentCosts(arrayify(input.predicate).length, gasCosts.contractRoot)).add(bn(input.predicateGasUsed))
|
39352
39430
|
);
|
39353
39431
|
}
|
39354
|
-
|
39355
|
-
|
39356
|
-
return total.add(gasCosts.ecr1);
|
39357
|
-
}
|
39358
|
-
return total;
|
39359
|
-
}, bn());
|
39432
|
+
return total.add(gasCosts.ecr1);
|
39433
|
+
}, bn(0));
|
39360
39434
|
return totalGas;
|
39361
39435
|
}
|
39362
39436
|
function getMinGas(params) {
|
@@ -39368,12 +39442,20 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39368
39442
|
return minGas;
|
39369
39443
|
}
|
39370
39444
|
function getMaxGas(params) {
|
39371
|
-
const {
|
39445
|
+
const {
|
39446
|
+
gasPerByte,
|
39447
|
+
witnessesLength,
|
39448
|
+
witnessLimit,
|
39449
|
+
minGas,
|
39450
|
+
gasLimit = bn(0),
|
39451
|
+
maxGasPerTx
|
39452
|
+
} = params;
|
39372
39453
|
let remainingAllowedWitnessGas = bn(0);
|
39373
39454
|
if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
|
39374
39455
|
remainingAllowedWitnessGas = bn(witnessLimit).sub(witnessesLength).mul(gasPerByte);
|
39375
39456
|
}
|
39376
|
-
|
39457
|
+
const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
|
39458
|
+
return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
|
39377
39459
|
}
|
39378
39460
|
function calculateMetadataGasForTxCreate({
|
39379
39461
|
gasCosts,
|
@@ -39395,6 +39477,10 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39395
39477
|
}) {
|
39396
39478
|
return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
39397
39479
|
}
|
39480
|
+
var calculateGasFee = (params) => {
|
39481
|
+
const { gas, gasPrice, priceFactor, tip } = params;
|
39482
|
+
return gas.mul(gasPrice).div(priceFactor).add(tip);
|
39483
|
+
};
|
39398
39484
|
|
39399
39485
|
// src/providers/utils/json.ts
|
39400
39486
|
function normalize2(object) {
|
@@ -39536,7 +39622,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39536
39622
|
// src/providers/transaction-request/transaction-request.ts
|
39537
39623
|
var BaseTransactionRequest = class {
|
39538
39624
|
/** Gas price for transaction */
|
39539
|
-
|
39625
|
+
tip;
|
39540
39626
|
/** Block until which tx cannot be included */
|
39541
39627
|
maturity;
|
39542
39628
|
/** The maximum fee payable by this transaction using BASE_ASSET. */
|
@@ -39549,38 +39635,34 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39549
39635
|
outputs = [];
|
39550
39636
|
/** List of witnesses */
|
39551
39637
|
witnesses = [];
|
39552
|
-
/** Base asset ID - should be fetched from the chain */
|
39553
|
-
baseAssetId;
|
39554
39638
|
/**
|
39555
39639
|
* Constructor for initializing a base transaction request.
|
39556
39640
|
*
|
39557
39641
|
* @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
|
39558
39642
|
*/
|
39559
39643
|
constructor({
|
39560
|
-
|
39644
|
+
tip,
|
39561
39645
|
maturity,
|
39562
39646
|
maxFee,
|
39563
39647
|
witnessLimit,
|
39564
39648
|
inputs,
|
39565
39649
|
outputs,
|
39566
|
-
witnesses
|
39567
|
-
|
39568
|
-
|
39569
|
-
this.gasPrice = bn(gasPrice);
|
39650
|
+
witnesses
|
39651
|
+
} = {}) {
|
39652
|
+
this.tip = bn(tip);
|
39570
39653
|
this.maturity = maturity ?? 0;
|
39571
39654
|
this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
|
39572
39655
|
this.maxFee = maxFee ? bn(maxFee) : void 0;
|
39573
39656
|
this.inputs = inputs ?? [];
|
39574
39657
|
this.outputs = outputs ?? [];
|
39575
39658
|
this.witnesses = witnesses ?? [];
|
39576
|
-
this.baseAssetId = baseAssetId;
|
39577
39659
|
}
|
39578
39660
|
static getPolicyMeta(req) {
|
39579
39661
|
let policyTypes = 0;
|
39580
39662
|
const policies = [];
|
39581
|
-
if (req.
|
39582
|
-
policyTypes += PolicyType.
|
39583
|
-
policies.push({ data: req.
|
39663
|
+
if (req.tip) {
|
39664
|
+
policyTypes += PolicyType.Tip;
|
39665
|
+
policies.push({ data: req.tip, type: PolicyType.Tip });
|
39584
39666
|
}
|
39585
39667
|
if (req.witnessLimit) {
|
39586
39668
|
policyTypes += PolicyType.WitnessLimit;
|
@@ -39767,10 +39849,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39767
39849
|
* @param predicate - Predicate bytes.
|
39768
39850
|
* @param predicateData - Predicate data bytes.
|
39769
39851
|
*/
|
39770
|
-
addCoinInput(coin
|
39852
|
+
addCoinInput(coin) {
|
39771
39853
|
const { assetId, owner, amount } = coin;
|
39772
39854
|
let witnessIndex;
|
39773
|
-
if (predicate) {
|
39855
|
+
if (coin.predicate) {
|
39774
39856
|
witnessIndex = 0;
|
39775
39857
|
} else {
|
39776
39858
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
|
@@ -39785,8 +39867,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39785
39867
|
amount,
|
39786
39868
|
assetId,
|
39787
39869
|
txPointer: "0x00000000000000000000000000000000",
|
39788
|
-
witnessIndex
|
39789
|
-
predicate: predicate?.bytes
|
39870
|
+
witnessIndex
|
39790
39871
|
};
|
39791
39872
|
this.pushInput(input);
|
39792
39873
|
this.addChangeOutput(owner, assetId);
|
@@ -39797,11 +39878,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39797
39878
|
*
|
39798
39879
|
* @param message - Message resource.
|
39799
39880
|
* @param predicate - Predicate bytes.
|
39881
|
+
* @param predicateData - Predicate data bytes.
|
39800
39882
|
*/
|
39801
|
-
addMessageInput(message
|
39883
|
+
addMessageInput(message) {
|
39802
39884
|
const { recipient, sender, amount } = message;
|
39885
|
+
const assetId = BaseAssetId;
|
39803
39886
|
let witnessIndex;
|
39804
|
-
if (predicate) {
|
39887
|
+
if (message.predicate) {
|
39805
39888
|
witnessIndex = 0;
|
39806
39889
|
} else {
|
39807
39890
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
|
@@ -39815,11 +39898,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39815
39898
|
sender: sender.toB256(),
|
39816
39899
|
recipient: recipient.toB256(),
|
39817
39900
|
amount,
|
39818
|
-
witnessIndex
|
39819
|
-
predicate: predicate?.bytes
|
39901
|
+
witnessIndex
|
39820
39902
|
};
|
39821
39903
|
this.pushInput(input);
|
39822
|
-
this.addChangeOutput(recipient,
|
39904
|
+
this.addChangeOutput(recipient, assetId);
|
39823
39905
|
}
|
39824
39906
|
/**
|
39825
39907
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -39847,32 +39929,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39847
39929
|
resources.forEach((resource) => this.addResource(resource));
|
39848
39930
|
return this;
|
39849
39931
|
}
|
39850
|
-
/**
|
39851
|
-
* Adds multiple resources to the transaction by adding coin/message inputs and change
|
39852
|
-
* outputs from the related assetIds.
|
39853
|
-
*
|
39854
|
-
* @param resources - The resources to add.
|
39855
|
-
* @returns This transaction.
|
39856
|
-
*/
|
39857
|
-
addPredicateResource(resource, predicate) {
|
39858
|
-
if (isCoin(resource)) {
|
39859
|
-
this.addCoinInput(resource, predicate);
|
39860
|
-
} else {
|
39861
|
-
this.addMessageInput(resource, predicate);
|
39862
|
-
}
|
39863
|
-
return this;
|
39864
|
-
}
|
39865
|
-
/**
|
39866
|
-
* Adds multiple predicate coin/message inputs to the transaction and change outputs
|
39867
|
-
* from the related assetIds.
|
39868
|
-
*
|
39869
|
-
* @param resources - The resources to add.
|
39870
|
-
* @returns This transaction.
|
39871
|
-
*/
|
39872
|
-
addPredicateResources(resources, predicate) {
|
39873
|
-
resources.forEach((resource) => this.addPredicateResource(resource, predicate));
|
39874
|
-
return this;
|
39875
|
-
}
|
39876
39932
|
/**
|
39877
39933
|
* Adds a coin output to the transaction.
|
39878
39934
|
*
|
@@ -39880,12 +39936,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39880
39936
|
* @param amount - Amount of coin.
|
39881
39937
|
* @param assetId - Asset ID of coin.
|
39882
39938
|
*/
|
39883
|
-
addCoinOutput(to, amount, assetId) {
|
39939
|
+
addCoinOutput(to, amount, assetId = BaseAssetId) {
|
39884
39940
|
this.pushOutput({
|
39885
39941
|
type: OutputType.Coin,
|
39886
39942
|
to: addressify(to).toB256(),
|
39887
39943
|
amount,
|
39888
|
-
assetId
|
39944
|
+
assetId
|
39889
39945
|
});
|
39890
39946
|
return this;
|
39891
39947
|
}
|
@@ -39912,7 +39968,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39912
39968
|
* @param to - Address of the owner.
|
39913
39969
|
* @param assetId - Asset ID of coin.
|
39914
39970
|
*/
|
39915
|
-
addChangeOutput(to, assetId) {
|
39971
|
+
addChangeOutput(to, assetId = BaseAssetId) {
|
39916
39972
|
const changeOutput = this.getChangeOutputs().find(
|
39917
39973
|
(output3) => hexlify(output3.assetId) === assetId
|
39918
39974
|
);
|
@@ -39920,7 +39976,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39920
39976
|
this.pushOutput({
|
39921
39977
|
type: OutputType.Change,
|
39922
39978
|
to: addressify(to).toB256(),
|
39923
|
-
assetId
|
39979
|
+
assetId
|
39924
39980
|
});
|
39925
39981
|
}
|
39926
39982
|
}
|
@@ -39952,7 +40008,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39952
40008
|
}
|
39953
40009
|
calculateMaxGas(chainInfo, minGas) {
|
39954
40010
|
const { consensusParameters } = chainInfo;
|
39955
|
-
const { gasPerByte } = consensusParameters;
|
40011
|
+
const { gasPerByte, maxGasPerTx } = consensusParameters;
|
39956
40012
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
39957
40013
|
(acc, wit) => acc + wit.dataLength,
|
39958
40014
|
0
|
@@ -39961,7 +40017,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39961
40017
|
gasPerByte,
|
39962
40018
|
minGas,
|
39963
40019
|
witnessesLength,
|
39964
|
-
witnessLimit: this.witnessLimit
|
40020
|
+
witnessLimit: this.witnessLimit,
|
40021
|
+
maxGasPerTx
|
39965
40022
|
});
|
39966
40023
|
}
|
39967
40024
|
/**
|
@@ -39979,24 +40036,27 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39979
40036
|
});
|
39980
40037
|
const updateAssetInput = (assetId, quantity) => {
|
39981
40038
|
const assetInput = findAssetInput(assetId);
|
40039
|
+
let usedQuantity = quantity;
|
40040
|
+
if (assetId === BaseAssetId) {
|
40041
|
+
usedQuantity = bn("1000000000000000000");
|
40042
|
+
}
|
39982
40043
|
if (assetInput && "assetId" in assetInput) {
|
39983
40044
|
assetInput.id = hexlify(randomBytes22(UTXO_ID_LEN));
|
39984
|
-
assetInput.amount =
|
40045
|
+
assetInput.amount = usedQuantity;
|
39985
40046
|
} else {
|
39986
40047
|
this.addResources([
|
39987
40048
|
{
|
39988
40049
|
id: hexlify(randomBytes22(UTXO_ID_LEN)),
|
39989
|
-
amount:
|
40050
|
+
amount: usedQuantity,
|
39990
40051
|
assetId,
|
39991
40052
|
owner: resourcesOwner || Address.fromRandom(),
|
39992
|
-
maturity: 0,
|
39993
40053
|
blockCreated: bn(1),
|
39994
40054
|
txCreatedIdx: bn(1)
|
39995
40055
|
}
|
39996
40056
|
]);
|
39997
40057
|
}
|
39998
40058
|
};
|
39999
|
-
updateAssetInput(
|
40059
|
+
updateAssetInput(BaseAssetId, bn(1e11));
|
40000
40060
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
40001
40061
|
}
|
40002
40062
|
/**
|
@@ -40021,7 +40081,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40021
40081
|
toJSON() {
|
40022
40082
|
return normalizeJSON(this);
|
40023
40083
|
}
|
40024
|
-
|
40084
|
+
updatePredicateGasUsed(inputs) {
|
40025
40085
|
this.inputs.forEach((i) => {
|
40026
40086
|
let correspondingInput;
|
40027
40087
|
switch (i.type) {
|
@@ -40043,6 +40103,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40043
40103
|
}
|
40044
40104
|
});
|
40045
40105
|
}
|
40106
|
+
shiftPredicateData() {
|
40107
|
+
this.inputs.forEach((input) => {
|
40108
|
+
if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
|
40109
|
+
input.predicateData = input.paddPredicateData(
|
40110
|
+
BaseTransactionRequest.getPolicyMeta(this).policies.length
|
40111
|
+
);
|
40112
|
+
}
|
40113
|
+
});
|
40114
|
+
}
|
40046
40115
|
};
|
40047
40116
|
|
40048
40117
|
// src/providers/transaction-request/hash-transaction.ts
|
@@ -40153,7 +40222,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40153
40222
|
*
|
40154
40223
|
* @param createTransactionRequestLike - The initial values for the instance
|
40155
40224
|
*/
|
40156
|
-
constructor({
|
40225
|
+
constructor({
|
40226
|
+
bytecodeWitnessIndex,
|
40227
|
+
salt,
|
40228
|
+
storageSlots,
|
40229
|
+
...rest
|
40230
|
+
} = {}) {
|
40157
40231
|
super(rest);
|
40158
40232
|
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
40159
40233
|
this.salt = hexlify(salt ?? ZeroBytes32);
|
@@ -40171,9 +40245,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40171
40245
|
return {
|
40172
40246
|
type: TransactionType.Create,
|
40173
40247
|
...baseTransaction,
|
40174
|
-
bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
|
40175
40248
|
bytecodeWitnessIndex,
|
40176
|
-
storageSlotsCount: storageSlots.length,
|
40249
|
+
storageSlotsCount: bn(storageSlots.length),
|
40177
40250
|
salt: this.salt ? hexlify(this.salt) : ZeroBytes32,
|
40178
40251
|
storageSlots
|
40179
40252
|
};
|
@@ -40268,7 +40341,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40268
40341
|
*
|
40269
40342
|
* @param scriptTransactionRequestLike - The initial values for the instance.
|
40270
40343
|
*/
|
40271
|
-
constructor({ script, scriptData, gasLimit, ...rest }) {
|
40344
|
+
constructor({ script, scriptData, gasLimit, ...rest } = {}) {
|
40272
40345
|
super(rest);
|
40273
40346
|
this.gasLimit = bn(gasLimit);
|
40274
40347
|
this.script = arrayify(script ?? returnZeroScript.bytes);
|
@@ -40287,8 +40360,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40287
40360
|
type: TransactionType.Script,
|
40288
40361
|
scriptGasLimit: this.gasLimit,
|
40289
40362
|
...super.getBaseTransaction(),
|
40290
|
-
scriptLength: script.length,
|
40291
|
-
scriptDataLength: scriptData.length,
|
40363
|
+
scriptLength: bn(script.length),
|
40364
|
+
scriptDataLength: bn(scriptData.length),
|
40292
40365
|
receiptsRoot: ZeroBytes32,
|
40293
40366
|
script: hexlify(script),
|
40294
40367
|
scriptData: hexlify(scriptData)
|
@@ -40352,7 +40425,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40352
40425
|
}
|
40353
40426
|
calculateMaxGas(chainInfo, minGas) {
|
40354
40427
|
const { consensusParameters } = chainInfo;
|
40355
|
-
const { gasPerByte } = consensusParameters;
|
40428
|
+
const { gasPerByte, maxGasPerTx } = consensusParameters;
|
40356
40429
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
40357
40430
|
(acc, wit) => acc + wit.dataLength,
|
40358
40431
|
0
|
@@ -40362,7 +40435,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40362
40435
|
minGas,
|
40363
40436
|
witnessesLength,
|
40364
40437
|
witnessLimit: this.witnessLimit,
|
40365
|
-
gasLimit: this.gasLimit
|
40438
|
+
gasLimit: this.gasLimit,
|
40439
|
+
maxGasPerTx
|
40366
40440
|
});
|
40367
40441
|
}
|
40368
40442
|
/**
|
@@ -40435,13 +40509,29 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40435
40509
|
}
|
40436
40510
|
}
|
40437
40511
|
};
|
40512
|
+
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
40513
|
+
(acc, input) => {
|
40514
|
+
if (input.type === InputType.Coin && input.owner === owner) {
|
40515
|
+
acc.utxos.push(input.id);
|
40516
|
+
}
|
40517
|
+
if (input.type === InputType.Message && input.recipient === owner) {
|
40518
|
+
acc.messages.push(input.nonce);
|
40519
|
+
}
|
40520
|
+
return acc;
|
40521
|
+
},
|
40522
|
+
{
|
40523
|
+
utxos: [],
|
40524
|
+
messages: []
|
40525
|
+
}
|
40526
|
+
);
|
40438
40527
|
|
40439
40528
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
40440
40529
|
var calculateTransactionFee = (params) => {
|
40441
40530
|
const {
|
40442
|
-
|
40531
|
+
gasPrice,
|
40443
40532
|
rawPayload,
|
40444
|
-
|
40533
|
+
tip,
|
40534
|
+
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
40445
40535
|
} = params;
|
40446
40536
|
const gasPerByte = bn(feeParams.gasPerByte);
|
40447
40537
|
const gasPriceFactor = bn(feeParams.gasPriceFactor);
|
@@ -40451,8 +40541,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40451
40541
|
return {
|
40452
40542
|
fee: bn(0),
|
40453
40543
|
minFee: bn(0),
|
40454
|
-
maxFee: bn(0)
|
40455
|
-
feeFromGasUsed: bn(0)
|
40544
|
+
maxFee: bn(0)
|
40456
40545
|
};
|
40457
40546
|
}
|
40458
40547
|
const { type: type3, witnesses, inputs, policies } = transaction;
|
@@ -40484,7 +40573,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40484
40573
|
metadataGas,
|
40485
40574
|
txBytesSize: transactionBytes.length
|
40486
40575
|
});
|
40487
|
-
const gasPrice = bn(policies.find((policy) => policy.type === PolicyType.GasPrice)?.data);
|
40488
40576
|
const witnessLimit = policies.find((policy) => policy.type === PolicyType.WitnessLimit)?.data;
|
40489
40577
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
40490
40578
|
const maxGas = getMaxGas({
|
@@ -40492,17 +40580,25 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40492
40580
|
minGas,
|
40493
40581
|
witnessesLength,
|
40494
40582
|
gasLimit,
|
40495
|
-
witnessLimit
|
40583
|
+
witnessLimit,
|
40584
|
+
maxGasPerTx
|
40585
|
+
});
|
40586
|
+
const minFee = calculateGasFee({
|
40587
|
+
gasPrice,
|
40588
|
+
gas: minGas,
|
40589
|
+
priceFactor: gasPriceFactor,
|
40590
|
+
tip
|
40591
|
+
});
|
40592
|
+
const maxFee = calculateGasFee({
|
40593
|
+
gasPrice,
|
40594
|
+
gas: maxGas,
|
40595
|
+
priceFactor: gasPriceFactor,
|
40596
|
+
tip
|
40496
40597
|
});
|
40497
|
-
const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
|
40498
|
-
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
|
40499
|
-
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
|
40500
|
-
const fee = minFee.add(feeFromGasUsed);
|
40501
40598
|
return {
|
40502
|
-
fee,
|
40503
40599
|
minFee,
|
40504
40600
|
maxFee,
|
40505
|
-
|
40601
|
+
fee: maxFee
|
40506
40602
|
};
|
40507
40603
|
};
|
40508
40604
|
|
@@ -41103,7 +41199,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41103
41199
|
gqlTransactionStatus,
|
41104
41200
|
abiMap = {},
|
41105
41201
|
maxInputs,
|
41106
|
-
gasCosts
|
41202
|
+
gasCosts,
|
41203
|
+
maxGasPerTx,
|
41204
|
+
gasPrice
|
41107
41205
|
} = params;
|
41108
41206
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
41109
41207
|
const rawPayload = hexlify(transactionBytes);
|
@@ -41117,11 +41215,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41117
41215
|
maxInputs
|
41118
41216
|
});
|
41119
41217
|
const typeName = getTransactionTypeName(transaction.type);
|
41218
|
+
const tip = bn(transaction.policies?.find((policy) => policy.type === PolicyType.Tip)?.data);
|
41120
41219
|
const { fee } = calculateTransactionFee({
|
41121
|
-
|
41220
|
+
gasPrice,
|
41122
41221
|
rawPayload,
|
41222
|
+
tip,
|
41123
41223
|
consensusParameters: {
|
41124
41224
|
gasCosts,
|
41225
|
+
maxGasPerTx,
|
41125
41226
|
feeParams: {
|
41126
41227
|
gasPerByte,
|
41127
41228
|
gasPriceFactor
|
@@ -41257,8 +41358,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41257
41358
|
const decodedTransaction = this.decodeTransaction(
|
41258
41359
|
transaction
|
41259
41360
|
);
|
41260
|
-
|
41261
|
-
|
41361
|
+
let txReceipts = [];
|
41362
|
+
if (transaction?.status && "receipts" in transaction.status) {
|
41363
|
+
txReceipts = transaction.status.receipts;
|
41364
|
+
}
|
41365
|
+
const receipts = txReceipts.map(processGqlReceipt) || [];
|
41366
|
+
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
41367
|
+
const gasPrice = await this.provider.getLatestGasPrice();
|
41262
41368
|
const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
|
41263
41369
|
const transactionSummary = assembleTransactionSummary({
|
41264
41370
|
id: this.id,
|
@@ -41270,7 +41376,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41270
41376
|
gasPriceFactor,
|
41271
41377
|
abiMap: contractsAbiMap,
|
41272
41378
|
maxInputs,
|
41273
|
-
gasCosts
|
41379
|
+
gasCosts,
|
41380
|
+
maxGasPerTx,
|
41381
|
+
gasPrice
|
41274
41382
|
});
|
41275
41383
|
return transactionSummary;
|
41276
41384
|
}
|
@@ -41414,13 +41522,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41414
41522
|
gasPerByte: bn(feeParams.gasPerByte),
|
41415
41523
|
maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
|
41416
41524
|
chainId: bn(consensusParameters.chainId),
|
41417
|
-
baseAssetId: consensusParameters.baseAssetId,
|
41418
41525
|
gasCosts
|
41419
41526
|
},
|
41420
41527
|
gasCosts,
|
41421
41528
|
latestBlock: {
|
41422
41529
|
id: latestBlock.id,
|
41423
|
-
height: bn(latestBlock.
|
41530
|
+
height: bn(latestBlock.height),
|
41424
41531
|
time: latestBlock.header.time,
|
41425
41532
|
transactions: latestBlock.transactions.map((i) => ({
|
41426
41533
|
id: i.id
|
@@ -41514,10 +41621,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41514
41621
|
* Returns some helpful parameters related to gas fees.
|
41515
41622
|
*/
|
41516
41623
|
getGasConfig() {
|
41517
|
-
const { minGasPrice } = this.getNode();
|
41518
41624
|
const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
|
41519
41625
|
return {
|
41520
|
-
minGasPrice,
|
41521
41626
|
maxGasPerTx,
|
41522
41627
|
maxGasPerPredicate,
|
41523
41628
|
gasPriceFactor,
|
@@ -41615,7 +41720,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41615
41720
|
*/
|
41616
41721
|
async getBlockNumber() {
|
41617
41722
|
const { chain } = await this.operations.getChain();
|
41618
|
-
return bn(chain.latestBlock.
|
41723
|
+
return bn(chain.latestBlock.height, 10);
|
41619
41724
|
}
|
41620
41725
|
/**
|
41621
41726
|
* Returns the chain information.
|
@@ -41627,11 +41732,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41627
41732
|
const processedNodeInfo = {
|
41628
41733
|
maxDepth: bn(nodeInfo.maxDepth),
|
41629
41734
|
maxTx: bn(nodeInfo.maxTx),
|
41630
|
-
minGasPrice: bn(nodeInfo.minGasPrice),
|
41631
41735
|
nodeVersion: nodeInfo.nodeVersion,
|
41632
41736
|
utxoValidation: nodeInfo.utxoValidation,
|
41633
|
-
vmBacktrace: nodeInfo.vmBacktrace
|
41634
|
-
peers: nodeInfo.peers
|
41737
|
+
vmBacktrace: nodeInfo.vmBacktrace
|
41635
41738
|
};
|
41636
41739
|
_Provider.nodeInfoCache[this.url] = processedNodeInfo;
|
41637
41740
|
return processedNodeInfo;
|
@@ -41657,17 +41760,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41657
41760
|
} = this.getChain();
|
41658
41761
|
return chainId.toNumber();
|
41659
41762
|
}
|
41660
|
-
/**
|
41661
|
-
* Returns the base asset ID
|
41662
|
-
*
|
41663
|
-
* @returns A promise that resolves to the base asset ID
|
41664
|
-
*/
|
41665
|
-
getBaseAssetId() {
|
41666
|
-
const {
|
41667
|
-
consensusParameters: { baseAssetId }
|
41668
|
-
} = this.getChain();
|
41669
|
-
return baseAssetId;
|
41670
|
-
}
|
41671
41763
|
/**
|
41672
41764
|
* Submits a transaction to the chain to be executed.
|
41673
41765
|
*
|
@@ -41728,14 +41820,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41728
41820
|
return this.estimateTxDependencies(transactionRequest);
|
41729
41821
|
}
|
41730
41822
|
const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
|
41731
|
-
const { dryRun:
|
41732
|
-
encodedTransaction,
|
41823
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
41824
|
+
encodedTransactions: encodedTransaction,
|
41733
41825
|
utxoValidation: utxoValidation || false
|
41734
41826
|
});
|
41735
|
-
const receipts =
|
41736
|
-
|
41737
|
-
|
41738
|
-
};
|
41827
|
+
const [{ receipts: rawReceipts, status }] = dryRunStatuses;
|
41828
|
+
const receipts = rawReceipts.map(processGqlReceipt);
|
41829
|
+
return { receipts, dryrunStatus: status };
|
41739
41830
|
}
|
41740
41831
|
/**
|
41741
41832
|
* Verifies whether enough gas is available to complete transaction.
|
@@ -41774,9 +41865,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41774
41865
|
* If there are missing variable outputs,
|
41775
41866
|
* `addVariableOutputs` is called on the transaction.
|
41776
41867
|
*
|
41777
|
-
* @privateRemarks
|
41778
|
-
* TODO: Investigate support for missing contract IDs
|
41779
|
-
* TODO: Add support for missing output messages
|
41780
41868
|
*
|
41781
41869
|
* @param transactionRequest - The transaction request object.
|
41782
41870
|
* @returns A promise.
|
@@ -41789,16 +41877,19 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41789
41877
|
missingContractIds: []
|
41790
41878
|
};
|
41791
41879
|
}
|
41792
|
-
await this.estimatePredicates(transactionRequest);
|
41793
41880
|
let receipts = [];
|
41794
41881
|
const missingContractIds = [];
|
41795
41882
|
let outputVariables = 0;
|
41883
|
+
let dryrunStatus;
|
41796
41884
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
41797
|
-
const {
|
41798
|
-
|
41885
|
+
const {
|
41886
|
+
dryRun: [{ receipts: rawReceipts, status }]
|
41887
|
+
} = await this.operations.dryRun({
|
41888
|
+
encodedTransactions: [hexlify(transactionRequest.toTransactionBytes())],
|
41799
41889
|
utxoValidation: false
|
41800
41890
|
});
|
41801
|
-
receipts =
|
41891
|
+
receipts = rawReceipts.map(processGqlReceipt);
|
41892
|
+
dryrunStatus = status;
|
41802
41893
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
41803
41894
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
41804
41895
|
if (hasMissingOutputs) {
|
@@ -41808,6 +41899,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41808
41899
|
transactionRequest.addContractInputAndOutput(Address.fromString(contractId));
|
41809
41900
|
missingContractIds.push(contractId);
|
41810
41901
|
});
|
41902
|
+
const { maxFee } = await this.estimateTxGasAndFee({
|
41903
|
+
transactionRequest
|
41904
|
+
});
|
41905
|
+
transactionRequest.maxFee = maxFee;
|
41811
41906
|
} else {
|
41812
41907
|
break;
|
41813
41908
|
}
|
@@ -41815,37 +41910,139 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41815
41910
|
return {
|
41816
41911
|
receipts,
|
41817
41912
|
outputVariables,
|
41818
|
-
missingContractIds
|
41913
|
+
missingContractIds,
|
41914
|
+
dryrunStatus
|
41819
41915
|
};
|
41820
41916
|
}
|
41917
|
+
/**
|
41918
|
+
* Dry runs multiple transactions and checks for missing dependencies in batches.
|
41919
|
+
*
|
41920
|
+
* Transactions are dry run in batches. After each dry run, transactions requiring
|
41921
|
+
* further modifications are identified. The method iteratively updates these transactions
|
41922
|
+
* and performs subsequent dry runs until all dependencies for each transaction are satisfied.
|
41923
|
+
*
|
41924
|
+
* @param transactionRequests - Array of transaction request objects.
|
41925
|
+
* @returns A promise that resolves to an array of results for each transaction.
|
41926
|
+
*/
|
41927
|
+
async estimateMultipleTxDependencies(transactionRequests) {
|
41928
|
+
const results = transactionRequests.map(() => ({
|
41929
|
+
receipts: [],
|
41930
|
+
outputVariables: 0,
|
41931
|
+
missingContractIds: [],
|
41932
|
+
dryrunStatus: void 0
|
41933
|
+
}));
|
41934
|
+
const allRequests = clone_default(transactionRequests);
|
41935
|
+
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
41936
|
+
allRequests.forEach((req, index) => {
|
41937
|
+
if (req.type === TransactionType.Script) {
|
41938
|
+
serializedTransactionsMap.set(index, hexlify(req.toTransactionBytes()));
|
41939
|
+
}
|
41940
|
+
});
|
41941
|
+
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
41942
|
+
let attempt = 0;
|
41943
|
+
while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
|
41944
|
+
const encodedTransactions = transactionsToProcess.map(
|
41945
|
+
(index) => serializedTransactionsMap.get(index)
|
41946
|
+
);
|
41947
|
+
const dryRunResults = await this.operations.dryRun({
|
41948
|
+
encodedTransactions,
|
41949
|
+
utxoValidation: false
|
41950
|
+
});
|
41951
|
+
const nextRoundTransactions = [];
|
41952
|
+
for (let i = 0; i < dryRunResults.dryRun.length; i++) {
|
41953
|
+
const currentResultIndex = transactionsToProcess[i];
|
41954
|
+
const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
|
41955
|
+
results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
|
41956
|
+
results[currentResultIndex].dryrunStatus = status;
|
41957
|
+
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
|
41958
|
+
results[currentResultIndex].receipts
|
41959
|
+
);
|
41960
|
+
const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
|
41961
|
+
const requestToProcess = allRequests[currentResultIndex];
|
41962
|
+
if (hasMissingOutputs && requestToProcess?.type === TransactionType.Script) {
|
41963
|
+
results[currentResultIndex].outputVariables += missingOutputVariables.length;
|
41964
|
+
requestToProcess.addVariableOutputs(missingOutputVariables.length);
|
41965
|
+
missingOutputContractIds.forEach(({ contractId }) => {
|
41966
|
+
requestToProcess.addContractInputAndOutput(Address.fromString(contractId));
|
41967
|
+
results[currentResultIndex].missingContractIds.push(contractId);
|
41968
|
+
});
|
41969
|
+
const { maxFee } = await this.estimateTxGasAndFee({
|
41970
|
+
transactionRequest: requestToProcess
|
41971
|
+
});
|
41972
|
+
requestToProcess.maxFee = maxFee;
|
41973
|
+
serializedTransactionsMap.set(
|
41974
|
+
currentResultIndex,
|
41975
|
+
hexlify(requestToProcess.toTransactionBytes())
|
41976
|
+
);
|
41977
|
+
nextRoundTransactions.push(currentResultIndex);
|
41978
|
+
allRequests[currentResultIndex] = requestToProcess;
|
41979
|
+
}
|
41980
|
+
}
|
41981
|
+
transactionsToProcess = nextRoundTransactions;
|
41982
|
+
attempt += 1;
|
41983
|
+
}
|
41984
|
+
return results;
|
41985
|
+
}
|
41986
|
+
async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
|
41987
|
+
if (estimateTxDependencies) {
|
41988
|
+
return this.estimateMultipleTxDependencies(transactionRequests);
|
41989
|
+
}
|
41990
|
+
const encodedTransactions = transactionRequests.map((tx) => hexlify(tx.toTransactionBytes()));
|
41991
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
41992
|
+
encodedTransactions,
|
41993
|
+
utxoValidation: utxoValidation || false
|
41994
|
+
});
|
41995
|
+
const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
|
41996
|
+
const receipts = rawReceipts.map(processGqlReceipt);
|
41997
|
+
return { receipts, dryrunStatus: status };
|
41998
|
+
});
|
41999
|
+
return results;
|
42000
|
+
}
|
41821
42001
|
/**
|
41822
42002
|
* Estimates the transaction gas and fee based on the provided transaction request.
|
41823
42003
|
* @param transactionRequest - The transaction request object.
|
41824
42004
|
* @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
|
41825
42005
|
*/
|
41826
|
-
estimateTxGasAndFee(params) {
|
42006
|
+
async estimateTxGasAndFee(params) {
|
41827
42007
|
const { transactionRequest } = params;
|
41828
|
-
|
42008
|
+
let { gasPrice } = params;
|
41829
42009
|
const chainInfo = this.getChain();
|
41830
|
-
const
|
41831
|
-
transactionRequest.gasPrice = gasPrice;
|
42010
|
+
const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
|
41832
42011
|
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
41833
|
-
|
42012
|
+
if (!gasPrice) {
|
42013
|
+
gasPrice = await this.estimateGasPrice(10);
|
42014
|
+
}
|
42015
|
+
const minFee = calculateGasFee({
|
42016
|
+
gasPrice: bn(gasPrice),
|
42017
|
+
gas: minGas,
|
42018
|
+
priceFactor: gasPriceFactor,
|
42019
|
+
tip: transactionRequest.tip
|
42020
|
+
}).add(1);
|
42021
|
+
let gasLimit = bn(0);
|
41834
42022
|
if (transactionRequest.type === TransactionType.Script) {
|
42023
|
+
gasLimit = transactionRequest.gasLimit;
|
41835
42024
|
if (transactionRequest.gasLimit.eq(0)) {
|
41836
42025
|
transactionRequest.gasLimit = minGas;
|
41837
42026
|
transactionRequest.gasLimit = maxGasPerTx.sub(
|
41838
42027
|
transactionRequest.calculateMaxGas(chainInfo, minGas)
|
41839
42028
|
);
|
42029
|
+
gasLimit = transactionRequest.gasLimit;
|
41840
42030
|
}
|
41841
42031
|
}
|
41842
42032
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
41843
|
-
const maxFee =
|
42033
|
+
const maxFee = calculateGasFee({
|
42034
|
+
gasPrice: bn(gasPrice),
|
42035
|
+
gas: maxGas,
|
42036
|
+
priceFactor: gasPriceFactor,
|
42037
|
+
tip: transactionRequest.tip
|
42038
|
+
}).add(1);
|
41844
42039
|
return {
|
41845
42040
|
minGas,
|
41846
42041
|
minFee,
|
41847
42042
|
maxGas,
|
41848
|
-
maxFee
|
42043
|
+
maxFee,
|
42044
|
+
gasPrice,
|
42045
|
+
gasLimit
|
41849
42046
|
};
|
41850
42047
|
}
|
41851
42048
|
/**
|
@@ -41863,15 +42060,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41863
42060
|
if (estimateTxDependencies) {
|
41864
42061
|
return this.estimateTxDependencies(transactionRequest);
|
41865
42062
|
}
|
41866
|
-
const
|
41867
|
-
const { dryRun:
|
41868
|
-
|
42063
|
+
const encodedTransactions = [hexlify(transactionRequest.toTransactionBytes())];
|
42064
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
42065
|
+
encodedTransactions,
|
41869
42066
|
utxoValidation: true
|
41870
42067
|
});
|
41871
|
-
const
|
41872
|
-
|
41873
|
-
receipts
|
41874
|
-
|
42068
|
+
const callResult = dryRunStatuses.map((dryRunStatus) => {
|
42069
|
+
const { id, receipts, status } = dryRunStatus;
|
42070
|
+
const processedReceipts = receipts.map(processGqlReceipt);
|
42071
|
+
return { id, receipts: processedReceipts, status };
|
42072
|
+
});
|
42073
|
+
return { receipts: callResult[0].receipts };
|
41875
42074
|
}
|
41876
42075
|
/**
|
41877
42076
|
* Returns a transaction cost to enable user
|
@@ -41888,77 +42087,79 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41888
42087
|
* @param tolerance - The tolerance to add on top of the gasUsed.
|
41889
42088
|
* @returns A promise that resolves to the transaction cost object.
|
41890
42089
|
*/
|
41891
|
-
async getTransactionCost(transactionRequestLike,
|
41892
|
-
estimateTxDependencies = true,
|
41893
|
-
estimatePredicates = true,
|
41894
|
-
resourcesOwner,
|
41895
|
-
signatureCallback
|
41896
|
-
} = {}) {
|
42090
|
+
async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
|
41897
42091
|
const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
|
41898
|
-
const { minGasPrice } = this.getGasConfig();
|
41899
|
-
const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
41900
42092
|
const isScriptTransaction = txRequestClone.type === TransactionType.Script;
|
41901
42093
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
41902
|
-
const allQuantities = mergeQuantities(coinOutputsQuantities,
|
42094
|
+
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
41903
42095
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
42096
|
+
txRequestClone.maxFee = bn(0);
|
41904
42097
|
if (isScriptTransaction) {
|
41905
42098
|
txRequestClone.gasLimit = bn(0);
|
41906
42099
|
}
|
41907
|
-
if (
|
41908
|
-
|
41909
|
-
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
41910
|
-
}
|
41911
|
-
await this.estimatePredicates(txRequestClone);
|
42100
|
+
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
42101
|
+
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
41912
42102
|
}
|
42103
|
+
const signedRequest = clone_default(txRequestClone);
|
42104
|
+
let addedSignatures = 0;
|
41913
42105
|
if (signatureCallback && isScriptTransaction) {
|
41914
|
-
|
42106
|
+
const lengthBefore = signedRequest.witnesses.length;
|
42107
|
+
await signatureCallback(signedRequest);
|
42108
|
+
addedSignatures = signedRequest.witnesses.length - lengthBefore;
|
41915
42109
|
}
|
41916
|
-
|
41917
|
-
|
42110
|
+
await this.estimatePredicates(signedRequest);
|
42111
|
+
let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
|
42112
|
+
transactionRequest: signedRequest
|
41918
42113
|
});
|
41919
42114
|
let receipts = [];
|
41920
42115
|
let missingContractIds = [];
|
41921
42116
|
let outputVariables = 0;
|
41922
42117
|
let gasUsed = bn(0);
|
41923
|
-
|
41924
|
-
|
42118
|
+
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
42119
|
+
txRequestClone.maxFee = maxFee;
|
42120
|
+
if (isScriptTransaction) {
|
42121
|
+
txRequestClone.gasLimit = gasLimit;
|
42122
|
+
if (signatureCallback) {
|
42123
|
+
await signatureCallback(txRequestClone);
|
42124
|
+
}
|
41925
42125
|
const result = await this.estimateTxDependencies(txRequestClone);
|
41926
42126
|
receipts = result.receipts;
|
41927
42127
|
outputVariables = result.outputVariables;
|
41928
42128
|
missingContractIds = result.missingContractIds;
|
41929
42129
|
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
41930
42130
|
txRequestClone.gasLimit = gasUsed;
|
41931
|
-
|
41932
|
-
|
41933
|
-
|
42131
|
+
({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
|
42132
|
+
transactionRequest: txRequestClone,
|
42133
|
+
gasPrice
|
41934
42134
|
}));
|
41935
42135
|
}
|
41936
42136
|
return {
|
41937
42137
|
requiredQuantities: allQuantities,
|
41938
42138
|
receipts,
|
41939
42139
|
gasUsed,
|
41940
|
-
|
41941
|
-
gasPrice: setGasPrice,
|
42140
|
+
gasPrice,
|
41942
42141
|
minGas,
|
41943
42142
|
maxGas,
|
41944
42143
|
minFee,
|
41945
42144
|
maxFee,
|
41946
|
-
estimatedInputs: txRequestClone.inputs,
|
41947
42145
|
outputVariables,
|
41948
|
-
missingContractIds
|
42146
|
+
missingContractIds,
|
42147
|
+
addedSignatures,
|
42148
|
+
estimatedPredicates: txRequestClone.inputs
|
41949
42149
|
};
|
41950
42150
|
}
|
41951
|
-
async getResourcesForTransaction(owner, transactionRequestLike,
|
42151
|
+
async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
|
41952
42152
|
const ownerAddress = Address.fromAddressOrString(owner);
|
41953
42153
|
const transactionRequest = transactionRequestify(clone_default(transactionRequestLike));
|
41954
|
-
const transactionCost = await this.getTransactionCost(transactionRequest,
|
42154
|
+
const transactionCost = await this.getTransactionCost(transactionRequest, {
|
42155
|
+
quantitiesToContract
|
42156
|
+
});
|
41955
42157
|
transactionRequest.addResources(
|
41956
42158
|
await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
|
41957
42159
|
);
|
41958
|
-
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
41959
|
-
|
41960
|
-
|
41961
|
-
);
|
42160
|
+
const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
|
42161
|
+
quantitiesToContract
|
42162
|
+
});
|
41962
42163
|
const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
|
41963
42164
|
return {
|
41964
42165
|
resources,
|
@@ -41982,7 +42183,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41982
42183
|
assetId: coin.assetId,
|
41983
42184
|
amount: bn(coin.amount),
|
41984
42185
|
owner: Address.fromAddressOrString(coin.owner),
|
41985
|
-
maturity: bn(coin.maturity).toNumber(),
|
41986
42186
|
blockCreated: bn(coin.blockCreated),
|
41987
42187
|
txCreatedIdx: bn(coin.txCreatedIdx)
|
41988
42188
|
}));
|
@@ -42034,7 +42234,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42034
42234
|
amount: bn(coin.amount),
|
42035
42235
|
assetId: coin.assetId,
|
42036
42236
|
owner: Address.fromAddressOrString(coin.owner),
|
42037
|
-
maturity: bn(coin.maturity).toNumber(),
|
42038
42237
|
blockCreated: bn(coin.blockCreated),
|
42039
42238
|
txCreatedIdx: bn(coin.txCreatedIdx)
|
42040
42239
|
};
|
@@ -42067,7 +42266,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42067
42266
|
}
|
42068
42267
|
return {
|
42069
42268
|
id: block2.id,
|
42070
|
-
height: bn(block2.
|
42269
|
+
height: bn(block2.height),
|
42071
42270
|
time: block2.header.time,
|
42072
42271
|
transactionIds: block2.transactions.map((tx) => tx.id)
|
42073
42272
|
};
|
@@ -42082,7 +42281,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42082
42281
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
42083
42282
|
const blocks = fetchedData.edges.map(({ node: block2 }) => ({
|
42084
42283
|
id: block2.id,
|
42085
|
-
height: bn(block2.
|
42284
|
+
height: bn(block2.height),
|
42086
42285
|
time: block2.header.time,
|
42087
42286
|
transactionIds: block2.transactions.map((tx) => tx.id)
|
42088
42287
|
}));
|
@@ -42109,7 +42308,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42109
42308
|
}
|
42110
42309
|
return {
|
42111
42310
|
id: block2.id,
|
42112
|
-
height: bn(block2.
|
42311
|
+
height: bn(block2.height, 10),
|
42113
42312
|
time: block2.header.time,
|
42114
42313
|
transactionIds: block2.transactions.map((tx) => tx.id),
|
42115
42314
|
transactions: block2.transactions.map(
|
@@ -42289,8 +42488,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42289
42488
|
prevRoot: messageBlockHeader.prevRoot,
|
42290
42489
|
time: messageBlockHeader.time,
|
42291
42490
|
applicationHash: messageBlockHeader.applicationHash,
|
42292
|
-
|
42293
|
-
|
42491
|
+
messageReceiptCount: bn(messageBlockHeader.messageReceiptCount),
|
42492
|
+
messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
|
42493
|
+
consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
|
42494
|
+
eventInboxRoot: messageBlockHeader.eventInboxRoot,
|
42495
|
+
stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
|
42294
42496
|
},
|
42295
42497
|
commitBlockHeader: {
|
42296
42498
|
id: commitBlockHeader.id,
|
@@ -42301,8 +42503,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42301
42503
|
prevRoot: commitBlockHeader.prevRoot,
|
42302
42504
|
time: commitBlockHeader.time,
|
42303
42505
|
applicationHash: commitBlockHeader.applicationHash,
|
42304
|
-
|
42305
|
-
|
42506
|
+
messageReceiptCount: bn(commitBlockHeader.messageReceiptCount),
|
42507
|
+
messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
|
42508
|
+
consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
|
42509
|
+
eventInboxRoot: commitBlockHeader.eventInboxRoot,
|
42510
|
+
stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
|
42306
42511
|
},
|
42307
42512
|
sender: Address.fromAddressOrString(sender),
|
42308
42513
|
recipient: Address.fromAddressOrString(recipient),
|
@@ -42311,6 +42516,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42311
42516
|
data
|
42312
42517
|
};
|
42313
42518
|
}
|
42519
|
+
async getLatestGasPrice() {
|
42520
|
+
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
42521
|
+
return bn(latestGasPrice.gasPrice);
|
42522
|
+
}
|
42523
|
+
async estimateGasPrice(blockHorizon) {
|
42524
|
+
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
42525
|
+
blockHorizon: String(blockHorizon)
|
42526
|
+
});
|
42527
|
+
return bn(estimateGasPrice.gasPrice);
|
42528
|
+
}
|
42314
42529
|
/**
|
42315
42530
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
42316
42531
|
*
|
@@ -42371,10 +42586,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42371
42586
|
arrayify(gqlTransaction.rawPayload),
|
42372
42587
|
0
|
42373
42588
|
);
|
42374
|
-
|
42589
|
+
let txReceipts = [];
|
42590
|
+
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
42591
|
+
txReceipts = gqlTransaction.status.receipts;
|
42592
|
+
}
|
42593
|
+
const receipts = txReceipts.map(processGqlReceipt);
|
42375
42594
|
const {
|
42376
|
-
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
|
42595
|
+
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
|
42377
42596
|
} = provider.getChain();
|
42597
|
+
const gasPrice = await provider.getLatestGasPrice();
|
42378
42598
|
const transactionInfo = assembleTransactionSummary({
|
42379
42599
|
id: gqlTransaction.id,
|
42380
42600
|
receipts,
|
@@ -42385,7 +42605,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42385
42605
|
gasPriceFactor: bn(gasPriceFactor),
|
42386
42606
|
abiMap,
|
42387
42607
|
maxInputs,
|
42388
|
-
gasCosts
|
42608
|
+
gasCosts,
|
42609
|
+
maxGasPerTx,
|
42610
|
+
gasPrice
|
42389
42611
|
});
|
42390
42612
|
return {
|
42391
42613
|
gqlTransaction,
|
@@ -42395,10 +42617,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42395
42617
|
async function getTransactionSummaryFromRequest(params) {
|
42396
42618
|
const { provider, transactionRequest, abiMap } = params;
|
42397
42619
|
const { receipts } = await provider.call(transactionRequest);
|
42398
|
-
const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
|
42620
|
+
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
|
42399
42621
|
const maxInputs = provider.getChain().consensusParameters.maxInputs;
|
42400
42622
|
const transaction = transactionRequest.toTransaction();
|
42401
42623
|
const transactionBytes = transactionRequest.toTransactionBytes();
|
42624
|
+
const gasPrice = await provider.getLatestGasPrice();
|
42402
42625
|
const transactionSummary = assembleTransactionSummary({
|
42403
42626
|
receipts,
|
42404
42627
|
transaction,
|
@@ -42407,7 +42630,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42407
42630
|
gasPerByte,
|
42408
42631
|
gasPriceFactor,
|
42409
42632
|
maxInputs,
|
42410
|
-
gasCosts
|
42633
|
+
gasCosts,
|
42634
|
+
maxGasPerTx,
|
42635
|
+
gasPrice
|
42411
42636
|
});
|
42412
42637
|
return transactionSummary;
|
42413
42638
|
}
|
@@ -42416,13 +42641,18 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42416
42641
|
const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
|
42417
42642
|
const { edges, pageInfo } = transactionsByOwner;
|
42418
42643
|
const {
|
42419
|
-
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
|
42644
|
+
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
|
42420
42645
|
} = provider.getChain();
|
42646
|
+
const gasPrice = await provider.getLatestGasPrice();
|
42421
42647
|
const transactions = edges.map((edge) => {
|
42422
42648
|
const { node: gqlTransaction } = edge;
|
42423
|
-
const { id, rawPayload,
|
42649
|
+
const { id, rawPayload, status } = gqlTransaction;
|
42424
42650
|
const [decodedTransaction] = new TransactionCoder().decode(arrayify(rawPayload), 0);
|
42425
|
-
|
42651
|
+
let txReceipts = [];
|
42652
|
+
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
42653
|
+
txReceipts = gqlTransaction.status.receipts;
|
42654
|
+
}
|
42655
|
+
const receipts = txReceipts.map(processGqlReceipt);
|
42426
42656
|
const transactionSummary = assembleTransactionSummary({
|
42427
42657
|
id,
|
42428
42658
|
receipts,
|
@@ -42433,7 +42663,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42433
42663
|
gasPerByte,
|
42434
42664
|
gasPriceFactor,
|
42435
42665
|
maxInputs,
|
42436
|
-
gasCosts
|
42666
|
+
gasCosts,
|
42667
|
+
maxGasPerTx,
|
42668
|
+
gasPrice
|
42437
42669
|
});
|
42438
42670
|
const output3 = {
|
42439
42671
|
gqlTransaction,
|
@@ -42724,9 +42956,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42724
42956
|
* @param assetId - The asset ID to check the balance for.
|
42725
42957
|
* @returns A promise that resolves to the balance amount.
|
42726
42958
|
*/
|
42727
|
-
async getBalance(assetId) {
|
42728
|
-
const
|
42729
|
-
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
42959
|
+
async getBalance(assetId = BaseAssetId) {
|
42960
|
+
const amount = await this.provider.getBalance(this.address, assetId);
|
42730
42961
|
return amount;
|
42731
42962
|
}
|
42732
42963
|
/**
|
@@ -42763,37 +42994,33 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42763
42994
|
* @param fee - The estimated transaction fee.
|
42764
42995
|
* @returns A promise that resolves when the resources are added to the transaction.
|
42765
42996
|
*/
|
42766
|
-
async fund(request,
|
42767
|
-
const
|
42768
|
-
const
|
42997
|
+
async fund(request, params) {
|
42998
|
+
const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
|
42999
|
+
const txRequest = request;
|
43000
|
+
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
42769
43001
|
amount: bn(fee),
|
42770
|
-
assetId:
|
42771
|
-
coinQuantities
|
43002
|
+
assetId: BaseAssetId,
|
43003
|
+
coinQuantities: requiredQuantities
|
42772
43004
|
});
|
42773
43005
|
const quantitiesDict = {};
|
42774
|
-
|
43006
|
+
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
42775
43007
|
quantitiesDict[assetId] = {
|
42776
43008
|
required: amount,
|
42777
43009
|
owned: bn(0)
|
42778
43010
|
};
|
42779
43011
|
});
|
42780
|
-
|
42781
|
-
const cachedMessages = [];
|
42782
|
-
const owner = this.address.toB256();
|
42783
|
-
request.inputs.forEach((input) => {
|
43012
|
+
txRequest.inputs.forEach((input) => {
|
42784
43013
|
const isResource = "amount" in input;
|
42785
43014
|
if (isResource) {
|
42786
43015
|
const isCoin2 = "owner" in input;
|
42787
43016
|
if (isCoin2) {
|
42788
43017
|
const assetId = String(input.assetId);
|
42789
|
-
if (
|
43018
|
+
if (quantitiesDict[assetId]) {
|
42790
43019
|
const amount = bn(input.amount);
|
42791
43020
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
42792
|
-
cachedUtxos.push(input.id);
|
42793
43021
|
}
|
42794
|
-
} else if (input.
|
42795
|
-
quantitiesDict[
|
42796
|
-
cachedMessages.push(input.nonce);
|
43022
|
+
} else if (input.amount && quantitiesDict[BaseAssetId]) {
|
43023
|
+
quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
|
42797
43024
|
}
|
42798
43025
|
}
|
42799
43026
|
});
|
@@ -42808,12 +43035,23 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42808
43035
|
});
|
42809
43036
|
const needsToBeFunded = missingQuantities.length;
|
42810
43037
|
if (needsToBeFunded) {
|
42811
|
-
const
|
42812
|
-
|
42813
|
-
|
42814
|
-
|
42815
|
-
|
43038
|
+
const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
|
43039
|
+
const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
|
43040
|
+
txRequest.addResources(resources);
|
43041
|
+
}
|
43042
|
+
txRequest.shiftPredicateData();
|
43043
|
+
txRequest.updatePredicateGasUsed(estimatedPredicates);
|
43044
|
+
const requestToBeReEstimate = clone_default(txRequest);
|
43045
|
+
if (addedSignatures) {
|
43046
|
+
Array.from({ length: addedSignatures }).forEach(
|
43047
|
+
() => requestToBeReEstimate.addEmptyWitness()
|
43048
|
+
);
|
42816
43049
|
}
|
43050
|
+
const { maxFee } = await this.provider.estimateTxGasAndFee({
|
43051
|
+
transactionRequest: requestToBeReEstimate
|
43052
|
+
});
|
43053
|
+
txRequest.maxFee = maxFee;
|
43054
|
+
return txRequest;
|
42817
43055
|
}
|
42818
43056
|
/**
|
42819
43057
|
* A helper that creates a transfer transaction request and returns it.
|
@@ -42821,30 +43059,25 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42821
43059
|
* @param destination - The address of the destination.
|
42822
43060
|
* @param amount - The amount of coins to transfer.
|
42823
43061
|
* @param assetId - The asset ID of the coins to transfer.
|
42824
|
-
* @param txParams - The transaction parameters (gasLimit,
|
43062
|
+
* @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
|
42825
43063
|
* @returns A promise that resolves to the prepared transaction request.
|
42826
43064
|
*/
|
42827
|
-
async createTransfer(destination, amount, assetId, txParams = {}) {
|
42828
|
-
const
|
42829
|
-
|
42830
|
-
const
|
42831
|
-
const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
|
42832
|
-
const request = new ScriptTransactionRequest(params);
|
42833
|
-
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetIdToTransfer);
|
42834
|
-
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
43065
|
+
async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
43066
|
+
const request = new ScriptTransactionRequest(txParams);
|
43067
|
+
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
|
43068
|
+
const txCost = await this.provider.getTransactionCost(request, {
|
42835
43069
|
estimateTxDependencies: true,
|
42836
43070
|
resourcesOwner: this
|
42837
43071
|
});
|
42838
|
-
|
42839
|
-
|
42840
|
-
|
42841
|
-
|
42842
|
-
|
42843
|
-
|
42844
|
-
|
42845
|
-
|
42846
|
-
await this.fund(request,
|
42847
|
-
request.updatePredicateInputs(estimatedInputs);
|
43072
|
+
if ("gasLimit" in txParams) {
|
43073
|
+
this.validateGas({
|
43074
|
+
gasUsed: txCost.gasUsed,
|
43075
|
+
gasLimit: request.gasLimit
|
43076
|
+
});
|
43077
|
+
}
|
43078
|
+
request.gasLimit = txCost.gasUsed;
|
43079
|
+
request.maxFee = txCost.maxFee;
|
43080
|
+
await this.fund(request, txCost);
|
42848
43081
|
return request;
|
42849
43082
|
}
|
42850
43083
|
/**
|
@@ -42856,15 +43089,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42856
43089
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
42857
43090
|
* @returns A promise that resolves to the transaction response.
|
42858
43091
|
*/
|
42859
|
-
async transfer(destination, amount, assetId, txParams = {}) {
|
43092
|
+
async transfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
42860
43093
|
if (bn(amount).lte(0)) {
|
42861
43094
|
throw new FuelError(
|
42862
43095
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
42863
43096
|
"Transfer amount must be a positive number."
|
42864
43097
|
);
|
42865
43098
|
}
|
42866
|
-
const
|
42867
|
-
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
43099
|
+
const request = await this.createTransfer(destination, amount, assetId, txParams);
|
42868
43100
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
42869
43101
|
}
|
42870
43102
|
/**
|
@@ -42876,7 +43108,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42876
43108
|
* @param txParams - The optional transaction parameters.
|
42877
43109
|
* @returns A promise that resolves to the transaction response.
|
42878
43110
|
*/
|
42879
|
-
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
43111
|
+
async transferToContract(contractId, amount, assetId = BaseAssetId, txParams = {}) {
|
42880
43112
|
if (bn(amount).lte(0)) {
|
42881
43113
|
throw new FuelError(
|
42882
43114
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -42884,33 +43116,30 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42884
43116
|
);
|
42885
43117
|
}
|
42886
43118
|
const contractAddress = Address.fromAddressOrString(contractId);
|
42887
|
-
const { minGasPrice } = this.provider.getGasConfig();
|
42888
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
42889
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42890
|
-
const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
|
42891
43119
|
const { script, scriptData } = await assembleTransferToContractScript({
|
42892
43120
|
hexlifiedContractId: contractAddress.toB256(),
|
42893
43121
|
amountToTransfer: bn(amount),
|
42894
|
-
assetId
|
43122
|
+
assetId
|
42895
43123
|
});
|
42896
43124
|
const request = new ScriptTransactionRequest({
|
42897
|
-
...
|
43125
|
+
...txParams,
|
42898
43126
|
script,
|
42899
43127
|
scriptData
|
42900
43128
|
});
|
42901
43129
|
request.addContractInputAndOutput(contractAddress);
|
42902
|
-
const
|
42903
|
-
|
42904
|
-
[{ amount: bn(amount), assetId: String(
|
42905
|
-
);
|
42906
|
-
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
42907
|
-
this.validateGas({
|
42908
|
-
gasUsed,
|
42909
|
-
gasPrice: request.gasPrice,
|
42910
|
-
gasLimit: request.gasLimit,
|
42911
|
-
minGasPrice
|
43130
|
+
const txCost = await this.provider.getTransactionCost(request, {
|
43131
|
+
resourcesOwner: this,
|
43132
|
+
quantitiesToContract: [{ amount: bn(amount), assetId: String(assetId) }]
|
42912
43133
|
});
|
42913
|
-
|
43134
|
+
if (txParams.gasLimit) {
|
43135
|
+
this.validateGas({
|
43136
|
+
gasUsed: txCost.gasUsed,
|
43137
|
+
gasLimit: request.gasLimit
|
43138
|
+
});
|
43139
|
+
}
|
43140
|
+
request.gasLimit = txCost.gasUsed;
|
43141
|
+
request.maxFee = txCost.maxFee;
|
43142
|
+
await this.fund(request, txCost);
|
42914
43143
|
return this.sendTransaction(request);
|
42915
43144
|
}
|
42916
43145
|
/**
|
@@ -42922,8 +43151,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42922
43151
|
* @returns A promise that resolves to the transaction response.
|
42923
43152
|
*/
|
42924
43153
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
42925
|
-
const { minGasPrice } = this.provider.getGasConfig();
|
42926
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
42927
43154
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
42928
43155
|
const recipientDataArray = arrayify(
|
42929
43156
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -42936,26 +43163,19 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42936
43163
|
...recipientDataArray,
|
42937
43164
|
...amountDataArray
|
42938
43165
|
]);
|
42939
|
-
const params = {
|
42940
|
-
script,
|
42941
|
-
gasPrice: minGasPrice,
|
42942
|
-
baseAssetId,
|
42943
|
-
...txParams
|
42944
|
-
};
|
43166
|
+
const params = { script, ...txParams };
|
42945
43167
|
const request = new ScriptTransactionRequest(params);
|
42946
|
-
const
|
42947
|
-
const
|
42948
|
-
|
42949
|
-
|
42950
|
-
|
42951
|
-
|
42952
|
-
|
42953
|
-
|
42954
|
-
|
42955
|
-
|
42956
|
-
|
42957
|
-
});
|
42958
|
-
await this.fund(request, requiredQuantities, maxFee);
|
43168
|
+
const quantitiesToContract = [{ amount: bn(amount), assetId: BaseAssetId }];
|
43169
|
+
const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
|
43170
|
+
if (txParams.gasLimit) {
|
43171
|
+
this.validateGas({
|
43172
|
+
gasUsed: txCost.gasUsed,
|
43173
|
+
gasLimit: request.gasLimit
|
43174
|
+
});
|
43175
|
+
}
|
43176
|
+
request.maxFee = txCost.maxFee;
|
43177
|
+
request.gasLimit = txCost.gasUsed;
|
43178
|
+
await this.fund(request, txCost);
|
42959
43179
|
return this.sendTransaction(request);
|
42960
43180
|
}
|
42961
43181
|
async signMessage(message) {
|
@@ -43013,18 +43233,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43013
43233
|
}
|
43014
43234
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
43015
43235
|
}
|
43016
|
-
validateGas({
|
43017
|
-
gasUsed,
|
43018
|
-
gasPrice,
|
43019
|
-
gasLimit,
|
43020
|
-
minGasPrice
|
43021
|
-
}) {
|
43022
|
-
if (minGasPrice.gt(gasPrice)) {
|
43023
|
-
throw new FuelError(
|
43024
|
-
ErrorCode.GAS_PRICE_TOO_LOW,
|
43025
|
-
`Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
|
43026
|
-
);
|
43027
|
-
}
|
43236
|
+
validateGas({ gasUsed, gasLimit }) {
|
43028
43237
|
if (gasUsed.gt(gasLimit)) {
|
43029
43238
|
throw new FuelError(
|
43030
43239
|
ErrorCode.GAS_LIMIT_TOO_LOW,
|
@@ -44613,7 +44822,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44613
44822
|
* @param transactionRequestLike - The transaction request to send.
|
44614
44823
|
* @returns A promise that resolves to the TransactionResponse object.
|
44615
44824
|
*/
|
44616
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies =
|
44825
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
|
44617
44826
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
44618
44827
|
if (estimateTxDependencies) {
|
44619
44828
|
await this.provider.estimateTxDependencies(transactionRequest);
|
@@ -47891,8 +48100,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47891
48100
|
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
47892
48101
|
request.inputs?.forEach((input) => {
|
47893
48102
|
if (input.type === InputType.Coin && hexlify(input.owner) === this.address.toB256()) {
|
47894
|
-
input.predicate = this.bytes;
|
47895
|
-
input.predicateData = this.getPredicateData(policies.length);
|
48103
|
+
input.predicate = hexlify(this.bytes);
|
48104
|
+
input.predicateData = hexlify(this.getPredicateData(policies.length));
|
47896
48105
|
}
|
47897
48106
|
});
|
47898
48107
|
return request;
|
@@ -47906,10 +48115,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47906
48115
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
47907
48116
|
* @returns A promise that resolves to the prepared transaction request.
|
47908
48117
|
*/
|
47909
|
-
async createTransfer(destination, amount, assetId, txParams = {}) {
|
47910
|
-
|
47911
|
-
const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
47912
|
-
return this.populateTransactionPredicateData(request);
|
48118
|
+
async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
48119
|
+
return super.createTransfer(destination, amount, assetId, txParams);
|
47913
48120
|
}
|
47914
48121
|
/**
|
47915
48122
|
* Sends a transaction with the populated predicate data.
|
@@ -47917,9 +48124,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47917
48124
|
* @param transactionRequestLike - The transaction request-like object.
|
47918
48125
|
* @returns A promise that resolves to the transaction response.
|
47919
48126
|
*/
|
47920
|
-
sendTransaction(transactionRequestLike
|
47921
|
-
const transactionRequest =
|
47922
|
-
return super.sendTransaction(transactionRequest,
|
48127
|
+
sendTransaction(transactionRequestLike) {
|
48128
|
+
const transactionRequest = transactionRequestify(transactionRequestLike);
|
48129
|
+
return super.sendTransaction(transactionRequest, { estimateTxDependencies: false });
|
47923
48130
|
}
|
47924
48131
|
/**
|
47925
48132
|
* Simulates a transaction with the populated predicate data.
|
@@ -47928,8 +48135,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47928
48135
|
* @returns A promise that resolves to the call result.
|
47929
48136
|
*/
|
47930
48137
|
simulateTransaction(transactionRequestLike) {
|
47931
|
-
const transactionRequest =
|
47932
|
-
return super.simulateTransaction(transactionRequest);
|
48138
|
+
const transactionRequest = transactionRequestify(transactionRequestLike);
|
48139
|
+
return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
|
47933
48140
|
}
|
47934
48141
|
getPredicateData(policiesLength) {
|
47935
48142
|
if (!this.predicateData.length) {
|
@@ -47975,6 +48182,25 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47975
48182
|
predicateInterface: abiInterface
|
47976
48183
|
};
|
47977
48184
|
}
|
48185
|
+
/**
|
48186
|
+
* Retrieves resources satisfying the spend query for the account.
|
48187
|
+
*
|
48188
|
+
* @param quantities - IDs of coins to exclude.
|
48189
|
+
* @param excludedIds - IDs of resources to be excluded from the query.
|
48190
|
+
* @returns A promise that resolves to an array of Resources.
|
48191
|
+
*/
|
48192
|
+
async getResourcesToSpend(quantities, excludedIds) {
|
48193
|
+
const resources = await this.provider.getResourcesToSpend(
|
48194
|
+
this.address,
|
48195
|
+
quantities,
|
48196
|
+
excludedIds
|
48197
|
+
);
|
48198
|
+
return resources.map((resource) => ({
|
48199
|
+
...resource,
|
48200
|
+
predicate: hexlify(this.bytes),
|
48201
|
+
paddPredicateData: (policiesLength) => hexlify(this.getPredicateData(policiesLength))
|
48202
|
+
}));
|
48203
|
+
}
|
47978
48204
|
/**
|
47979
48205
|
* Sets the configurable constants for the predicate.
|
47980
48206
|
*
|