@fuel-ts/account 0.0.0-pr-1699-20240214162434 → 0.0.0-pr-1788-20240222085506
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/dist/account.d.ts +8 -6
- package/dist/account.d.ts.map +1 -1
- package/dist/connectors/fuel.d.ts +5 -6
- package/dist/connectors/fuel.d.ts.map +1 -1
- package/dist/connectors/index.d.ts +0 -2
- package/dist/connectors/index.d.ts.map +1 -1
- package/dist/connectors/types/asset.d.ts +0 -14
- package/dist/connectors/types/asset.d.ts.map +1 -1
- package/dist/connectors/types/data-type.d.ts +0 -4
- package/dist/connectors/types/data-type.d.ts.map +1 -1
- package/dist/connectors/types/events.d.ts +0 -5
- package/dist/connectors/types/events.d.ts.map +1 -1
- package/dist/connectors/types/index.d.ts +0 -2
- package/dist/connectors/types/index.d.ts.map +1 -1
- package/dist/connectors/utils/cache.d.ts.map +1 -1
- package/dist/connectors/utils/index.d.ts +0 -1
- package/dist/connectors/utils/index.d.ts.map +1 -1
- package/dist/hdwallet/hdwallet.d.ts +1 -1
- package/dist/hdwallet/hdwallet.d.ts.map +1 -1
- package/dist/index.global.js +898 -785
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +460 -344
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +388 -284
- package/dist/index.mjs.map +1 -1
- package/dist/mnemonic/mnemonic.d.ts +1 -1
- package/dist/mnemonic/mnemonic.d.ts.map +1 -1
- package/dist/mnemonic/utils.d.ts +1 -1
- package/dist/mnemonic/utils.d.ts.map +1 -1
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/predicate/utils/getPredicateRoot.d.ts +1 -1
- package/dist/predicate/utils/getPredicateRoot.d.ts.map +1 -1
- package/dist/providers/assets/index.d.ts +4 -0
- package/dist/providers/assets/index.d.ts.map +1 -0
- package/dist/providers/assets/types.d.ts +36 -0
- package/dist/providers/assets/types.d.ts.map +1 -0
- package/dist/providers/assets/utils/index.d.ts +4 -0
- package/dist/providers/assets/utils/index.d.ts.map +1 -0
- package/dist/providers/assets/utils/network.d.ts +33 -0
- package/dist/providers/assets/utils/network.d.ts.map +1 -0
- package/dist/providers/assets/utils/resolveIconPaths.d.ts +14 -0
- package/dist/providers/assets/utils/resolveIconPaths.d.ts.map +1 -0
- package/dist/providers/assets/utils/url.d.ts +2 -0
- package/dist/providers/assets/utils/url.d.ts.map +1 -0
- package/dist/providers/chains.d.ts +11 -0
- package/dist/providers/chains.d.ts.map +1 -0
- package/dist/providers/coin-quantity.d.ts +1 -1
- package/dist/providers/coin-quantity.d.ts.map +1 -1
- package/dist/providers/index.d.ts +2 -0
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/memory-cache.d.ts +1 -1
- package/dist/providers/memory-cache.d.ts.map +1 -1
- package/dist/providers/message.d.ts +1 -2
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +14 -7
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/resource.d.ts +1 -1
- package/dist/providers/resource.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/hash-transaction.d.ts.map +1 -1
- package/dist/providers/transaction-request/input.d.ts +1 -1
- package/dist/providers/transaction-request/input.d.ts.map +1 -1
- package/dist/providers/transaction-request/output.d.ts +1 -1
- package/dist/providers/transaction-request/output.d.ts.map +1 -1
- package/dist/providers/transaction-request/script-transaction-request.d.ts +1 -2
- package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/storage-slot.d.ts +1 -1
- package/dist/providers/transaction-request/storage-slot.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +3 -11
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/witness.d.ts +1 -1
- package/dist/providers/transaction-request/witness.d.ts.map +1 -1
- package/dist/providers/utils/gas.d.ts.map +1 -1
- package/dist/providers/utils/json.d.ts.map +1 -1
- package/dist/signer/signer.d.ts +1 -1
- package/dist/signer/signer.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +3319 -3222
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +349 -252
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +283 -198
- package/dist/test-utils.mjs.map +1 -1
- package/dist/utils/formatTransferToContractScriptData.d.ts +1 -2
- package/dist/utils/formatTransferToContractScriptData.d.ts.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts +4 -4
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/dist/wallet/wallet.d.ts +1 -2
- package/dist/wallet/wallet.d.ts.map +1 -1
- package/dist/wallet/wallets.d.ts +1 -1
- package/dist/wallet/wallets.d.ts.map +1 -1
- package/package.json +17 -17
- package/dist/connectors/fixtures/generate-accounts.d.ts +0 -2
- package/dist/connectors/fixtures/generate-accounts.d.ts.map +0 -1
- package/dist/connectors/fixtures/mocked-connector.d.ts +0 -45
- package/dist/connectors/fixtures/mocked-connector.d.ts.map +0 -1
- package/dist/connectors/fixtures/promise-callback.d.ts +0 -7
- package/dist/connectors/fixtures/promise-callback.d.ts.map +0 -1
- package/dist/connectors/fuel-wallet-locked.d.ts +0 -13
- package/dist/connectors/fuel-wallet-locked.d.ts.map +0 -1
- package/dist/connectors/fuel-wallet-provider.d.ts +0 -14
- package/dist/connectors/fuel-wallet-provider.d.ts.map +0 -1
- package/dist/connectors/types/connection.d.ts +0 -7
- package/dist/connectors/types/connection.d.ts.map +0 -1
- package/dist/connectors/types/nertwork-data.d.ts +0 -7
- package/dist/connectors/types/nertwork-data.d.ts.map +0 -1
- package/dist/connectors/utils/get-asset-by-chain.d.ts +0 -3
- package/dist/connectors/utils/get-asset-by-chain.d.ts.map +0 -1
package/dist/index.global.js
CHANGED
@@ -30103,8 +30103,8 @@ spurious results.`);
|
|
30103
30103
|
function getBuiltinVersions() {
|
30104
30104
|
return {
|
30105
30105
|
FORC: "0.50.0",
|
30106
|
-
FUEL_CORE: "0.22.
|
30107
|
-
FUELS: "0.
|
30106
|
+
FUEL_CORE: "0.22.1",
|
30107
|
+
FUELS: "0.74.0"
|
30108
30108
|
};
|
30109
30109
|
}
|
30110
30110
|
function parseVersion(version2) {
|
@@ -30177,10 +30177,12 @@ spurious results.`);
|
|
30177
30177
|
ErrorCode2["CHAIN_INFO_CACHE_EMPTY"] = "chain-info-cache-empty";
|
30178
30178
|
ErrorCode2["NODE_INFO_CACHE_EMPTY"] = "node-info-cache-empty";
|
30179
30179
|
ErrorCode2["MISSING_PROVIDER"] = "missing-provider";
|
30180
|
+
ErrorCode2["INVALID_PROVIDER"] = "invalid-provider";
|
30180
30181
|
ErrorCode2["INVALID_PUBLIC_KEY"] = "invalid-public-key";
|
30181
30182
|
ErrorCode2["INSUFFICIENT_BALANCE"] = "insufficient-balance";
|
30182
30183
|
ErrorCode2["WALLET_MANAGER_ERROR"] = "wallet-manager-error";
|
30183
30184
|
ErrorCode2["HD_WALLET_ERROR"] = "hd-wallet-error";
|
30185
|
+
ErrorCode2["MISSING_CONNECTOR"] = "missing-connector";
|
30184
30186
|
ErrorCode2["PARSE_FAILED"] = "parse-failed";
|
30185
30187
|
ErrorCode2["ENCODE_ERROR"] = "encode-error";
|
30186
30188
|
ErrorCode2["DECODE_ERROR"] = "decode-error";
|
@@ -30258,6 +30260,66 @@ spurious results.`);
|
|
30258
30260
|
var FuelError = _FuelError;
|
30259
30261
|
__publicField2(FuelError, "CODES", ErrorCode);
|
30260
30262
|
|
30263
|
+
// ../utils/dist/index.mjs
|
30264
|
+
var chunkAndPadBytes = (bytes4, chunkSize) => {
|
30265
|
+
const chunks = [];
|
30266
|
+
for (let offset = 0; offset < bytes4.length; offset += chunkSize) {
|
30267
|
+
const chunk = new Uint8Array(chunkSize);
|
30268
|
+
chunk.set(bytes4.slice(offset, offset + chunkSize));
|
30269
|
+
chunks.push(chunk);
|
30270
|
+
}
|
30271
|
+
const lastChunk = chunks[chunks.length - 1];
|
30272
|
+
const remainingBytes = bytes4.length % chunkSize;
|
30273
|
+
const paddedChunkLength = remainingBytes + (8 - remainingBytes % 8) % 8;
|
30274
|
+
const newChunk = lastChunk.slice(0, paddedChunkLength);
|
30275
|
+
chunks[chunks.length - 1] = newChunk;
|
30276
|
+
return chunks;
|
30277
|
+
};
|
30278
|
+
var arrayify = (value) => {
|
30279
|
+
if (value instanceof Uint8Array) {
|
30280
|
+
return new Uint8Array(value);
|
30281
|
+
}
|
30282
|
+
if (typeof value === "string" && value.match(/^0x([0-9a-f][0-9a-f])*$/i)) {
|
30283
|
+
const result = new Uint8Array((value.length - 2) / 2);
|
30284
|
+
let offset = 2;
|
30285
|
+
for (let i = 0; i < result.length; i++) {
|
30286
|
+
result[i] = parseInt(value.substring(offset, offset + 2), 16);
|
30287
|
+
offset += 2;
|
30288
|
+
}
|
30289
|
+
return result;
|
30290
|
+
}
|
30291
|
+
throw new FuelError(ErrorCode.PARSE_FAILED, "invalid BytesLike value");
|
30292
|
+
};
|
30293
|
+
var concatBytes2 = (arrays) => {
|
30294
|
+
const byteArrays = arrays.map((array) => {
|
30295
|
+
if (array instanceof Uint8Array) {
|
30296
|
+
return array;
|
30297
|
+
}
|
30298
|
+
return Uint8Array.from(array);
|
30299
|
+
});
|
30300
|
+
const totalSize = byteArrays.reduce((accum, item) => accum + item.length, 0);
|
30301
|
+
const concatenated = new Uint8Array(totalSize);
|
30302
|
+
byteArrays.reduce((offset, object) => {
|
30303
|
+
concatenated.set(object, offset);
|
30304
|
+
return offset + object.length;
|
30305
|
+
}, 0);
|
30306
|
+
return concatenated;
|
30307
|
+
};
|
30308
|
+
var concat = (arrays) => {
|
30309
|
+
const bytes4 = arrays.map((v) => arrayify(v));
|
30310
|
+
return concatBytes2(bytes4);
|
30311
|
+
};
|
30312
|
+
var HexCharacters = "0123456789abcdef";
|
30313
|
+
function hexlify(data) {
|
30314
|
+
const bytes4 = arrayify(data);
|
30315
|
+
let result = "0x";
|
30316
|
+
for (let i = 0; i < bytes4.length; i++) {
|
30317
|
+
const v = bytes4[i];
|
30318
|
+
result += HexCharacters[(v & 240) >> 4] + HexCharacters[v & 15];
|
30319
|
+
}
|
30320
|
+
return result;
|
30321
|
+
}
|
30322
|
+
|
30261
30323
|
// ../crypto/dist/index.mjs
|
30262
30324
|
var import_crypto9 = __toESM(__require("crypto"), 1);
|
30263
30325
|
|
@@ -30426,9 +30488,6 @@ spurious results.`);
|
|
30426
30488
|
function getBytes(value, name) {
|
30427
30489
|
return _getBytes(value, name, false);
|
30428
30490
|
}
|
30429
|
-
function getBytesCopy(value, name) {
|
30430
|
-
return _getBytes(value, name, true);
|
30431
|
-
}
|
30432
30491
|
function isHexString(value, length) {
|
30433
30492
|
if (typeof value !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) {
|
30434
30493
|
return false;
|
@@ -30441,19 +30500,16 @@ spurious results.`);
|
|
30441
30500
|
}
|
30442
30501
|
return true;
|
30443
30502
|
}
|
30444
|
-
var
|
30445
|
-
function
|
30503
|
+
var HexCharacters2 = "0123456789abcdef";
|
30504
|
+
function hexlify2(data) {
|
30446
30505
|
const bytes4 = getBytes(data);
|
30447
30506
|
let result = "0x";
|
30448
30507
|
for (let i = 0; i < bytes4.length; i++) {
|
30449
30508
|
const v = bytes4[i];
|
30450
|
-
result +=
|
30509
|
+
result += HexCharacters2[(v & 240) >> 4] + HexCharacters2[v & 15];
|
30451
30510
|
}
|
30452
30511
|
return result;
|
30453
30512
|
}
|
30454
|
-
function concat(datas) {
|
30455
|
-
return "0x" + datas.map((d) => hexlify(d).substring(2)).join("");
|
30456
|
-
}
|
30457
30513
|
function dataSlice(data, start, end) {
|
30458
30514
|
const bytes4 = getBytes(data);
|
30459
30515
|
if (end != null && end > bytes4.length) {
|
@@ -30463,7 +30519,7 @@ spurious results.`);
|
|
30463
30519
|
offset: end
|
30464
30520
|
});
|
30465
30521
|
}
|
30466
|
-
return
|
30522
|
+
return hexlify2(bytes4.slice(start == null ? 0 : start, end == null ? bytes4.length : end));
|
30467
30523
|
}
|
30468
30524
|
|
30469
30525
|
// ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/utils/maths.js
|
@@ -30746,7 +30802,7 @@ spurious results.`);
|
|
30746
30802
|
function computeHmac(algorithm, _key, _data) {
|
30747
30803
|
const key = getBytes(_key, "key");
|
30748
30804
|
const data = getBytes(_data, "data");
|
30749
|
-
return
|
30805
|
+
return hexlify2(__computeHmac(algorithm, key, data));
|
30750
30806
|
}
|
30751
30807
|
computeHmac._ = _computeHmac;
|
30752
30808
|
computeHmac.lock = function() {
|
@@ -31101,7 +31157,7 @@ spurious results.`);
|
|
31101
31157
|
var __keccak256 = _keccak256;
|
31102
31158
|
function keccak2562(_data) {
|
31103
31159
|
const data = getBytes(_data, "data");
|
31104
|
-
return
|
31160
|
+
return hexlify2(__keccak256(data));
|
31105
31161
|
}
|
31106
31162
|
keccak2562._ = _keccak256;
|
31107
31163
|
keccak2562.lock = function() {
|
@@ -31300,7 +31356,7 @@ spurious results.`);
|
|
31300
31356
|
var __ripemd160 = _ripemd160;
|
31301
31357
|
function ripemd1602(_data) {
|
31302
31358
|
const data = getBytes(_data, "data");
|
31303
|
-
return
|
31359
|
+
return hexlify2(__ripemd160(data));
|
31304
31360
|
}
|
31305
31361
|
ripemd1602._ = _ripemd160;
|
31306
31362
|
ripemd1602.lock = function() {
|
@@ -31323,7 +31379,7 @@ spurious results.`);
|
|
31323
31379
|
function pbkdf22(_password, _salt, iterations, keylen, algo) {
|
31324
31380
|
const password = getBytes(_password, "password");
|
31325
31381
|
const salt = getBytes(_salt, "salt");
|
31326
|
-
return
|
31382
|
+
return hexlify2(__pbkdf2(password, salt, iterations, keylen, algo));
|
31327
31383
|
}
|
31328
31384
|
pbkdf22._ = _pbkdf2;
|
31329
31385
|
pbkdf22.lock = function() {
|
@@ -31350,7 +31406,7 @@ spurious results.`);
|
|
31350
31406
|
var locked512 = false;
|
31351
31407
|
function sha2562(_data) {
|
31352
31408
|
const data = getBytes(_data, "data");
|
31353
|
-
return
|
31409
|
+
return hexlify2(__sha256(data));
|
31354
31410
|
}
|
31355
31411
|
sha2562._ = _sha256;
|
31356
31412
|
sha2562.lock = function() {
|
@@ -31365,7 +31421,7 @@ spurious results.`);
|
|
31365
31421
|
Object.freeze(sha2562);
|
31366
31422
|
function sha512(_data) {
|
31367
31423
|
const data = getBytes(_data, "data");
|
31368
|
-
return
|
31424
|
+
return hexlify2(__sha512(data));
|
31369
31425
|
}
|
31370
31426
|
sha512._ = _sha512;
|
31371
31427
|
sha512.lock = function() {
|
@@ -31981,7 +32037,7 @@ spurious results.`);
|
|
31981
32037
|
var keyFromPassword = (password, saltBuffer) => {
|
31982
32038
|
const passBuffer = bufferFromString(String(password).normalize("NFKC"), "utf-8");
|
31983
32039
|
const key = pbkdf22(passBuffer, saltBuffer, 1e5, 32, "sha256");
|
31984
|
-
return
|
32040
|
+
return arrayify(key);
|
31985
32041
|
};
|
31986
32042
|
var encrypt = async (password, data) => {
|
31987
32043
|
const iv = randomBytes3(16);
|
@@ -32067,7 +32123,7 @@ spurious results.`);
|
|
32067
32123
|
function toBech32(address) {
|
32068
32124
|
return import_bech32.bech32m.encode(
|
32069
32125
|
FUEL_BECH32_HRP_PREFIX,
|
32070
|
-
import_bech32.bech32m.toWords(
|
32126
|
+
import_bech32.bech32m.toWords(arrayify(hexlify(address)))
|
32071
32127
|
);
|
32072
32128
|
}
|
32073
32129
|
function isBech32(address) {
|
@@ -32246,7 +32302,7 @@ spurious results.`);
|
|
32246
32302
|
if (!isPublicKey(publicKey)) {
|
32247
32303
|
throw new FuelError(FuelError.CODES.INVALID_PUBLIC_KEY, `Invalid Public Key: ${publicKey}.`);
|
32248
32304
|
}
|
32249
|
-
const b256Address = sha2562(hexlify(
|
32305
|
+
const b256Address = sha2562(hexlify(arrayify(publicKey)));
|
32250
32306
|
return new Address(toBech32(b256Address));
|
32251
32307
|
}
|
32252
32308
|
/**
|
@@ -32594,56 +32650,6 @@ spurious results.`);
|
|
32594
32650
|
return coinQuantities;
|
32595
32651
|
};
|
32596
32652
|
|
32597
|
-
// ../utils/dist/index.mjs
|
32598
|
-
var chunkAndPadBytes = (bytes4, chunkSize) => {
|
32599
|
-
const chunks = [];
|
32600
|
-
for (let offset = 0; offset < bytes4.length; offset += chunkSize) {
|
32601
|
-
const chunk = new Uint8Array(chunkSize);
|
32602
|
-
chunk.set(bytes4.slice(offset, offset + chunkSize));
|
32603
|
-
chunks.push(chunk);
|
32604
|
-
}
|
32605
|
-
const lastChunk = chunks[chunks.length - 1];
|
32606
|
-
const remainingBytes = bytes4.length % chunkSize;
|
32607
|
-
const paddedChunkLength = remainingBytes + (8 - remainingBytes % 8) % 8;
|
32608
|
-
const newChunk = lastChunk.slice(0, paddedChunkLength);
|
32609
|
-
chunks[chunks.length - 1] = newChunk;
|
32610
|
-
return chunks;
|
32611
|
-
};
|
32612
|
-
var arrayify = (value) => {
|
32613
|
-
if (value instanceof Uint8Array) {
|
32614
|
-
return new Uint8Array(value);
|
32615
|
-
}
|
32616
|
-
if (typeof value === "string" && value.match(/^0x([0-9a-f][0-9a-f])*$/i)) {
|
32617
|
-
const result = new Uint8Array((value.length - 2) / 2);
|
32618
|
-
let offset = 2;
|
32619
|
-
for (let i = 0; i < result.length; i++) {
|
32620
|
-
result[i] = parseInt(value.substring(offset, offset + 2), 16);
|
32621
|
-
offset += 2;
|
32622
|
-
}
|
32623
|
-
return result;
|
32624
|
-
}
|
32625
|
-
throw new FuelError(ErrorCode.PARSE_FAILED, "invalid BytesLike value");
|
32626
|
-
};
|
32627
|
-
var concatBytes2 = (arrays) => {
|
32628
|
-
const byteArrays = arrays.map((array) => {
|
32629
|
-
if (array instanceof Uint8Array) {
|
32630
|
-
return array;
|
32631
|
-
}
|
32632
|
-
return Uint8Array.from(array);
|
32633
|
-
});
|
32634
|
-
const totalSize = byteArrays.reduce((accum, item) => accum + item.length, 0);
|
32635
|
-
const concatenated = new Uint8Array(totalSize);
|
32636
|
-
byteArrays.reduce((offset, object) => {
|
32637
|
-
concatenated.set(object, offset);
|
32638
|
-
return offset + object.length;
|
32639
|
-
}, 0);
|
32640
|
-
return concatenated;
|
32641
|
-
};
|
32642
|
-
var concat2 = (arrays) => {
|
32643
|
-
const bytes4 = arrays.map((v) => arrayify(v));
|
32644
|
-
return concatBytes2(bytes4);
|
32645
|
-
};
|
32646
|
-
|
32647
32653
|
// ../abi-coder/dist/index.mjs
|
32648
32654
|
var __defProp3 = Object.defineProperty;
|
32649
32655
|
var __defNormalProp3 = (obj, key, value) => key in obj ? __defProp3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
@@ -32766,7 +32772,7 @@ spurious results.`);
|
|
32766
32772
|
topLevelData[parseInt(pointerIndex, 10) + totalIndex] = vData;
|
32767
32773
|
});
|
32768
32774
|
}
|
32769
|
-
const byteArray =
|
32775
|
+
const byteArray = arrayify(item);
|
32770
32776
|
totalIndex += byteArray.byteLength / WORD_SIZE;
|
32771
32777
|
return byteArray;
|
32772
32778
|
});
|
@@ -32783,7 +32789,7 @@ spurious results.`);
|
|
32783
32789
|
}
|
32784
32790
|
function unpackDynamicData(results, baseOffset, dataOffset) {
|
32785
32791
|
if (!results.dynamicData) {
|
32786
|
-
return
|
32792
|
+
return concat([results]);
|
32787
32793
|
}
|
32788
32794
|
let cumulativeDynamicByteLength = 0;
|
32789
32795
|
let updatedResults = results;
|
@@ -32801,7 +32807,7 @@ spurious results.`);
|
|
32801
32807
|
dataOffset + vData.byteLength + cumulativeDynamicByteLength
|
32802
32808
|
)
|
32803
32809
|
) : vData;
|
32804
|
-
updatedResults =
|
32810
|
+
updatedResults = concat([updatedResults, dataToAppend]);
|
32805
32811
|
cumulativeDynamicByteLength += dataToAppend.byteLength;
|
32806
32812
|
});
|
32807
32813
|
return updatedResults;
|
@@ -32887,7 +32893,7 @@ spurious results.`);
|
|
32887
32893
|
encode(value) {
|
32888
32894
|
let encodedValue;
|
32889
32895
|
try {
|
32890
|
-
encodedValue =
|
32896
|
+
encodedValue = arrayify(value);
|
32891
32897
|
} catch (error) {
|
32892
32898
|
throw new FuelError(ErrorCode.ENCODE_ERROR, `Invalid ${this.type}.`);
|
32893
32899
|
}
|
@@ -32918,7 +32924,7 @@ spurious results.`);
|
|
32918
32924
|
encode(value) {
|
32919
32925
|
let encodedValue;
|
32920
32926
|
try {
|
32921
|
-
encodedValue =
|
32927
|
+
encodedValue = arrayify(value);
|
32922
32928
|
} catch (error) {
|
32923
32929
|
throw new FuelError(ErrorCode.ENCODE_ERROR, `Invalid ${this.type}.`);
|
32924
32930
|
}
|
@@ -32985,6 +32991,51 @@ spurious results.`);
|
|
32985
32991
|
return [true, offset + this.paddingLength];
|
32986
32992
|
}
|
32987
32993
|
};
|
32994
|
+
var _getPaddedData;
|
32995
|
+
var getPaddedData_fn;
|
32996
|
+
var ByteCoder = class extends Coder {
|
32997
|
+
constructor() {
|
32998
|
+
super("struct", "struct Bytes", BASE_VECTOR_OFFSET);
|
32999
|
+
__privateAdd2(this, _getPaddedData);
|
33000
|
+
}
|
33001
|
+
encode(value) {
|
33002
|
+
if (!Array.isArray(value)) {
|
33003
|
+
throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
|
33004
|
+
}
|
33005
|
+
const parts = [];
|
33006
|
+
const pointer = new U64Coder().encode(BASE_VECTOR_OFFSET);
|
33007
|
+
const data = __privateMethod2(this, _getPaddedData, getPaddedData_fn).call(this, value);
|
33008
|
+
pointer.dynamicData = {
|
33009
|
+
0: concatWithDynamicData([data])
|
33010
|
+
};
|
33011
|
+
parts.push(pointer);
|
33012
|
+
parts.push(new U64Coder().encode(data.byteLength));
|
33013
|
+
parts.push(new U64Coder().encode(value.length));
|
33014
|
+
return concatWithDynamicData(parts);
|
33015
|
+
}
|
33016
|
+
decode(data, offset) {
|
33017
|
+
if (data.length < BASE_VECTOR_OFFSET) {
|
33018
|
+
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid byte data size.`);
|
33019
|
+
}
|
33020
|
+
const len = data.slice(16, 24);
|
33021
|
+
const encodedLength = bn(new U64Coder().decode(len, 0)[0]).toNumber();
|
33022
|
+
const byteData = data.slice(BASE_VECTOR_OFFSET, BASE_VECTOR_OFFSET + encodedLength);
|
33023
|
+
if (byteData.length !== encodedLength) {
|
33024
|
+
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid bytes byte data size.`);
|
33025
|
+
}
|
33026
|
+
return [byteData, offset + BASE_VECTOR_OFFSET];
|
33027
|
+
}
|
33028
|
+
};
|
33029
|
+
_getPaddedData = /* @__PURE__ */ new WeakSet();
|
33030
|
+
getPaddedData_fn = function(value) {
|
33031
|
+
const data = [Uint8Array.from(value)];
|
33032
|
+
const paddingLength = (WORD_SIZE - value.length % WORD_SIZE) % WORD_SIZE;
|
33033
|
+
if (paddingLength) {
|
33034
|
+
data.push(new Uint8Array(paddingLength));
|
33035
|
+
}
|
33036
|
+
return concat(data);
|
33037
|
+
};
|
33038
|
+
__publicField3(ByteCoder, "memorySize", 1);
|
32988
33039
|
var isFullyNativeEnum = (enumCoders) => Object.values(enumCoders).every(
|
32989
33040
|
// @ts-expect-error complicated types
|
32990
33041
|
({ type: type3, coders }) => type3 === "()" && JSON.stringify(coders) === JSON.stringify([])
|
@@ -33011,7 +33062,7 @@ spurious results.`);
|
|
33011
33062
|
const encodedValue = valueCoder.encode([]);
|
33012
33063
|
const caseIndex = Object.keys(this.coders).indexOf(value);
|
33013
33064
|
const padding = new Uint8Array(this.#encodedValueSize - valueCoder.encodedLength);
|
33014
|
-
return
|
33065
|
+
return concat([this.#caseIndexCoder.encode(caseIndex), padding, encodedValue]);
|
33015
33066
|
}
|
33016
33067
|
encode(value) {
|
33017
33068
|
if (typeof value === "string" && this.coders[value]) {
|
@@ -33058,6 +33109,31 @@ spurious results.`);
|
|
33058
33109
|
return [{ [caseKey]: decoded }, newOffset];
|
33059
33110
|
}
|
33060
33111
|
};
|
33112
|
+
var OptionCoder = class extends EnumCoder {
|
33113
|
+
encode(value) {
|
33114
|
+
const result = super.encode(this.toSwayOption(value));
|
33115
|
+
return result;
|
33116
|
+
}
|
33117
|
+
toSwayOption(input) {
|
33118
|
+
if (input !== void 0) {
|
33119
|
+
return { Some: input };
|
33120
|
+
}
|
33121
|
+
return { None: [] };
|
33122
|
+
}
|
33123
|
+
decode(data, offset) {
|
33124
|
+
if (data.length < this.encodedLength - 1) {
|
33125
|
+
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid option data size.`);
|
33126
|
+
}
|
33127
|
+
const [decoded, newOffset] = super.decode(data, offset);
|
33128
|
+
return [this.toOption(decoded), newOffset];
|
33129
|
+
}
|
33130
|
+
toOption(output4) {
|
33131
|
+
if (output4 && "Some" in output4) {
|
33132
|
+
return output4.Some;
|
33133
|
+
}
|
33134
|
+
return void 0;
|
33135
|
+
}
|
33136
|
+
};
|
33061
33137
|
var NumberCoder = class extends Coder {
|
33062
33138
|
// This is to align the bits to the total bytes
|
33063
33139
|
// See https://github.com/FuelLabs/fuel-specs/blob/master/specs/protocol/abi.md#unsigned-integers
|
@@ -33128,6 +33204,77 @@ spurious results.`);
|
|
33128
33204
|
return [toNumber2(bytes4), offset + 8];
|
33129
33205
|
}
|
33130
33206
|
};
|
33207
|
+
var RawSliceCoder = class extends Coder {
|
33208
|
+
constructor() {
|
33209
|
+
super("raw untyped slice", "raw untyped slice", BASE_RAW_SLICE_OFFSET);
|
33210
|
+
}
|
33211
|
+
encode(value) {
|
33212
|
+
if (!Array.isArray(value)) {
|
33213
|
+
throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
|
33214
|
+
}
|
33215
|
+
const parts = [];
|
33216
|
+
const coder = new NumberCoder("u8", { isSmallBytes: true });
|
33217
|
+
const pointer = new U64Coder().encode(BASE_RAW_SLICE_OFFSET);
|
33218
|
+
pointer.dynamicData = {
|
33219
|
+
0: concatWithDynamicData(value.map((v) => coder.encode(v)))
|
33220
|
+
};
|
33221
|
+
parts.push(pointer);
|
33222
|
+
parts.push(new U64Coder().encode(value.length));
|
33223
|
+
return concatWithDynamicData(parts);
|
33224
|
+
}
|
33225
|
+
decode(data, offset) {
|
33226
|
+
const dataBytes = data.slice(offset);
|
33227
|
+
const internalCoder = new ArrayCoder(
|
33228
|
+
new NumberCoder("u8", { isSmallBytes: true }),
|
33229
|
+
dataBytes.length
|
33230
|
+
);
|
33231
|
+
const [decodedValue] = internalCoder.decode(dataBytes, 0);
|
33232
|
+
return [decodedValue, offset + dataBytes.length];
|
33233
|
+
}
|
33234
|
+
};
|
33235
|
+
var _getPaddedData2;
|
33236
|
+
var getPaddedData_fn2;
|
33237
|
+
var StdStringCoder = class extends Coder {
|
33238
|
+
constructor() {
|
33239
|
+
super("struct", "struct String", 1);
|
33240
|
+
__privateAdd2(this, _getPaddedData2);
|
33241
|
+
}
|
33242
|
+
encode(value) {
|
33243
|
+
const parts = [];
|
33244
|
+
const pointer = new U64Coder().encode(BASE_VECTOR_OFFSET);
|
33245
|
+
const data = __privateMethod2(this, _getPaddedData2, getPaddedData_fn2).call(this, value);
|
33246
|
+
pointer.dynamicData = {
|
33247
|
+
0: concatWithDynamicData([data])
|
33248
|
+
};
|
33249
|
+
parts.push(pointer);
|
33250
|
+
parts.push(new U64Coder().encode(data.byteLength));
|
33251
|
+
parts.push(new U64Coder().encode(value.length));
|
33252
|
+
return concatWithDynamicData(parts);
|
33253
|
+
}
|
33254
|
+
decode(data, offset) {
|
33255
|
+
if (data.length < this.encodedLength) {
|
33256
|
+
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid std string data size.`);
|
33257
|
+
}
|
33258
|
+
const len = data.slice(16, 24);
|
33259
|
+
const encodedLength = bn(new U64Coder().decode(len, 0)[0]).toNumber();
|
33260
|
+
const byteData = data.slice(BASE_VECTOR_OFFSET, BASE_VECTOR_OFFSET + encodedLength);
|
33261
|
+
if (byteData.length !== encodedLength) {
|
33262
|
+
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid std string byte data size.`);
|
33263
|
+
}
|
33264
|
+
const value = toUtf8String(byteData);
|
33265
|
+
return [value, offset + BASE_VECTOR_OFFSET];
|
33266
|
+
}
|
33267
|
+
};
|
33268
|
+
_getPaddedData2 = /* @__PURE__ */ new WeakSet();
|
33269
|
+
getPaddedData_fn2 = function(value) {
|
33270
|
+
const data = [toUtf8Bytes(value)];
|
33271
|
+
const paddingLength = (WORD_SIZE - value.length % WORD_SIZE) % WORD_SIZE;
|
33272
|
+
if (paddingLength) {
|
33273
|
+
data.push(new Uint8Array(paddingLength));
|
33274
|
+
}
|
33275
|
+
return concat(data);
|
33276
|
+
};
|
33277
|
+
__publicField3(StdStringCoder, "memorySize", 1);
|
33131
33278
|
var StringCoder = class extends Coder {
|
33132
33279
|
length;
|
33133
33280
|
#paddingLength;
|
@@ -33144,7 +33291,7 @@ spurious results.`);
|
|
33144
33291
|
}
|
33145
33292
|
const encoded = toUtf8Bytes(value);
|
33146
33293
|
const padding = new Uint8Array(this.#paddingLength);
|
33147
|
-
return
|
33294
|
+
return concat([encoded, padding]);
|
33148
33295
|
}
|
33149
33296
|
decode(data, offset) {
|
33150
33297
|
if (data.length < this.encodedLength) {
|
@@ -33159,31 +33306,6 @@ spurious results.`);
|
|
33159
33306
|
return [value, offset + this.length + padding];
|
33160
33307
|
}
|
33161
33308
|
};
|
33162
|
-
var OptionCoder = class extends EnumCoder {
|
33163
|
-
encode(value) {
|
33164
|
-
const result = super.encode(this.toSwayOption(value));
|
33165
|
-
return result;
|
33166
|
-
}
|
33167
|
-
toSwayOption(input) {
|
33168
|
-
if (input !== void 0) {
|
33169
|
-
return { Some: input };
|
33170
|
-
}
|
33171
|
-
return { None: [] };
|
33172
|
-
}
|
33173
|
-
decode(data, offset) {
|
33174
|
-
if (data.length < this.encodedLength - 1) {
|
33175
|
-
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid option data size.`);
|
33176
|
-
}
|
33177
|
-
const [decoded, newOffset] = super.decode(data, offset);
|
33178
|
-
return [this.toOption(decoded), newOffset];
|
33179
|
-
}
|
33180
|
-
toOption(output4) {
|
33181
|
-
if (output4 && "Some" in output4) {
|
33182
|
-
return output4.Some;
|
33183
|
-
}
|
33184
|
-
return void 0;
|
33185
|
-
}
|
33186
|
-
};
|
33187
33309
|
var StructCoder = class extends Coder {
|
33188
33310
|
name;
|
33189
33311
|
coders;
|
@@ -33308,122 +33430,6 @@ spurious results.`);
|
|
33308
33430
|
];
|
33309
33431
|
}
|
33310
33432
|
};
|
33311
|
-
var _getPaddedData;
|
33312
|
-
var getPaddedData_fn;
|
33313
|
-
var ByteCoder = class extends Coder {
|
33314
|
-
constructor() {
|
33315
|
-
super("struct", "struct Bytes", BASE_VECTOR_OFFSET);
|
33316
|
-
__privateAdd2(this, _getPaddedData);
|
33317
|
-
}
|
33318
|
-
encode(value) {
|
33319
|
-
if (!Array.isArray(value)) {
|
33320
|
-
throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
|
33321
|
-
}
|
33322
|
-
const parts = [];
|
33323
|
-
const pointer = new U64Coder().encode(BASE_VECTOR_OFFSET);
|
33324
|
-
const data = __privateMethod2(this, _getPaddedData, getPaddedData_fn).call(this, value);
|
33325
|
-
pointer.dynamicData = {
|
33326
|
-
0: concatWithDynamicData([data])
|
33327
|
-
};
|
33328
|
-
parts.push(pointer);
|
33329
|
-
parts.push(new U64Coder().encode(data.byteLength));
|
33330
|
-
parts.push(new U64Coder().encode(value.length));
|
33331
|
-
return concatWithDynamicData(parts);
|
33332
|
-
}
|
33333
|
-
decode(data, offset) {
|
33334
|
-
if (data.length < BASE_VECTOR_OFFSET) {
|
33335
|
-
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid byte data size.`);
|
33336
|
-
}
|
33337
|
-
const len = data.slice(16, 24);
|
33338
|
-
const encodedLength = bn(new U64Coder().decode(len, 0)[0]).toNumber();
|
33339
|
-
const byteData = data.slice(BASE_VECTOR_OFFSET, BASE_VECTOR_OFFSET + encodedLength);
|
33340
|
-
if (byteData.length !== encodedLength) {
|
33341
|
-
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid bytes byte data size.`);
|
33342
|
-
}
|
33343
|
-
return [byteData, offset + BASE_VECTOR_OFFSET];
|
33344
|
-
}
|
33345
|
-
};
|
33346
|
-
_getPaddedData = /* @__PURE__ */ new WeakSet();
|
33347
|
-
getPaddedData_fn = function(value) {
|
33348
|
-
const data = [Uint8Array.from(value)];
|
33349
|
-
const paddingLength = (WORD_SIZE - value.length % WORD_SIZE) % WORD_SIZE;
|
33350
|
-
if (paddingLength) {
|
33351
|
-
data.push(new Uint8Array(paddingLength));
|
33352
|
-
}
|
33353
|
-
return concat2(data);
|
33354
|
-
};
|
33355
|
-
__publicField3(ByteCoder, "memorySize", 1);
|
33356
|
-
var RawSliceCoder = class extends Coder {
|
33357
|
-
constructor() {
|
33358
|
-
super("raw untyped slice", "raw untyped slice", BASE_RAW_SLICE_OFFSET);
|
33359
|
-
}
|
33360
|
-
encode(value) {
|
33361
|
-
if (!Array.isArray(value)) {
|
33362
|
-
throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
|
33363
|
-
}
|
33364
|
-
const parts = [];
|
33365
|
-
const coder = new NumberCoder("u8", { isSmallBytes: true });
|
33366
|
-
const pointer = new U64Coder().encode(BASE_RAW_SLICE_OFFSET);
|
33367
|
-
pointer.dynamicData = {
|
33368
|
-
0: concatWithDynamicData(value.map((v) => coder.encode(v)))
|
33369
|
-
};
|
33370
|
-
parts.push(pointer);
|
33371
|
-
parts.push(new U64Coder().encode(value.length));
|
33372
|
-
return concatWithDynamicData(parts);
|
33373
|
-
}
|
33374
|
-
decode(data, offset) {
|
33375
|
-
const dataBytes = data.slice(offset);
|
33376
|
-
const internalCoder = new ArrayCoder(
|
33377
|
-
new NumberCoder("u8", { isSmallBytes: true }),
|
33378
|
-
dataBytes.length
|
33379
|
-
);
|
33380
|
-
const [decodedValue] = internalCoder.decode(dataBytes, 0);
|
33381
|
-
return [decodedValue, offset + dataBytes.length];
|
33382
|
-
}
|
33383
|
-
};
|
33384
|
-
var _getPaddedData2;
|
33385
|
-
var getPaddedData_fn2;
|
33386
|
-
var StdStringCoder = class extends Coder {
|
33387
|
-
constructor() {
|
33388
|
-
super("struct", "struct String", 1);
|
33389
|
-
__privateAdd2(this, _getPaddedData2);
|
33390
|
-
}
|
33391
|
-
encode(value) {
|
33392
|
-
const parts = [];
|
33393
|
-
const pointer = new U64Coder().encode(BASE_VECTOR_OFFSET);
|
33394
|
-
const data = __privateMethod2(this, _getPaddedData2, getPaddedData_fn2).call(this, value);
|
33395
|
-
pointer.dynamicData = {
|
33396
|
-
0: concatWithDynamicData([data])
|
33397
|
-
};
|
33398
|
-
parts.push(pointer);
|
33399
|
-
parts.push(new U64Coder().encode(data.byteLength));
|
33400
|
-
parts.push(new U64Coder().encode(value.length));
|
33401
|
-
return concatWithDynamicData(parts);
|
33402
|
-
}
|
33403
|
-
decode(data, offset) {
|
33404
|
-
if (data.length < this.encodedLength) {
|
33405
|
-
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid std string data size.`);
|
33406
|
-
}
|
33407
|
-
const len = data.slice(16, 24);
|
33408
|
-
const encodedLength = bn(new U64Coder().decode(len, 0)[0]).toNumber();
|
33409
|
-
const byteData = data.slice(BASE_VECTOR_OFFSET, BASE_VECTOR_OFFSET + encodedLength);
|
33410
|
-
if (byteData.length !== encodedLength) {
|
33411
|
-
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid std string byte data size.`);
|
33412
|
-
}
|
33413
|
-
const value = toUtf8String(byteData);
|
33414
|
-
return [value, offset + BASE_VECTOR_OFFSET];
|
33415
|
-
}
|
33416
|
-
};
|
33417
|
-
_getPaddedData2 = /* @__PURE__ */ new WeakSet();
|
33418
|
-
getPaddedData_fn2 = function(value) {
|
33419
|
-
const data = [toUtf8Bytes(value)];
|
33420
|
-
const paddingLength = (WORD_SIZE - value.length % WORD_SIZE) % WORD_SIZE;
|
33421
|
-
if (paddingLength) {
|
33422
|
-
data.push(new Uint8Array(paddingLength));
|
33423
|
-
}
|
33424
|
-
return concat2(data);
|
33425
|
-
};
|
33426
|
-
__publicField3(StdStringCoder, "memorySize", 1);
|
33427
33433
|
var BooleanCoder2 = class extends Coder {
|
33428
33434
|
constructor() {
|
33429
33435
|
super("boolean", "boolean", 1);
|
@@ -34065,7 +34071,7 @@ spurious results.`);
|
|
34065
34071
|
throw new FuelError(ErrorCode.ABI_TYPES_AND_VALUES_MISMATCH, errorMsg);
|
34066
34072
|
}
|
34067
34073
|
decodeArguments(data) {
|
34068
|
-
const bytes4 =
|
34074
|
+
const bytes4 = arrayify(data);
|
34069
34075
|
const nonEmptyInputs = this.jsonFn.inputs.filter(
|
34070
34076
|
(x) => findOrThrow(this.jsonAbi.types, (t) => t.typeId === x.type).type !== "()"
|
34071
34077
|
);
|
@@ -34110,7 +34116,7 @@ spurious results.`);
|
|
34110
34116
|
if (outputAbiType.type === "()") {
|
34111
34117
|
return [void 0, 0];
|
34112
34118
|
}
|
34113
|
-
const bytes4 =
|
34119
|
+
const bytes4 = arrayify(data);
|
34114
34120
|
const coder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output);
|
34115
34121
|
return coder.decode(bytes4, 0);
|
34116
34122
|
}
|
@@ -34177,7 +34183,7 @@ spurious results.`);
|
|
34177
34183
|
return externalInterface.decodeLog(data, logId, receiptId);
|
34178
34184
|
}
|
34179
34185
|
const { loggedType } = findOrThrow(this.jsonAbi.loggedTypes, (type3) => type3.logId === logId);
|
34180
|
-
return AbiCoder.decode(this.jsonAbi, loggedType,
|
34186
|
+
return AbiCoder.decode(this.jsonAbi, loggedType, arrayify(data), 0, {
|
34181
34187
|
version: this.jsonAbi.encoding
|
34182
34188
|
});
|
34183
34189
|
}
|
@@ -34234,12 +34240,12 @@ spurious results.`);
|
|
34234
34240
|
}
|
34235
34241
|
encode(value) {
|
34236
34242
|
const parts = [];
|
34237
|
-
const data =
|
34243
|
+
const data = arrayify(value);
|
34238
34244
|
parts.push(data);
|
34239
34245
|
if (this.#paddingLength) {
|
34240
34246
|
parts.push(new Uint8Array(this.#paddingLength));
|
34241
34247
|
}
|
34242
|
-
return
|
34248
|
+
return concat(parts);
|
34243
34249
|
}
|
34244
34250
|
decode(data, offset) {
|
34245
34251
|
let decoded;
|
@@ -34285,7 +34291,7 @@ spurious results.`);
|
|
34285
34291
|
parts.push(new NumberCoder("u32").encode(value.predicateDataLength));
|
34286
34292
|
parts.push(new ByteArrayCoder(value.predicateLength).encode(value.predicate));
|
34287
34293
|
parts.push(new ByteArrayCoder(value.predicateDataLength).encode(value.predicateData));
|
34288
|
-
return
|
34294
|
+
return concat(parts);
|
34289
34295
|
}
|
34290
34296
|
decode(data, offset) {
|
34291
34297
|
let decoded;
|
@@ -34349,7 +34355,7 @@ spurious results.`);
|
|
34349
34355
|
parts.push(new B256Coder().encode(value.stateRoot));
|
34350
34356
|
parts.push(new TxPointerCoder().encode(value.txPointer));
|
34351
34357
|
parts.push(new B256Coder().encode(value.contractID));
|
34352
|
-
return
|
34358
|
+
return concat(parts);
|
34353
34359
|
}
|
34354
34360
|
decode(data, offset) {
|
34355
34361
|
let decoded;
|
@@ -34390,11 +34396,11 @@ spurious results.`);
|
|
34390
34396
|
parts.push(new ByteArrayCoder(32).encode(value.recipient));
|
34391
34397
|
parts.push(new ByteArrayCoder(32).encode(value.nonce));
|
34392
34398
|
parts.push(new U64Coder().encode(value.amount));
|
34393
|
-
parts.push(
|
34394
|
-
return sha2562(
|
34399
|
+
parts.push(arrayify(value.data || "0x"));
|
34400
|
+
return sha2562(concat(parts));
|
34395
34401
|
}
|
34396
34402
|
static encodeData(messageData) {
|
34397
|
-
const bytes4 =
|
34403
|
+
const bytes4 = arrayify(messageData || "0x");
|
34398
34404
|
const dataLength2 = bytes4.length;
|
34399
34405
|
return new ByteArrayCoder(dataLength2).encode(bytes4);
|
34400
34406
|
}
|
@@ -34413,13 +34419,13 @@ spurious results.`);
|
|
34413
34419
|
parts.push(new ByteArrayCoder(data.length).encode(data));
|
34414
34420
|
parts.push(new ByteArrayCoder(value.predicateLength).encode(value.predicate));
|
34415
34421
|
parts.push(new ByteArrayCoder(value.predicateDataLength).encode(value.predicateData));
|
34416
|
-
return
|
34422
|
+
return concat(parts);
|
34417
34423
|
}
|
34418
34424
|
static decodeData(messageData) {
|
34419
|
-
const bytes4 =
|
34425
|
+
const bytes4 = arrayify(messageData);
|
34420
34426
|
const dataLength2 = bytes4.length;
|
34421
34427
|
const [data] = new ByteArrayCoder(dataLength2).decode(bytes4, 0);
|
34422
|
-
return
|
34428
|
+
return arrayify(data);
|
34423
34429
|
}
|
34424
34430
|
decode(data, offset) {
|
34425
34431
|
let decoded;
|
@@ -34496,7 +34502,7 @@ spurious results.`);
|
|
34496
34502
|
);
|
34497
34503
|
}
|
34498
34504
|
}
|
34499
|
-
return
|
34505
|
+
return concat(parts);
|
34500
34506
|
}
|
34501
34507
|
decode(data, offset) {
|
34502
34508
|
let decoded;
|
@@ -34542,7 +34548,7 @@ spurious results.`);
|
|
34542
34548
|
parts.push(new B256Coder().encode(value.to));
|
34543
34549
|
parts.push(new U64Coder().encode(value.amount));
|
34544
34550
|
parts.push(new B256Coder().encode(value.assetId));
|
34545
|
-
return
|
34551
|
+
return concat(parts);
|
34546
34552
|
}
|
34547
34553
|
decode(data, offset) {
|
34548
34554
|
let decoded;
|
@@ -34573,7 +34579,7 @@ spurious results.`);
|
|
34573
34579
|
parts.push(new NumberCoder("u8").encode(value.inputIndex));
|
34574
34580
|
parts.push(new B256Coder().encode(value.balanceRoot));
|
34575
34581
|
parts.push(new B256Coder().encode(value.stateRoot));
|
34576
|
-
return
|
34582
|
+
return concat(parts);
|
34577
34583
|
}
|
34578
34584
|
decode(data, offset) {
|
34579
34585
|
let decoded;
|
@@ -34604,7 +34610,7 @@ spurious results.`);
|
|
34604
34610
|
parts.push(new B256Coder().encode(value.to));
|
34605
34611
|
parts.push(new U64Coder().encode(value.amount));
|
34606
34612
|
parts.push(new B256Coder().encode(value.assetId));
|
34607
|
-
return
|
34613
|
+
return concat(parts);
|
34608
34614
|
}
|
34609
34615
|
decode(data, offset) {
|
34610
34616
|
let decoded;
|
@@ -34635,7 +34641,7 @@ spurious results.`);
|
|
34635
34641
|
parts.push(new B256Coder().encode(value.to));
|
34636
34642
|
parts.push(new U64Coder().encode(value.amount));
|
34637
34643
|
parts.push(new B256Coder().encode(value.assetId));
|
34638
|
-
return
|
34644
|
+
return concat(parts);
|
34639
34645
|
}
|
34640
34646
|
decode(data, offset) {
|
34641
34647
|
let decoded;
|
@@ -34665,7 +34671,7 @@ spurious results.`);
|
|
34665
34671
|
const parts = [];
|
34666
34672
|
parts.push(new B256Coder().encode(value.contractId));
|
34667
34673
|
parts.push(new B256Coder().encode(value.stateRoot));
|
34668
|
-
return
|
34674
|
+
return concat(parts);
|
34669
34675
|
}
|
34670
34676
|
decode(data, offset) {
|
34671
34677
|
let decoded;
|
@@ -34720,7 +34726,7 @@ spurious results.`);
|
|
34720
34726
|
);
|
34721
34727
|
}
|
34722
34728
|
}
|
34723
|
-
return
|
34729
|
+
return concat(parts);
|
34724
34730
|
}
|
34725
34731
|
decode(data, offset) {
|
34726
34732
|
let decoded;
|
@@ -34800,7 +34806,7 @@ spurious results.`);
|
|
34800
34806
|
}
|
34801
34807
|
}
|
34802
34808
|
});
|
34803
|
-
return
|
34809
|
+
return concat(parts);
|
34804
34810
|
}
|
34805
34811
|
decode(data, offset, policyTypes) {
|
34806
34812
|
let o = offset;
|
@@ -34854,8 +34860,8 @@ spurious results.`);
|
|
34854
34860
|
parts.push(new ByteArrayCoder(32).encode(value.recipient));
|
34855
34861
|
parts.push(new ByteArrayCoder(32).encode(value.nonce));
|
34856
34862
|
parts.push(new U64Coder().encode(value.amount));
|
34857
|
-
parts.push(
|
34858
|
-
return sha2562(
|
34863
|
+
parts.push(arrayify(value.data || "0x"));
|
34864
|
+
return sha2562(concat(parts));
|
34859
34865
|
}
|
34860
34866
|
encode(value) {
|
34861
34867
|
const parts = [];
|
@@ -34866,7 +34872,7 @@ spurious results.`);
|
|
34866
34872
|
parts.push(new NumberCoder("u16").encode(value.data.length));
|
34867
34873
|
parts.push(new B256Coder().encode(value.digest));
|
34868
34874
|
parts.push(new ByteArrayCoder(value.data.length).encode(value.data));
|
34869
|
-
return
|
34875
|
+
return concat(parts);
|
34870
34876
|
}
|
34871
34877
|
decode(data, offset) {
|
34872
34878
|
let decoded;
|
@@ -34884,7 +34890,7 @@ spurious results.`);
|
|
34884
34890
|
[decoded, o] = new B256Coder().decode(data, o);
|
34885
34891
|
const digest = decoded;
|
34886
34892
|
[decoded, o] = new ByteArrayCoder(len).decode(data, o);
|
34887
|
-
const messageData =
|
34893
|
+
const messageData = arrayify(decoded);
|
34888
34894
|
const receiptMessageOut = {
|
34889
34895
|
type: 10,
|
34890
34896
|
messageId: "",
|
@@ -34900,9 +34906,9 @@ spurious results.`);
|
|
34900
34906
|
}
|
34901
34907
|
};
|
34902
34908
|
var getAssetId = (contractId, subId) => {
|
34903
|
-
const contractIdBytes =
|
34904
|
-
const subIdBytes =
|
34905
|
-
return sha2562(
|
34909
|
+
const contractIdBytes = arrayify(contractId);
|
34910
|
+
const subIdBytes = arrayify(subId);
|
34911
|
+
return sha2562(concat([contractIdBytes, subIdBytes]));
|
34906
34912
|
};
|
34907
34913
|
var ReceiptMintCoder = class extends Coder {
|
34908
34914
|
constructor() {
|
@@ -34918,7 +34924,7 @@ spurious results.`);
|
|
34918
34924
|
parts.push(new U64Coder().encode(value.val));
|
34919
34925
|
parts.push(new U64Coder().encode(value.pc));
|
34920
34926
|
parts.push(new U64Coder().encode(value.is));
|
34921
|
-
return
|
34927
|
+
return concat(parts);
|
34922
34928
|
}
|
34923
34929
|
decode(data, offset) {
|
34924
34930
|
let decoded;
|
@@ -34960,7 +34966,7 @@ spurious results.`);
|
|
34960
34966
|
parts.push(new U64Coder().encode(value.val));
|
34961
34967
|
parts.push(new U64Coder().encode(value.pc));
|
34962
34968
|
parts.push(new U64Coder().encode(value.is));
|
34963
|
-
return
|
34969
|
+
return concat(parts);
|
34964
34970
|
}
|
34965
34971
|
decode(data, offset) {
|
34966
34972
|
let decoded;
|
@@ -35009,7 +35015,7 @@ spurious results.`);
|
|
35009
35015
|
const parts = [];
|
35010
35016
|
parts.push(new NumberCoder("u16").encode(value.dataLength));
|
35011
35017
|
parts.push(new ByteArrayCoder(value.dataLength).encode(value.data));
|
35012
|
-
return
|
35018
|
+
return concat(parts);
|
35013
35019
|
}
|
35014
35020
|
decode(data, offset) {
|
35015
35021
|
let decoded;
|
@@ -35053,7 +35059,7 @@ spurious results.`);
|
|
35053
35059
|
parts.push(new ArrayCoder(new InputCoder(), value.inputsCount).encode(value.inputs));
|
35054
35060
|
parts.push(new ArrayCoder(new OutputCoder(), value.outputsCount).encode(value.outputs));
|
35055
35061
|
parts.push(new ArrayCoder(new WitnessCoder(), value.witnessesCount).encode(value.witnesses));
|
35056
|
-
return
|
35062
|
+
return concat(parts);
|
35057
35063
|
}
|
35058
35064
|
decode(data, offset) {
|
35059
35065
|
let decoded;
|
@@ -35129,7 +35135,7 @@ spurious results.`);
|
|
35129
35135
|
parts.push(new ArrayCoder(new InputCoder(), value.inputsCount).encode(value.inputs));
|
35130
35136
|
parts.push(new ArrayCoder(new OutputCoder(), value.outputsCount).encode(value.outputs));
|
35131
35137
|
parts.push(new ArrayCoder(new WitnessCoder(), value.witnessesCount).encode(value.witnesses));
|
35132
|
-
return
|
35138
|
+
return concat(parts);
|
35133
35139
|
}
|
35134
35140
|
decode(data, offset) {
|
35135
35141
|
let decoded;
|
@@ -35192,7 +35198,7 @@ spurious results.`);
|
|
35192
35198
|
parts.push(new OutputContractCoder().encode(value.outputContract));
|
35193
35199
|
parts.push(new U64Coder().encode(value.mintAmount));
|
35194
35200
|
parts.push(new B256Coder().encode(value.mintAssetId));
|
35195
|
-
return
|
35201
|
+
return concat(parts);
|
35196
35202
|
}
|
35197
35203
|
decode(data, offset) {
|
35198
35204
|
let decoded;
|
@@ -35252,7 +35258,7 @@ spurious results.`);
|
|
35252
35258
|
);
|
35253
35259
|
}
|
35254
35260
|
}
|
35255
|
-
return
|
35261
|
+
return concat(parts);
|
35256
35262
|
}
|
35257
35263
|
decode(data, offset) {
|
35258
35264
|
let decoded;
|
@@ -35282,6 +35288,242 @@ spurious results.`);
|
|
35282
35288
|
}
|
35283
35289
|
};
|
35284
35290
|
|
35291
|
+
// ../../node_modules/.pnpm/@noble+curves@1.3.0/node_modules/@noble/curves/esm/abstract/utils.js
|
35292
|
+
var utils_exports = {};
|
35293
|
+
__export(utils_exports, {
|
35294
|
+
bitGet: () => bitGet,
|
35295
|
+
bitLen: () => bitLen,
|
35296
|
+
bitMask: () => bitMask,
|
35297
|
+
bitSet: () => bitSet,
|
35298
|
+
bytesToHex: () => bytesToHex2,
|
35299
|
+
bytesToNumberBE: () => bytesToNumberBE,
|
35300
|
+
bytesToNumberLE: () => bytesToNumberLE,
|
35301
|
+
concatBytes: () => concatBytes3,
|
35302
|
+
createHmacDrbg: () => createHmacDrbg,
|
35303
|
+
ensureBytes: () => ensureBytes,
|
35304
|
+
equalBytes: () => equalBytes,
|
35305
|
+
hexToBytes: () => hexToBytes2,
|
35306
|
+
hexToNumber: () => hexToNumber,
|
35307
|
+
isBytes: () => isBytes,
|
35308
|
+
numberToBytesBE: () => numberToBytesBE,
|
35309
|
+
numberToBytesLE: () => numberToBytesLE,
|
35310
|
+
numberToHexUnpadded: () => numberToHexUnpadded,
|
35311
|
+
numberToVarBytesBE: () => numberToVarBytesBE,
|
35312
|
+
utf8ToBytes: () => utf8ToBytes3,
|
35313
|
+
validateObject: () => validateObject
|
35314
|
+
});
|
35315
|
+
var _0n3 = BigInt(0);
|
35316
|
+
var _1n3 = BigInt(1);
|
35317
|
+
var _2n3 = BigInt(2);
|
35318
|
+
function isBytes(a) {
|
35319
|
+
return a instanceof Uint8Array || a != null && typeof a === "object" && a.constructor.name === "Uint8Array";
|
35320
|
+
}
|
35321
|
+
var hexes3 = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
|
35322
|
+
function bytesToHex2(bytes4) {
|
35323
|
+
if (!isBytes(bytes4))
|
35324
|
+
throw new Error("Uint8Array expected");
|
35325
|
+
let hex = "";
|
35326
|
+
for (let i = 0; i < bytes4.length; i++) {
|
35327
|
+
hex += hexes3[bytes4[i]];
|
35328
|
+
}
|
35329
|
+
return hex;
|
35330
|
+
}
|
35331
|
+
function numberToHexUnpadded(num) {
|
35332
|
+
const hex = num.toString(16);
|
35333
|
+
return hex.length & 1 ? `0${hex}` : hex;
|
35334
|
+
}
|
35335
|
+
function hexToNumber(hex) {
|
35336
|
+
if (typeof hex !== "string")
|
35337
|
+
throw new Error("hex string expected, got " + typeof hex);
|
35338
|
+
return BigInt(hex === "" ? "0" : `0x${hex}`);
|
35339
|
+
}
|
35340
|
+
var asciis = { _0: 48, _9: 57, _A: 65, _F: 70, _a: 97, _f: 102 };
|
35341
|
+
function asciiToBase16(char) {
|
35342
|
+
if (char >= asciis._0 && char <= asciis._9)
|
35343
|
+
return char - asciis._0;
|
35344
|
+
if (char >= asciis._A && char <= asciis._F)
|
35345
|
+
return char - (asciis._A - 10);
|
35346
|
+
if (char >= asciis._a && char <= asciis._f)
|
35347
|
+
return char - (asciis._a - 10);
|
35348
|
+
return;
|
35349
|
+
}
|
35350
|
+
function hexToBytes2(hex) {
|
35351
|
+
if (typeof hex !== "string")
|
35352
|
+
throw new Error("hex string expected, got " + typeof hex);
|
35353
|
+
const hl = hex.length;
|
35354
|
+
const al = hl / 2;
|
35355
|
+
if (hl % 2)
|
35356
|
+
throw new Error("padded hex string expected, got unpadded hex of length " + hl);
|
35357
|
+
const array = new Uint8Array(al);
|
35358
|
+
for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
|
35359
|
+
const n1 = asciiToBase16(hex.charCodeAt(hi));
|
35360
|
+
const n2 = asciiToBase16(hex.charCodeAt(hi + 1));
|
35361
|
+
if (n1 === void 0 || n2 === void 0) {
|
35362
|
+
const char = hex[hi] + hex[hi + 1];
|
35363
|
+
throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
|
35364
|
+
}
|
35365
|
+
array[ai] = n1 * 16 + n2;
|
35366
|
+
}
|
35367
|
+
return array;
|
35368
|
+
}
|
35369
|
+
function bytesToNumberBE(bytes4) {
|
35370
|
+
return hexToNumber(bytesToHex2(bytes4));
|
35371
|
+
}
|
35372
|
+
function bytesToNumberLE(bytes4) {
|
35373
|
+
if (!isBytes(bytes4))
|
35374
|
+
throw new Error("Uint8Array expected");
|
35375
|
+
return hexToNumber(bytesToHex2(Uint8Array.from(bytes4).reverse()));
|
35376
|
+
}
|
35377
|
+
function numberToBytesBE(n, len) {
|
35378
|
+
return hexToBytes2(n.toString(16).padStart(len * 2, "0"));
|
35379
|
+
}
|
35380
|
+
function numberToBytesLE(n, len) {
|
35381
|
+
return numberToBytesBE(n, len).reverse();
|
35382
|
+
}
|
35383
|
+
function numberToVarBytesBE(n) {
|
35384
|
+
return hexToBytes2(numberToHexUnpadded(n));
|
35385
|
+
}
|
35386
|
+
function ensureBytes(title, hex, expectedLength) {
|
35387
|
+
let res;
|
35388
|
+
if (typeof hex === "string") {
|
35389
|
+
try {
|
35390
|
+
res = hexToBytes2(hex);
|
35391
|
+
} catch (e) {
|
35392
|
+
throw new Error(`${title} must be valid hex string, got "${hex}". Cause: ${e}`);
|
35393
|
+
}
|
35394
|
+
} else if (isBytes(hex)) {
|
35395
|
+
res = Uint8Array.from(hex);
|
35396
|
+
} else {
|
35397
|
+
throw new Error(`${title} must be hex string or Uint8Array`);
|
35398
|
+
}
|
35399
|
+
const len = res.length;
|
35400
|
+
if (typeof expectedLength === "number" && len !== expectedLength)
|
35401
|
+
throw new Error(`${title} expected ${expectedLength} bytes, got ${len}`);
|
35402
|
+
return res;
|
35403
|
+
}
|
35404
|
+
function concatBytes3(...arrays) {
|
35405
|
+
let sum = 0;
|
35406
|
+
for (let i = 0; i < arrays.length; i++) {
|
35407
|
+
const a = arrays[i];
|
35408
|
+
if (!isBytes(a))
|
35409
|
+
throw new Error("Uint8Array expected");
|
35410
|
+
sum += a.length;
|
35411
|
+
}
|
35412
|
+
let res = new Uint8Array(sum);
|
35413
|
+
let pad3 = 0;
|
35414
|
+
for (let i = 0; i < arrays.length; i++) {
|
35415
|
+
const a = arrays[i];
|
35416
|
+
res.set(a, pad3);
|
35417
|
+
pad3 += a.length;
|
35418
|
+
}
|
35419
|
+
return res;
|
35420
|
+
}
|
35421
|
+
function equalBytes(a, b) {
|
35422
|
+
if (a.length !== b.length)
|
35423
|
+
return false;
|
35424
|
+
let diff = 0;
|
35425
|
+
for (let i = 0; i < a.length; i++)
|
35426
|
+
diff |= a[i] ^ b[i];
|
35427
|
+
return diff === 0;
|
35428
|
+
}
|
35429
|
+
function utf8ToBytes3(str) {
|
35430
|
+
if (typeof str !== "string")
|
35431
|
+
throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
|
35432
|
+
return new Uint8Array(new TextEncoder().encode(str));
|
35433
|
+
}
|
35434
|
+
function bitLen(n) {
|
35435
|
+
let len;
|
35436
|
+
for (len = 0; n > _0n3; n >>= _1n3, len += 1)
|
35437
|
+
;
|
35438
|
+
return len;
|
35439
|
+
}
|
35440
|
+
function bitGet(n, pos) {
|
35441
|
+
return n >> BigInt(pos) & _1n3;
|
35442
|
+
}
|
35443
|
+
var bitSet = (n, pos, value) => {
|
35444
|
+
return n | (value ? _1n3 : _0n3) << BigInt(pos);
|
35445
|
+
};
|
35446
|
+
var bitMask = (n) => (_2n3 << BigInt(n - 1)) - _1n3;
|
35447
|
+
var u8n = (data) => new Uint8Array(data);
|
35448
|
+
var u8fr = (arr) => Uint8Array.from(arr);
|
35449
|
+
function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
35450
|
+
if (typeof hashLen !== "number" || hashLen < 2)
|
35451
|
+
throw new Error("hashLen must be a number");
|
35452
|
+
if (typeof qByteLen !== "number" || qByteLen < 2)
|
35453
|
+
throw new Error("qByteLen must be a number");
|
35454
|
+
if (typeof hmacFn !== "function")
|
35455
|
+
throw new Error("hmacFn must be a function");
|
35456
|
+
let v = u8n(hashLen);
|
35457
|
+
let k = u8n(hashLen);
|
35458
|
+
let i = 0;
|
35459
|
+
const reset = () => {
|
35460
|
+
v.fill(1);
|
35461
|
+
k.fill(0);
|
35462
|
+
i = 0;
|
35463
|
+
};
|
35464
|
+
const h = (...b) => hmacFn(k, v, ...b);
|
35465
|
+
const reseed = (seed = u8n()) => {
|
35466
|
+
k = h(u8fr([0]), seed);
|
35467
|
+
v = h();
|
35468
|
+
if (seed.length === 0)
|
35469
|
+
return;
|
35470
|
+
k = h(u8fr([1]), seed);
|
35471
|
+
v = h();
|
35472
|
+
};
|
35473
|
+
const gen3 = () => {
|
35474
|
+
if (i++ >= 1e3)
|
35475
|
+
throw new Error("drbg: tried 1000 values");
|
35476
|
+
let len = 0;
|
35477
|
+
const out = [];
|
35478
|
+
while (len < qByteLen) {
|
35479
|
+
v = h();
|
35480
|
+
const sl = v.slice();
|
35481
|
+
out.push(sl);
|
35482
|
+
len += v.length;
|
35483
|
+
}
|
35484
|
+
return concatBytes3(...out);
|
35485
|
+
};
|
35486
|
+
const genUntil = (seed, pred) => {
|
35487
|
+
reset();
|
35488
|
+
reseed(seed);
|
35489
|
+
let res = void 0;
|
35490
|
+
while (!(res = pred(gen3())))
|
35491
|
+
reseed();
|
35492
|
+
reset();
|
35493
|
+
return res;
|
35494
|
+
};
|
35495
|
+
return genUntil;
|
35496
|
+
}
|
35497
|
+
var validatorFns = {
|
35498
|
+
bigint: (val) => typeof val === "bigint",
|
35499
|
+
function: (val) => typeof val === "function",
|
35500
|
+
boolean: (val) => typeof val === "boolean",
|
35501
|
+
string: (val) => typeof val === "string",
|
35502
|
+
stringOrUint8Array: (val) => typeof val === "string" || isBytes(val),
|
35503
|
+
isSafeInteger: (val) => Number.isSafeInteger(val),
|
35504
|
+
array: (val) => Array.isArray(val),
|
35505
|
+
field: (val, object) => object.Fp.isValid(val),
|
35506
|
+
hash: (val) => typeof val === "function" && Number.isSafeInteger(val.outputLen)
|
35507
|
+
};
|
35508
|
+
function validateObject(object, validators, optValidators = {}) {
|
35509
|
+
const checkField = (fieldName, type3, isOptional) => {
|
35510
|
+
const checkVal = validatorFns[type3];
|
35511
|
+
if (typeof checkVal !== "function")
|
35512
|
+
throw new Error(`Invalid validator "${type3}", expected function`);
|
35513
|
+
const val = object[fieldName];
|
35514
|
+
if (isOptional && val === void 0)
|
35515
|
+
return;
|
35516
|
+
if (!checkVal(val, object)) {
|
35517
|
+
throw new Error(`Invalid param ${String(fieldName)}=${val} (${typeof val}), expected ${type3}`);
|
35518
|
+
}
|
35519
|
+
};
|
35520
|
+
for (const [fieldName, type3] of Object.entries(validators))
|
35521
|
+
checkField(fieldName, type3, false);
|
35522
|
+
for (const [fieldName, type3] of Object.entries(optValidators))
|
35523
|
+
checkField(fieldName, type3, true);
|
35524
|
+
return object;
|
35525
|
+
}
|
35526
|
+
|
35285
35527
|
// src/providers/provider.ts
|
35286
35528
|
var import_graphql_request = __toESM(require_dist2());
|
35287
35529
|
|
@@ -39528,18 +39770,18 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39528
39770
|
const { type: type3 } = value;
|
39529
39771
|
switch (value.type) {
|
39530
39772
|
case InputType.Coin: {
|
39531
|
-
const predicate =
|
39532
|
-
const predicateData =
|
39773
|
+
const predicate = arrayify(value.predicate ?? "0x");
|
39774
|
+
const predicateData = arrayify(value.predicateData ?? "0x");
|
39533
39775
|
return {
|
39534
39776
|
type: InputType.Coin,
|
39535
|
-
txID: hexlify(
|
39536
|
-
outputIndex:
|
39777
|
+
txID: hexlify(arrayify(value.id).slice(0, 32)),
|
39778
|
+
outputIndex: arrayify(value.id)[32],
|
39537
39779
|
owner: hexlify(value.owner),
|
39538
39780
|
amount: bn(value.amount),
|
39539
39781
|
assetId: hexlify(value.assetId),
|
39540
39782
|
txPointer: {
|
39541
|
-
blockHeight: toNumber2(
|
39542
|
-
txIndex: toNumber2(
|
39783
|
+
blockHeight: toNumber2(arrayify(value.txPointer).slice(0, 8)),
|
39784
|
+
txIndex: toNumber2(arrayify(value.txPointer).slice(8, 16))
|
39543
39785
|
},
|
39544
39786
|
witnessIndex: value.witnessIndex,
|
39545
39787
|
maturity: value.maturity ?? 0,
|
@@ -39558,16 +39800,16 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39558
39800
|
balanceRoot: ZeroBytes32,
|
39559
39801
|
stateRoot: ZeroBytes32,
|
39560
39802
|
txPointer: {
|
39561
|
-
blockHeight: toNumber2(
|
39562
|
-
txIndex: toNumber2(
|
39803
|
+
blockHeight: toNumber2(arrayify(value.txPointer).slice(0, 8)),
|
39804
|
+
txIndex: toNumber2(arrayify(value.txPointer).slice(8, 16))
|
39563
39805
|
},
|
39564
39806
|
contractID: hexlify(value.contractId)
|
39565
39807
|
};
|
39566
39808
|
}
|
39567
39809
|
case InputType.Message: {
|
39568
|
-
const predicate =
|
39569
|
-
const predicateData =
|
39570
|
-
const data =
|
39810
|
+
const predicate = arrayify(value.predicate ?? "0x");
|
39811
|
+
const predicateData = arrayify(value.predicateData ?? "0x");
|
39812
|
+
const data = arrayify(value.data ?? "0x");
|
39571
39813
|
return {
|
39572
39814
|
type: InputType.Message,
|
39573
39815
|
sender: hexlify(value.sender),
|
@@ -39803,7 +40045,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39803
40045
|
const recipient = hexOrZero(receipt.recipient);
|
39804
40046
|
const nonce = hexOrZero(receipt.nonce);
|
39805
40047
|
const amount = bn(receipt.amount);
|
39806
|
-
const data = receipt.data ?
|
40048
|
+
const data = receipt.data ? arrayify(receipt.data) : Uint8Array.from([]);
|
39807
40049
|
const digest = hexOrZero(receipt.digest);
|
39808
40050
|
const messageId = ReceiptMessageOutCoder.getMessageId({
|
39809
40051
|
sender,
|
@@ -39945,9 +40187,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39945
40187
|
const totalGas = inputs.reduce((total, input) => {
|
39946
40188
|
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
39947
40189
|
return total.add(
|
39948
|
-
resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(
|
39949
|
-
resolveGasDependentCosts(getBytesCopy(input.predicate).length, gasCosts.contractRoot)
|
39950
|
-
).add(bn(input.predicateGasUsed))
|
40190
|
+
resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify(input.predicate).length, gasCosts.contractRoot)).add(bn(input.predicateGasUsed))
|
39951
40191
|
);
|
39952
40192
|
}
|
39953
40193
|
if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
|
@@ -40061,7 +40301,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
40061
40301
|
|
40062
40302
|
// src/providers/transaction-request/witness.ts
|
40063
40303
|
var witnessify = (value) => {
|
40064
|
-
const data =
|
40304
|
+
const data = arrayify(value);
|
40065
40305
|
return {
|
40066
40306
|
data: hexlify(data),
|
40067
40307
|
dataLength: data.length
|
@@ -40476,7 +40716,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
40476
40716
|
*
|
40477
40717
|
* @param quantities - CoinQuantity Array.
|
40478
40718
|
*/
|
40479
|
-
fundWithFakeUtxos(quantities) {
|
40719
|
+
fundWithFakeUtxos(quantities, resourcesOwner) {
|
40480
40720
|
let idCounter = 0;
|
40481
40721
|
const generateId = () => {
|
40482
40722
|
const counterString = String(idCounter++);
|
@@ -40500,7 +40740,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
40500
40740
|
id: generateId(),
|
40501
40741
|
amount: quantity,
|
40502
40742
|
assetId,
|
40503
|
-
owner: Address.fromRandom(),
|
40743
|
+
owner: resourcesOwner || Address.fromRandom(),
|
40504
40744
|
maturity: 0,
|
40505
40745
|
blockCreated: bn(1),
|
40506
40746
|
txCreatedIdx: bn(1)
|
@@ -40533,19 +40773,29 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
40533
40773
|
toJSON() {
|
40534
40774
|
return normalizeJSON(this);
|
40535
40775
|
}
|
40536
|
-
|
40537
|
-
|
40538
|
-
|
40539
|
-
|
40540
|
-
|
40541
|
-
|
40542
|
-
|
40543
|
-
|
40544
|
-
|
40545
|
-
|
40546
|
-
|
40547
|
-
|
40548
|
-
|
40776
|
+
updatePredicateInputs(inputs) {
|
40777
|
+
this.inputs.forEach((i) => {
|
40778
|
+
let correspondingInput;
|
40779
|
+
switch (i.type) {
|
40780
|
+
case InputType.Contract:
|
40781
|
+
return;
|
40782
|
+
case InputType.Coin:
|
40783
|
+
correspondingInput = inputs.find((x) => x.type === InputType.Coin && x.owner === i.owner);
|
40784
|
+
break;
|
40785
|
+
case InputType.Message:
|
40786
|
+
correspondingInput = inputs.find(
|
40787
|
+
(x) => x.type === InputType.Message && x.sender === i.sender
|
40788
|
+
);
|
40789
|
+
break;
|
40790
|
+
default:
|
40791
|
+
break;
|
40792
|
+
}
|
40793
|
+
if (correspondingInput && "predicateGasUsed" in correspondingInput && bn(correspondingInput.predicateGasUsed).gt(0)) {
|
40794
|
+
i.predicate = correspondingInput.predicate;
|
40795
|
+
i.predicateData = correspondingInput.predicateData;
|
40796
|
+
i.predicateGasUsed = correspondingInput.predicateGasUsed;
|
40797
|
+
}
|
40798
|
+
});
|
40549
40799
|
}
|
40550
40800
|
};
|
40551
40801
|
|
@@ -40632,7 +40882,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
40632
40882
|
// src/providers/transaction-request/storage-slot.ts
|
40633
40883
|
var getStorageValue = (value) => {
|
40634
40884
|
const v = new Uint8Array(32);
|
40635
|
-
v.set(
|
40885
|
+
v.set(arrayify(value));
|
40636
40886
|
return v;
|
40637
40887
|
};
|
40638
40888
|
var storageSlotify = (storageSlot) => {
|
@@ -40737,7 +40987,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
40737
40987
|
}
|
40738
40988
|
metadataGas(gasCosts) {
|
40739
40989
|
return calculateMetadataGasForTxCreate({
|
40740
|
-
contractBytesSize: bn(
|
40990
|
+
contractBytesSize: bn(arrayify(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
|
40741
40991
|
gasCosts,
|
40742
40992
|
stateRootSize: this.storageSlots.length,
|
40743
40993
|
txBytesSize: this.byteSize()
|
@@ -40752,7 +41002,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
40752
41002
|
Opcode::NOOP
|
40753
41003
|
*/
|
40754
41004
|
// TODO: Don't use hardcoded scripts: https://github.com/FuelLabs/fuels-ts/issues/281
|
40755
|
-
bytes:
|
41005
|
+
bytes: arrayify("0x24000000"),
|
40756
41006
|
encodeScriptData: () => new Uint8Array(0)
|
40757
41007
|
};
|
40758
41008
|
var withdrawScript = {
|
@@ -40766,7 +41016,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
40766
41016
|
00000000 00000000 [amount value]
|
40767
41017
|
*/
|
40768
41018
|
// TODO: Don't use hardcoded scripts: https://github.com/FuelLabs/fuels-ts/issues/281
|
40769
|
-
bytes:
|
41019
|
+
bytes: arrayify("0x5040C0105D44C0064C40001124000000"),
|
40770
41020
|
encodeScriptData: () => new Uint8Array(0)
|
40771
41021
|
};
|
40772
41022
|
|
@@ -40794,8 +41044,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
40794
41044
|
constructor({ script, scriptData, gasLimit, ...rest } = {}) {
|
40795
41045
|
super(rest);
|
40796
41046
|
this.gasLimit = bn(gasLimit);
|
40797
|
-
this.script =
|
40798
|
-
this.scriptData =
|
41047
|
+
this.script = arrayify(script ?? returnZeroScript.bytes);
|
41048
|
+
this.scriptData = arrayify(scriptData ?? returnZeroScript.encodeScriptData());
|
40799
41049
|
}
|
40800
41050
|
/**
|
40801
41051
|
* Converts the transaction request to a `TransactionScript`.
|
@@ -40803,8 +41053,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
40803
41053
|
* @returns The transaction script object.
|
40804
41054
|
*/
|
40805
41055
|
toTransaction() {
|
40806
|
-
const script =
|
40807
|
-
const scriptData =
|
41056
|
+
const script = arrayify(this.script ?? "0x");
|
41057
|
+
const scriptData = arrayify(this.scriptData ?? "0x");
|
40808
41058
|
return {
|
40809
41059
|
type: TransactionType.Script,
|
40810
41060
|
scriptGasLimit: this.gasLimit,
|
@@ -40967,7 +41217,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
40967
41217
|
} = params;
|
40968
41218
|
const gasPerByte = bn(feeParams.gasPerByte);
|
40969
41219
|
const gasPriceFactor = bn(feeParams.gasPriceFactor);
|
40970
|
-
const transactionBytes =
|
41220
|
+
const transactionBytes = arrayify(rawPayload);
|
40971
41221
|
const [transaction] = new TransactionCoder().decode(transactionBytes, 0);
|
40972
41222
|
if (transaction.type === TransactionType.Mint) {
|
40973
41223
|
return {
|
@@ -40982,7 +41232,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
40982
41232
|
let gasLimit = bn(0);
|
40983
41233
|
if (type3 === TransactionType.Create) {
|
40984
41234
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
40985
|
-
const contractBytesSize = bn(
|
41235
|
+
const contractBytesSize = bn(arrayify(witnesses[bytecodeWitnessIndex].data).length);
|
40986
41236
|
metadataGas = calculateMetadataGasForTxCreate({
|
40987
41237
|
contractBytesSize,
|
40988
41238
|
gasCosts,
|
@@ -41775,7 +42025,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
41775
42025
|
*/
|
41776
42026
|
decodeTransaction(transactionWithReceipts) {
|
41777
42027
|
return new TransactionCoder().decode(
|
41778
|
-
|
42028
|
+
arrayify(transactionWithReceipts.rawPayload),
|
41779
42029
|
0
|
41780
42030
|
)?.[0];
|
41781
42031
|
}
|
@@ -41801,7 +42051,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
41801
42051
|
id: this.id,
|
41802
42052
|
receipts,
|
41803
42053
|
transaction: decodedTransaction,
|
41804
|
-
transactionBytes:
|
42054
|
+
transactionBytes: arrayify(transaction.rawPayload),
|
41805
42055
|
gqlTransactionStatus: transaction.status,
|
41806
42056
|
gasPerByte,
|
41807
42057
|
gasPriceFactor,
|
@@ -42233,7 +42483,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42233
42483
|
async call(transactionRequestLike, { utxoValidation, estimateTxDependencies = true } = {}) {
|
42234
42484
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
42235
42485
|
if (estimateTxDependencies) {
|
42236
|
-
|
42486
|
+
return this.estimateTxDependencies(transactionRequest);
|
42237
42487
|
}
|
42238
42488
|
const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
|
42239
42489
|
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
@@ -42252,6 +42502,14 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42252
42502
|
* @returns A promise that resolves to the estimated transaction request object.
|
42253
42503
|
*/
|
42254
42504
|
async estimatePredicates(transactionRequest) {
|
42505
|
+
const shouldEstimatePredicates = Boolean(
|
42506
|
+
transactionRequest.inputs.find(
|
42507
|
+
(input) => "predicate" in input && input.predicate && !equalBytes(arrayify(input.predicate), arrayify("0x")) && new BN(input.predicateGasUsed).isZero()
|
42508
|
+
)
|
42509
|
+
);
|
42510
|
+
if (!shouldEstimatePredicates) {
|
42511
|
+
return transactionRequest;
|
42512
|
+
}
|
42255
42513
|
const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
|
42256
42514
|
const response = await this.operations.estimatePredicates({
|
42257
42515
|
encodedTransaction
|
@@ -42282,34 +42540,33 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42282
42540
|
* @returns A promise.
|
42283
42541
|
*/
|
42284
42542
|
async estimateTxDependencies(transactionRequest) {
|
42285
|
-
let missingOutputVariableCount = 0;
|
42286
|
-
let missingOutputContractIdsCount = 0;
|
42287
|
-
let tries = 0;
|
42288
42543
|
if (transactionRequest.type === TransactionType.Create) {
|
42289
|
-
return
|
42290
|
-
|
42291
|
-
|
42292
|
-
if (txRequest.hasPredicateInput()) {
|
42293
|
-
txRequest = await this.estimatePredicates(txRequest);
|
42544
|
+
return {
|
42545
|
+
receipts: []
|
42546
|
+
};
|
42294
42547
|
}
|
42295
|
-
|
42548
|
+
await this.estimatePredicates(transactionRequest);
|
42549
|
+
let receipts = [];
|
42550
|
+
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
42296
42551
|
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
42297
|
-
encodedTransaction: hexlify(
|
42552
|
+
encodedTransaction: hexlify(transactionRequest.toTransactionBytes()),
|
42298
42553
|
utxoValidation: false
|
42299
42554
|
});
|
42300
|
-
|
42555
|
+
receipts = gqlReceipts.map(processGqlReceipt);
|
42301
42556
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
42302
|
-
|
42303
|
-
|
42304
|
-
|
42305
|
-
|
42557
|
+
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
42558
|
+
if (hasMissingOutputs) {
|
42559
|
+
transactionRequest.addVariableOutputs(missingOutputVariables.length);
|
42560
|
+
missingOutputContractIds.forEach(({ contractId }) => {
|
42561
|
+
transactionRequest.addContractInputAndOutput(Address.fromString(contractId));
|
42562
|
+
});
|
42563
|
+
} else {
|
42564
|
+
break;
|
42306
42565
|
}
|
42307
|
-
txRequest.addVariableOutputs(missingOutputVariableCount);
|
42308
|
-
missingOutputContractIds.forEach(
|
42309
|
-
({ contractId }) => txRequest.addContractInputAndOutput(Address.fromString(contractId))
|
42310
|
-
);
|
42311
|
-
tries += 1;
|
42312
42566
|
}
|
42567
|
+
return {
|
42568
|
+
receipts
|
42569
|
+
};
|
42313
42570
|
}
|
42314
42571
|
/**
|
42315
42572
|
* Executes a signed transaction without applying the states changes
|
@@ -42324,7 +42581,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42324
42581
|
async simulate(transactionRequestLike, { estimateTxDependencies = true } = {}) {
|
42325
42582
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
42326
42583
|
if (estimateTxDependencies) {
|
42327
|
-
|
42584
|
+
return this.estimateTxDependencies(transactionRequest);
|
42328
42585
|
}
|
42329
42586
|
const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
|
42330
42587
|
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
@@ -42351,36 +42608,38 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42351
42608
|
* @param tolerance - The tolerance to add on top of the gasUsed.
|
42352
42609
|
* @returns A promise that resolves to the transaction cost object.
|
42353
42610
|
*/
|
42354
|
-
async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
|
42355
|
-
|
42611
|
+
async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
|
42612
|
+
estimateTxDependencies = true,
|
42613
|
+
estimatePredicates = true,
|
42614
|
+
resourcesOwner
|
42615
|
+
} = {}) {
|
42616
|
+
const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
|
42356
42617
|
const chainInfo = this.getChain();
|
42357
42618
|
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
42358
|
-
const gasPrice = max(
|
42359
|
-
const isScriptTransaction =
|
42360
|
-
|
42619
|
+
const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
42620
|
+
const isScriptTransaction = txRequestClone.type === TransactionType.Script;
|
42621
|
+
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
42622
|
+
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
42623
|
+
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
42624
|
+
if (estimatePredicates) {
|
42361
42625
|
if (isScriptTransaction) {
|
42362
|
-
|
42626
|
+
txRequestClone.gasLimit = bn(0);
|
42363
42627
|
}
|
42364
|
-
|
42628
|
+
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
42629
|
+
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
42630
|
+
}
|
42631
|
+
await this.estimatePredicates(txRequestClone);
|
42365
42632
|
}
|
42366
|
-
const minGas =
|
42367
|
-
const maxGas =
|
42368
|
-
const coinOutputsQuantities = transactionRequest.getCoinOutputsQuantities();
|
42369
|
-
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
42370
|
-
transactionRequest.fundWithFakeUtxos(allQuantities);
|
42371
|
-
let gasUsed = minGas;
|
42633
|
+
const minGas = txRequestClone.calculateMinGas(chainInfo);
|
42634
|
+
const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
|
42372
42635
|
let receipts = [];
|
42373
|
-
if (isScriptTransaction) {
|
42374
|
-
|
42375
|
-
|
42376
|
-
const result = await this.
|
42377
|
-
estimateTxDependencies
|
42378
|
-
});
|
42636
|
+
if (isScriptTransaction && estimateTxDependencies) {
|
42637
|
+
txRequestClone.gasPrice = bn(0);
|
42638
|
+
txRequestClone.gasLimit = bn(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
|
42639
|
+
const result = await this.estimateTxDependencies(txRequestClone);
|
42379
42640
|
receipts = result.receipts;
|
42380
|
-
gasUsed = getGasUsedFromReceipts(receipts);
|
42381
|
-
} else {
|
42382
|
-
gasUsed = minGas;
|
42383
42641
|
}
|
42642
|
+
const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
|
42384
42643
|
const usedFee = calculatePriceWithFactor(
|
42385
42644
|
gasUsed,
|
42386
42645
|
gasPrice,
|
@@ -42398,7 +42657,9 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42398
42657
|
maxGas,
|
42399
42658
|
usedFee,
|
42400
42659
|
minFee,
|
42401
|
-
maxFee
|
42660
|
+
maxFee,
|
42661
|
+
estimatedInputs: txRequestClone.inputs,
|
42662
|
+
estimatedOutputs: txRequestClone.outputs
|
42402
42663
|
};
|
42403
42664
|
}
|
42404
42665
|
async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
|
@@ -42566,7 +42827,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42566
42827
|
time: block2.header.time,
|
42567
42828
|
transactionIds: block2.transactions.map((tx) => tx.id),
|
42568
42829
|
transactions: block2.transactions.map(
|
42569
|
-
(tx) => new TransactionCoder().decode(
|
42830
|
+
(tx) => new TransactionCoder().decode(arrayify(tx.rawPayload), 0)?.[0]
|
42570
42831
|
)
|
42571
42832
|
};
|
42572
42833
|
}
|
@@ -42582,7 +42843,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42582
42843
|
return null;
|
42583
42844
|
}
|
42584
42845
|
return new TransactionCoder().decode(
|
42585
|
-
|
42846
|
+
arrayify(transaction.rawPayload),
|
42586
42847
|
0
|
42587
42848
|
)?.[0];
|
42588
42849
|
}
|
@@ -42788,6 +43049,10 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42788
43049
|
});
|
42789
43050
|
return bn(latestBlockHeight);
|
42790
43051
|
}
|
43052
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
43053
|
+
async getTransactionResponse(transactionId) {
|
43054
|
+
return new TransactionResponse2(transactionId, this);
|
43055
|
+
}
|
42791
43056
|
};
|
42792
43057
|
var Provider = _Provider;
|
42793
43058
|
_cacheInputs = new WeakSet();
|
@@ -42817,7 +43082,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42817
43082
|
);
|
42818
43083
|
}
|
42819
43084
|
const [decodedTransaction] = new TransactionCoder().decode(
|
42820
|
-
|
43085
|
+
arrayify(gqlTransaction.rawPayload),
|
42821
43086
|
0
|
42822
43087
|
);
|
42823
43088
|
const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
|
@@ -42828,7 +43093,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42828
43093
|
id: gqlTransaction.id,
|
42829
43094
|
receipts,
|
42830
43095
|
transaction: decodedTransaction,
|
42831
|
-
transactionBytes:
|
43096
|
+
transactionBytes: arrayify(gqlTransaction.rawPayload),
|
42832
43097
|
gqlTransactionStatus: gqlTransaction.status,
|
42833
43098
|
gasPerByte: bn(gasPerByte),
|
42834
43099
|
gasPriceFactor: bn(gasPriceFactor),
|
@@ -42870,13 +43135,13 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42870
43135
|
const transactions = edges.map((edge) => {
|
42871
43136
|
const { node: gqlTransaction } = edge;
|
42872
43137
|
const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
|
42873
|
-
const [decodedTransaction] = new TransactionCoder().decode(
|
43138
|
+
const [decodedTransaction] = new TransactionCoder().decode(arrayify(rawPayload), 0);
|
42874
43139
|
const receipts = gqlReceipts?.map(processGqlReceipt) || [];
|
42875
43140
|
const transactionSummary = assembleTransactionSummary({
|
42876
43141
|
id,
|
42877
43142
|
receipts,
|
42878
43143
|
transaction: decodedTransaction,
|
42879
|
-
transactionBytes:
|
43144
|
+
transactionBytes: arrayify(rawPayload),
|
42880
43145
|
gqlTransactionStatus: status,
|
42881
43146
|
abiMap,
|
42882
43147
|
gasPerByte,
|
@@ -42896,6 +43161,127 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42896
43161
|
};
|
42897
43162
|
}
|
42898
43163
|
|
43164
|
+
// src/providers/chains.ts
|
43165
|
+
var CHAIN_IDS = {
|
43166
|
+
eth: {
|
43167
|
+
sepolia: 11155111,
|
43168
|
+
foundry: 31337
|
43169
|
+
},
|
43170
|
+
fuel: {
|
43171
|
+
beta5: 0,
|
43172
|
+
devnet: 10
|
43173
|
+
}
|
43174
|
+
};
|
43175
|
+
|
43176
|
+
// src/providers/assets/utils/network.ts
|
43177
|
+
var getDefaultChainId = (networkType) => {
|
43178
|
+
if (networkType === "ethereum") {
|
43179
|
+
return CHAIN_IDS.eth.sepolia;
|
43180
|
+
}
|
43181
|
+
if (networkType === "fuel") {
|
43182
|
+
return CHAIN_IDS.fuel.beta5;
|
43183
|
+
}
|
43184
|
+
return void 0;
|
43185
|
+
};
|
43186
|
+
var getAssetNetwork = ({
|
43187
|
+
asset,
|
43188
|
+
chainId,
|
43189
|
+
networkType
|
43190
|
+
}) => {
|
43191
|
+
const network = asset.networks.find(
|
43192
|
+
(item) => item.chainId === chainId && item.type === networkType
|
43193
|
+
);
|
43194
|
+
return network;
|
43195
|
+
};
|
43196
|
+
var getAssetWithNetwork = ({
|
43197
|
+
asset,
|
43198
|
+
chainId,
|
43199
|
+
networkType
|
43200
|
+
}) => {
|
43201
|
+
const { networks: _, ...assetRest } = asset;
|
43202
|
+
const chainIdToUse = chainId ?? getDefaultChainId(networkType);
|
43203
|
+
if (chainIdToUse === void 0) {
|
43204
|
+
return void 0;
|
43205
|
+
}
|
43206
|
+
const assetNetwork = getAssetNetwork({
|
43207
|
+
asset,
|
43208
|
+
chainId: chainIdToUse,
|
43209
|
+
networkType
|
43210
|
+
});
|
43211
|
+
if (!assetNetwork) {
|
43212
|
+
return void 0;
|
43213
|
+
}
|
43214
|
+
return {
|
43215
|
+
...assetRest,
|
43216
|
+
...assetNetwork
|
43217
|
+
};
|
43218
|
+
};
|
43219
|
+
var getAssetEth = (asset, chainId) => getAssetWithNetwork({
|
43220
|
+
asset,
|
43221
|
+
networkType: "ethereum",
|
43222
|
+
chainId
|
43223
|
+
});
|
43224
|
+
var getAssetFuel = (asset, chainId) => getAssetWithNetwork({
|
43225
|
+
asset,
|
43226
|
+
networkType: "fuel",
|
43227
|
+
chainId
|
43228
|
+
});
|
43229
|
+
|
43230
|
+
// src/providers/assets/utils/url.ts
|
43231
|
+
var DELIMITER_PATH = "/";
|
43232
|
+
var trimRegex = /^\/|\/$/g;
|
43233
|
+
var trimPath = (path = "") => path.replace(trimRegex, "");
|
43234
|
+
function urlJoin(baseUrl, ...paths) {
|
43235
|
+
const hasBaseUrl = baseUrl !== null && baseUrl !== void 0;
|
43236
|
+
const rootPath = baseUrl?.[0] === "/" && baseUrl.length > 1;
|
43237
|
+
const allPaths = [baseUrl, ...paths].filter(Boolean).map(trimPath);
|
43238
|
+
if (rootPath && hasBaseUrl) {
|
43239
|
+
allPaths.unshift("");
|
43240
|
+
}
|
43241
|
+
return allPaths.join(DELIMITER_PATH);
|
43242
|
+
}
|
43243
|
+
|
43244
|
+
// src/providers/assets/utils/resolveIconPaths.ts
|
43245
|
+
function resolveIconPaths(assets2, basePath = "./") {
|
43246
|
+
return assets2.map((asset) => ({
|
43247
|
+
...asset,
|
43248
|
+
icon: urlJoin(basePath, asset.icon)
|
43249
|
+
}));
|
43250
|
+
}
|
43251
|
+
|
43252
|
+
// src/providers/assets/index.ts
|
43253
|
+
var assets = [
|
43254
|
+
{
|
43255
|
+
name: "Ethereum",
|
43256
|
+
symbol: "ETH",
|
43257
|
+
icon: "eth.svg",
|
43258
|
+
networks: [
|
43259
|
+
{
|
43260
|
+
type: "ethereum",
|
43261
|
+
chainId: CHAIN_IDS.eth.sepolia,
|
43262
|
+
decimals: 18
|
43263
|
+
},
|
43264
|
+
{
|
43265
|
+
type: "ethereum",
|
43266
|
+
chainId: CHAIN_IDS.eth.foundry,
|
43267
|
+
decimals: 18
|
43268
|
+
},
|
43269
|
+
{
|
43270
|
+
type: "fuel",
|
43271
|
+
chainId: CHAIN_IDS.fuel.beta5,
|
43272
|
+
decimals: 9,
|
43273
|
+
assetId: "0x0000000000000000000000000000000000000000000000000000000000000000"
|
43274
|
+
},
|
43275
|
+
{
|
43276
|
+
type: "fuel",
|
43277
|
+
chainId: CHAIN_IDS.fuel.devnet,
|
43278
|
+
decimals: 9,
|
43279
|
+
assetId: "0x0000000000000000000000000000000000000000000000000000000000000000"
|
43280
|
+
}
|
43281
|
+
]
|
43282
|
+
}
|
43283
|
+
];
|
43284
|
+
|
42899
43285
|
// src/utils/formatTransferToContractScriptData.ts
|
42900
43286
|
var asm = __toESM(require_node());
|
42901
43287
|
var formatTransferToContractScriptData = (params) => {
|
@@ -42903,9 +43289,9 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42903
43289
|
const numberCoder = new U64Coder();
|
42904
43290
|
const encoded = numberCoder.encode(new BN(amountToTransfer).toNumber());
|
42905
43291
|
const scriptData = Uint8Array.from([
|
42906
|
-
...
|
43292
|
+
...arrayify(hexlifiedContractId),
|
42907
43293
|
...encoded,
|
42908
|
-
...
|
43294
|
+
...arrayify(assetId)
|
42909
43295
|
]);
|
42910
43296
|
return scriptData;
|
42911
43297
|
};
|
@@ -42939,15 +43325,17 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42939
43325
|
* The provider used to interact with the network.
|
42940
43326
|
*/
|
42941
43327
|
_provider;
|
43328
|
+
_connector;
|
42942
43329
|
/**
|
42943
43330
|
* Creates a new Account instance.
|
42944
43331
|
*
|
42945
43332
|
* @param address - The address of the account.
|
42946
43333
|
* @param provider - A Provider instance (optional).
|
42947
43334
|
*/
|
42948
|
-
constructor(address, provider) {
|
43335
|
+
constructor(address, provider, connector) {
|
42949
43336
|
super();
|
42950
43337
|
this._provider = provider;
|
43338
|
+
this._connector = connector;
|
42951
43339
|
this.address = Address.fromDynamicInput(address);
|
42952
43340
|
}
|
42953
43341
|
/**
|
@@ -43153,7 +43541,10 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43153
43541
|
const params = { gasPrice: minGasPrice, ...txParams };
|
43154
43542
|
const request = new ScriptTransactionRequest(params);
|
43155
43543
|
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
|
43156
|
-
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(request
|
43544
|
+
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
43545
|
+
estimateTxDependencies: true,
|
43546
|
+
resourcesOwner: this
|
43547
|
+
});
|
43157
43548
|
request.gasPrice = bn(txParams.gasPrice ?? minGasPrice);
|
43158
43549
|
request.gasLimit = bn(txParams.gasLimit ?? gasUsed);
|
43159
43550
|
this.validateGas({
|
@@ -43163,6 +43554,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43163
43554
|
minGasPrice
|
43164
43555
|
});
|
43165
43556
|
await this.fund(request, requiredQuantities, maxFee);
|
43557
|
+
request.updatePredicateInputs(estimatedInputs);
|
43166
43558
|
return request;
|
43167
43559
|
}
|
43168
43560
|
/**
|
@@ -43176,7 +43568,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43176
43568
|
*/
|
43177
43569
|
async transfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
43178
43570
|
const request = await this.createTransfer(destination, amount, assetId, txParams);
|
43179
|
-
return this.sendTransaction(request);
|
43571
|
+
return this.sendTransaction(request, { estimateTxDependencies: false });
|
43180
43572
|
}
|
43181
43573
|
/**
|
43182
43574
|
* Transfers coins to a contract address.
|
@@ -43227,14 +43619,14 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43227
43619
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
43228
43620
|
const { minGasPrice } = this.provider.getGasConfig();
|
43229
43621
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
43230
|
-
const recipientDataArray =
|
43622
|
+
const recipientDataArray = arrayify(
|
43231
43623
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
43232
43624
|
);
|
43233
|
-
const amountDataArray =
|
43625
|
+
const amountDataArray = arrayify(
|
43234
43626
|
"0x".concat(bn(amount).toHex().substring(2).padStart(16, "0"))
|
43235
43627
|
);
|
43236
43628
|
const script = new Uint8Array([
|
43237
|
-
...
|
43629
|
+
...arrayify(withdrawScript.bytes),
|
43238
43630
|
...recipientDataArray,
|
43239
43631
|
...amountDataArray
|
43240
43632
|
]);
|
@@ -43255,17 +43647,30 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43255
43647
|
await this.fund(request, requiredQuantities, maxFee);
|
43256
43648
|
return this.sendTransaction(request);
|
43257
43649
|
}
|
43650
|
+
async signMessage(message) {
|
43651
|
+
if (!this._connector) {
|
43652
|
+
throw new FuelError(ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
|
43653
|
+
}
|
43654
|
+
return this._connector.signMessage(this.address.toString(), message);
|
43655
|
+
}
|
43258
43656
|
/**
|
43259
43657
|
* Sends a transaction to the network.
|
43260
43658
|
*
|
43261
43659
|
* @param transactionRequestLike - The transaction request to be sent.
|
43262
43660
|
* @returns A promise that resolves to the transaction response.
|
43263
43661
|
*/
|
43264
|
-
async sendTransaction(transactionRequestLike,
|
43662
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
|
43663
|
+
if (this._connector) {
|
43664
|
+
return this.provider.getTransactionResponse(
|
43665
|
+
await this._connector.sendTransaction(this.address.toString(), transactionRequestLike)
|
43666
|
+
);
|
43667
|
+
}
|
43265
43668
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
43266
|
-
|
43669
|
+
if (estimateTxDependencies) {
|
43670
|
+
await this.provider.estimateTxDependencies(transactionRequest);
|
43671
|
+
}
|
43267
43672
|
return this.provider.sendTransaction(transactionRequest, {
|
43268
|
-
|
43673
|
+
awaitExecution,
|
43269
43674
|
estimateTxDependencies: false
|
43270
43675
|
});
|
43271
43676
|
}
|
@@ -43275,9 +43680,11 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43275
43680
|
* @param transactionRequestLike - The transaction request to be simulated.
|
43276
43681
|
* @returns A promise that resolves to the call result.
|
43277
43682
|
*/
|
43278
|
-
async simulateTransaction(transactionRequestLike) {
|
43683
|
+
async simulateTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
|
43279
43684
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
43280
|
-
|
43685
|
+
if (estimateTxDependencies) {
|
43686
|
+
await this.provider.estimateTxDependencies(transactionRequest);
|
43687
|
+
}
|
43281
43688
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
43282
43689
|
}
|
43283
43690
|
validateGas({
|
@@ -43306,11 +43713,11 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43306
43713
|
if (!Number.isSafeInteger(n) || n < 0)
|
43307
43714
|
throw new Error(`Wrong positive integer: ${n}`);
|
43308
43715
|
}
|
43309
|
-
function
|
43716
|
+
function isBytes2(a) {
|
43310
43717
|
return a instanceof Uint8Array || a != null && typeof a === "object" && a.constructor.name === "Uint8Array";
|
43311
43718
|
}
|
43312
43719
|
function bytes3(b, ...lengths) {
|
43313
|
-
if (!
|
43720
|
+
if (!isBytes2(b))
|
43314
43721
|
throw new Error("Expected Uint8Array");
|
43315
43722
|
if (lengths.length > 0 && !lengths.includes(b.length))
|
43316
43723
|
throw new Error(`Expected Uint8Array of length ${lengths}, not of length=${b.length}`);
|
@@ -43340,7 +43747,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43340
43747
|
var crypto5 = nc2 && typeof nc2 === "object" && "webcrypto" in nc2 ? nc2.webcrypto : void 0;
|
43341
43748
|
|
43342
43749
|
// ../../node_modules/.pnpm/@noble+hashes@1.3.3/node_modules/@noble/hashes/esm/utils.js
|
43343
|
-
function
|
43750
|
+
function isBytes3(a) {
|
43344
43751
|
return a instanceof Uint8Array || a != null && typeof a === "object" && a.constructor.name === "Uint8Array";
|
43345
43752
|
}
|
43346
43753
|
var createView3 = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
@@ -43348,23 +43755,23 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43348
43755
|
var isLE3 = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
43349
43756
|
if (!isLE3)
|
43350
43757
|
throw new Error("Non little-endian hardware is not supported");
|
43351
|
-
function
|
43758
|
+
function utf8ToBytes4(str) {
|
43352
43759
|
if (typeof str !== "string")
|
43353
43760
|
throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
|
43354
43761
|
return new Uint8Array(new TextEncoder().encode(str));
|
43355
43762
|
}
|
43356
43763
|
function toBytes4(data) {
|
43357
43764
|
if (typeof data === "string")
|
43358
|
-
data =
|
43359
|
-
if (!
|
43765
|
+
data = utf8ToBytes4(data);
|
43766
|
+
if (!isBytes3(data))
|
43360
43767
|
throw new Error(`expected Uint8Array, got ${typeof data}`);
|
43361
43768
|
return data;
|
43362
43769
|
}
|
43363
|
-
function
|
43770
|
+
function concatBytes4(...arrays) {
|
43364
43771
|
let sum = 0;
|
43365
43772
|
for (let i = 0; i < arrays.length; i++) {
|
43366
43773
|
const a = arrays[i];
|
43367
|
-
if (!
|
43774
|
+
if (!isBytes3(a))
|
43368
43775
|
throw new Error("Uint8Array expected");
|
43369
43776
|
sum += a.length;
|
43370
43777
|
}
|
@@ -43579,312 +43986,76 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43579
43986
|
]);
|
43580
43987
|
var SHA256_W2 = /* @__PURE__ */ new Uint32Array(64);
|
43581
43988
|
var SHA2562 = class extends SHA23 {
|
43582
|
-
constructor() {
|
43583
|
-
super(64, 32, 8, false);
|
43584
|
-
this.A = IV2[0] | 0;
|
43585
|
-
this.B = IV2[1] | 0;
|
43586
|
-
this.C = IV2[2] | 0;
|
43587
|
-
this.D = IV2[3] | 0;
|
43588
|
-
this.E = IV2[4] | 0;
|
43589
|
-
this.F = IV2[5] | 0;
|
43590
|
-
this.G = IV2[6] | 0;
|
43591
|
-
this.H = IV2[7] | 0;
|
43592
|
-
}
|
43593
|
-
get() {
|
43594
|
-
const { A, B, C, D, E, F, G, H } = this;
|
43595
|
-
return [A, B, C, D, E, F, G, H];
|
43596
|
-
}
|
43597
|
-
// prettier-ignore
|
43598
|
-
set(A, B, C, D, E, F, G, H) {
|
43599
|
-
this.A = A | 0;
|
43600
|
-
this.B = B | 0;
|
43601
|
-
this.C = C | 0;
|
43602
|
-
this.D = D | 0;
|
43603
|
-
this.E = E | 0;
|
43604
|
-
this.F = F | 0;
|
43605
|
-
this.G = G | 0;
|
43606
|
-
this.H = H | 0;
|
43607
|
-
}
|
43608
|
-
process(view, offset) {
|
43609
|
-
for (let i = 0; i < 16; i++, offset += 4)
|
43610
|
-
SHA256_W2[i] = view.getUint32(offset, false);
|
43611
|
-
for (let i = 16; i < 64; i++) {
|
43612
|
-
const W15 = SHA256_W2[i - 15];
|
43613
|
-
const W2 = SHA256_W2[i - 2];
|
43614
|
-
const s0 = rotr2(W15, 7) ^ rotr2(W15, 18) ^ W15 >>> 3;
|
43615
|
-
const s1 = rotr2(W2, 17) ^ rotr2(W2, 19) ^ W2 >>> 10;
|
43616
|
-
SHA256_W2[i] = s1 + SHA256_W2[i - 7] + s0 + SHA256_W2[i - 16] | 0;
|
43617
|
-
}
|
43618
|
-
let { A, B, C, D, E, F, G, H } = this;
|
43619
|
-
for (let i = 0; i < 64; i++) {
|
43620
|
-
const sigma1 = rotr2(E, 6) ^ rotr2(E, 11) ^ rotr2(E, 25);
|
43621
|
-
const T1 = H + sigma1 + Chi2(E, F, G) + SHA256_K2[i] + SHA256_W2[i] | 0;
|
43622
|
-
const sigma0 = rotr2(A, 2) ^ rotr2(A, 13) ^ rotr2(A, 22);
|
43623
|
-
const T2 = sigma0 + Maj2(A, B, C) | 0;
|
43624
|
-
H = G;
|
43625
|
-
G = F;
|
43626
|
-
F = E;
|
43627
|
-
E = D + T1 | 0;
|
43628
|
-
D = C;
|
43629
|
-
C = B;
|
43630
|
-
B = A;
|
43631
|
-
A = T1 + T2 | 0;
|
43632
|
-
}
|
43633
|
-
A = A + this.A | 0;
|
43634
|
-
B = B + this.B | 0;
|
43635
|
-
C = C + this.C | 0;
|
43636
|
-
D = D + this.D | 0;
|
43637
|
-
E = E + this.E | 0;
|
43638
|
-
F = F + this.F | 0;
|
43639
|
-
G = G + this.G | 0;
|
43640
|
-
H = H + this.H | 0;
|
43641
|
-
this.set(A, B, C, D, E, F, G, H);
|
43642
|
-
}
|
43643
|
-
roundClean() {
|
43644
|
-
SHA256_W2.fill(0);
|
43645
|
-
}
|
43646
|
-
destroy() {
|
43647
|
-
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
43648
|
-
this.buffer.fill(0);
|
43649
|
-
}
|
43650
|
-
};
|
43651
|
-
var sha2563 = /* @__PURE__ */ wrapConstructor3(() => new SHA2562());
|
43652
|
-
|
43653
|
-
// ../../node_modules/.pnpm/@noble+curves@1.3.0/node_modules/@noble/curves/esm/abstract/utils.js
|
43654
|
-
var utils_exports = {};
|
43655
|
-
__export(utils_exports, {
|
43656
|
-
bitGet: () => bitGet,
|
43657
|
-
bitLen: () => bitLen,
|
43658
|
-
bitMask: () => bitMask,
|
43659
|
-
bitSet: () => bitSet,
|
43660
|
-
bytesToHex: () => bytesToHex2,
|
43661
|
-
bytesToNumberBE: () => bytesToNumberBE,
|
43662
|
-
bytesToNumberLE: () => bytesToNumberLE,
|
43663
|
-
concatBytes: () => concatBytes4,
|
43664
|
-
createHmacDrbg: () => createHmacDrbg,
|
43665
|
-
ensureBytes: () => ensureBytes,
|
43666
|
-
equalBytes: () => equalBytes,
|
43667
|
-
hexToBytes: () => hexToBytes2,
|
43668
|
-
hexToNumber: () => hexToNumber,
|
43669
|
-
isBytes: () => isBytes3,
|
43670
|
-
numberToBytesBE: () => numberToBytesBE,
|
43671
|
-
numberToBytesLE: () => numberToBytesLE,
|
43672
|
-
numberToHexUnpadded: () => numberToHexUnpadded,
|
43673
|
-
numberToVarBytesBE: () => numberToVarBytesBE,
|
43674
|
-
utf8ToBytes: () => utf8ToBytes4,
|
43675
|
-
validateObject: () => validateObject
|
43676
|
-
});
|
43677
|
-
var _0n3 = BigInt(0);
|
43678
|
-
var _1n3 = BigInt(1);
|
43679
|
-
var _2n3 = BigInt(2);
|
43680
|
-
function isBytes3(a) {
|
43681
|
-
return a instanceof Uint8Array || a != null && typeof a === "object" && a.constructor.name === "Uint8Array";
|
43682
|
-
}
|
43683
|
-
var hexes3 = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
|
43684
|
-
function bytesToHex2(bytes4) {
|
43685
|
-
if (!isBytes3(bytes4))
|
43686
|
-
throw new Error("Uint8Array expected");
|
43687
|
-
let hex = "";
|
43688
|
-
for (let i = 0; i < bytes4.length; i++) {
|
43689
|
-
hex += hexes3[bytes4[i]];
|
43690
|
-
}
|
43691
|
-
return hex;
|
43692
|
-
}
|
43693
|
-
function numberToHexUnpadded(num) {
|
43694
|
-
const hex = num.toString(16);
|
43695
|
-
return hex.length & 1 ? `0${hex}` : hex;
|
43696
|
-
}
|
43697
|
-
function hexToNumber(hex) {
|
43698
|
-
if (typeof hex !== "string")
|
43699
|
-
throw new Error("hex string expected, got " + typeof hex);
|
43700
|
-
return BigInt(hex === "" ? "0" : `0x${hex}`);
|
43701
|
-
}
|
43702
|
-
var asciis = { _0: 48, _9: 57, _A: 65, _F: 70, _a: 97, _f: 102 };
|
43703
|
-
function asciiToBase16(char) {
|
43704
|
-
if (char >= asciis._0 && char <= asciis._9)
|
43705
|
-
return char - asciis._0;
|
43706
|
-
if (char >= asciis._A && char <= asciis._F)
|
43707
|
-
return char - (asciis._A - 10);
|
43708
|
-
if (char >= asciis._a && char <= asciis._f)
|
43709
|
-
return char - (asciis._a - 10);
|
43710
|
-
return;
|
43711
|
-
}
|
43712
|
-
function hexToBytes2(hex) {
|
43713
|
-
if (typeof hex !== "string")
|
43714
|
-
throw new Error("hex string expected, got " + typeof hex);
|
43715
|
-
const hl = hex.length;
|
43716
|
-
const al = hl / 2;
|
43717
|
-
if (hl % 2)
|
43718
|
-
throw new Error("padded hex string expected, got unpadded hex of length " + hl);
|
43719
|
-
const array = new Uint8Array(al);
|
43720
|
-
for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
|
43721
|
-
const n1 = asciiToBase16(hex.charCodeAt(hi));
|
43722
|
-
const n2 = asciiToBase16(hex.charCodeAt(hi + 1));
|
43723
|
-
if (n1 === void 0 || n2 === void 0) {
|
43724
|
-
const char = hex[hi] + hex[hi + 1];
|
43725
|
-
throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
|
43726
|
-
}
|
43727
|
-
array[ai] = n1 * 16 + n2;
|
43989
|
+
constructor() {
|
43990
|
+
super(64, 32, 8, false);
|
43991
|
+
this.A = IV2[0] | 0;
|
43992
|
+
this.B = IV2[1] | 0;
|
43993
|
+
this.C = IV2[2] | 0;
|
43994
|
+
this.D = IV2[3] | 0;
|
43995
|
+
this.E = IV2[4] | 0;
|
43996
|
+
this.F = IV2[5] | 0;
|
43997
|
+
this.G = IV2[6] | 0;
|
43998
|
+
this.H = IV2[7] | 0;
|
43728
43999
|
}
|
43729
|
-
|
43730
|
-
|
43731
|
-
|
43732
|
-
|
43733
|
-
|
43734
|
-
|
43735
|
-
|
43736
|
-
|
43737
|
-
|
43738
|
-
|
43739
|
-
|
43740
|
-
|
43741
|
-
|
43742
|
-
|
43743
|
-
|
43744
|
-
|
43745
|
-
|
43746
|
-
|
43747
|
-
|
43748
|
-
|
43749
|
-
|
43750
|
-
|
43751
|
-
|
43752
|
-
|
43753
|
-
} catch (e) {
|
43754
|
-
throw new Error(`${title} must be valid hex string, got "${hex}". Cause: ${e}`);
|
44000
|
+
get() {
|
44001
|
+
const { A, B, C, D, E, F, G, H } = this;
|
44002
|
+
return [A, B, C, D, E, F, G, H];
|
44003
|
+
}
|
44004
|
+
// prettier-ignore
|
44005
|
+
set(A, B, C, D, E, F, G, H) {
|
44006
|
+
this.A = A | 0;
|
44007
|
+
this.B = B | 0;
|
44008
|
+
this.C = C | 0;
|
44009
|
+
this.D = D | 0;
|
44010
|
+
this.E = E | 0;
|
44011
|
+
this.F = F | 0;
|
44012
|
+
this.G = G | 0;
|
44013
|
+
this.H = H | 0;
|
44014
|
+
}
|
44015
|
+
process(view, offset) {
|
44016
|
+
for (let i = 0; i < 16; i++, offset += 4)
|
44017
|
+
SHA256_W2[i] = view.getUint32(offset, false);
|
44018
|
+
for (let i = 16; i < 64; i++) {
|
44019
|
+
const W15 = SHA256_W2[i - 15];
|
44020
|
+
const W2 = SHA256_W2[i - 2];
|
44021
|
+
const s0 = rotr2(W15, 7) ^ rotr2(W15, 18) ^ W15 >>> 3;
|
44022
|
+
const s1 = rotr2(W2, 17) ^ rotr2(W2, 19) ^ W2 >>> 10;
|
44023
|
+
SHA256_W2[i] = s1 + SHA256_W2[i - 7] + s0 + SHA256_W2[i - 16] | 0;
|
43755
44024
|
}
|
43756
|
-
|
43757
|
-
|
43758
|
-
|
43759
|
-
|
44025
|
+
let { A, B, C, D, E, F, G, H } = this;
|
44026
|
+
for (let i = 0; i < 64; i++) {
|
44027
|
+
const sigma1 = rotr2(E, 6) ^ rotr2(E, 11) ^ rotr2(E, 25);
|
44028
|
+
const T1 = H + sigma1 + Chi2(E, F, G) + SHA256_K2[i] + SHA256_W2[i] | 0;
|
44029
|
+
const sigma0 = rotr2(A, 2) ^ rotr2(A, 13) ^ rotr2(A, 22);
|
44030
|
+
const T2 = sigma0 + Maj2(A, B, C) | 0;
|
44031
|
+
H = G;
|
44032
|
+
G = F;
|
44033
|
+
F = E;
|
44034
|
+
E = D + T1 | 0;
|
44035
|
+
D = C;
|
44036
|
+
C = B;
|
44037
|
+
B = A;
|
44038
|
+
A = T1 + T2 | 0;
|
44039
|
+
}
|
44040
|
+
A = A + this.A | 0;
|
44041
|
+
B = B + this.B | 0;
|
44042
|
+
C = C + this.C | 0;
|
44043
|
+
D = D + this.D | 0;
|
44044
|
+
E = E + this.E | 0;
|
44045
|
+
F = F + this.F | 0;
|
44046
|
+
G = G + this.G | 0;
|
44047
|
+
H = H + this.H | 0;
|
44048
|
+
this.set(A, B, C, D, E, F, G, H);
|
43760
44049
|
}
|
43761
|
-
|
43762
|
-
|
43763
|
-
throw new Error(`${title} expected ${expectedLength} bytes, got ${len}`);
|
43764
|
-
return res;
|
43765
|
-
}
|
43766
|
-
function concatBytes4(...arrays) {
|
43767
|
-
let sum = 0;
|
43768
|
-
for (let i = 0; i < arrays.length; i++) {
|
43769
|
-
const a = arrays[i];
|
43770
|
-
if (!isBytes3(a))
|
43771
|
-
throw new Error("Uint8Array expected");
|
43772
|
-
sum += a.length;
|
44050
|
+
roundClean() {
|
44051
|
+
SHA256_W2.fill(0);
|
43773
44052
|
}
|
43774
|
-
|
43775
|
-
|
43776
|
-
|
43777
|
-
const a = arrays[i];
|
43778
|
-
res.set(a, pad3);
|
43779
|
-
pad3 += a.length;
|
44053
|
+
destroy() {
|
44054
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
44055
|
+
this.buffer.fill(0);
|
43780
44056
|
}
|
43781
|
-
return res;
|
43782
|
-
}
|
43783
|
-
function equalBytes(a, b) {
|
43784
|
-
if (a.length !== b.length)
|
43785
|
-
return false;
|
43786
|
-
let diff = 0;
|
43787
|
-
for (let i = 0; i < a.length; i++)
|
43788
|
-
diff |= a[i] ^ b[i];
|
43789
|
-
return diff === 0;
|
43790
|
-
}
|
43791
|
-
function utf8ToBytes4(str) {
|
43792
|
-
if (typeof str !== "string")
|
43793
|
-
throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
|
43794
|
-
return new Uint8Array(new TextEncoder().encode(str));
|
43795
|
-
}
|
43796
|
-
function bitLen(n) {
|
43797
|
-
let len;
|
43798
|
-
for (len = 0; n > _0n3; n >>= _1n3, len += 1)
|
43799
|
-
;
|
43800
|
-
return len;
|
43801
|
-
}
|
43802
|
-
function bitGet(n, pos) {
|
43803
|
-
return n >> BigInt(pos) & _1n3;
|
43804
|
-
}
|
43805
|
-
var bitSet = (n, pos, value) => {
|
43806
|
-
return n | (value ? _1n3 : _0n3) << BigInt(pos);
|
43807
|
-
};
|
43808
|
-
var bitMask = (n) => (_2n3 << BigInt(n - 1)) - _1n3;
|
43809
|
-
var u8n = (data) => new Uint8Array(data);
|
43810
|
-
var u8fr = (arr) => Uint8Array.from(arr);
|
43811
|
-
function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
43812
|
-
if (typeof hashLen !== "number" || hashLen < 2)
|
43813
|
-
throw new Error("hashLen must be a number");
|
43814
|
-
if (typeof qByteLen !== "number" || qByteLen < 2)
|
43815
|
-
throw new Error("qByteLen must be a number");
|
43816
|
-
if (typeof hmacFn !== "function")
|
43817
|
-
throw new Error("hmacFn must be a function");
|
43818
|
-
let v = u8n(hashLen);
|
43819
|
-
let k = u8n(hashLen);
|
43820
|
-
let i = 0;
|
43821
|
-
const reset = () => {
|
43822
|
-
v.fill(1);
|
43823
|
-
k.fill(0);
|
43824
|
-
i = 0;
|
43825
|
-
};
|
43826
|
-
const h = (...b) => hmacFn(k, v, ...b);
|
43827
|
-
const reseed = (seed = u8n()) => {
|
43828
|
-
k = h(u8fr([0]), seed);
|
43829
|
-
v = h();
|
43830
|
-
if (seed.length === 0)
|
43831
|
-
return;
|
43832
|
-
k = h(u8fr([1]), seed);
|
43833
|
-
v = h();
|
43834
|
-
};
|
43835
|
-
const gen3 = () => {
|
43836
|
-
if (i++ >= 1e3)
|
43837
|
-
throw new Error("drbg: tried 1000 values");
|
43838
|
-
let len = 0;
|
43839
|
-
const out = [];
|
43840
|
-
while (len < qByteLen) {
|
43841
|
-
v = h();
|
43842
|
-
const sl = v.slice();
|
43843
|
-
out.push(sl);
|
43844
|
-
len += v.length;
|
43845
|
-
}
|
43846
|
-
return concatBytes4(...out);
|
43847
|
-
};
|
43848
|
-
const genUntil = (seed, pred) => {
|
43849
|
-
reset();
|
43850
|
-
reseed(seed);
|
43851
|
-
let res = void 0;
|
43852
|
-
while (!(res = pred(gen3())))
|
43853
|
-
reseed();
|
43854
|
-
reset();
|
43855
|
-
return res;
|
43856
|
-
};
|
43857
|
-
return genUntil;
|
43858
|
-
}
|
43859
|
-
var validatorFns = {
|
43860
|
-
bigint: (val) => typeof val === "bigint",
|
43861
|
-
function: (val) => typeof val === "function",
|
43862
|
-
boolean: (val) => typeof val === "boolean",
|
43863
|
-
string: (val) => typeof val === "string",
|
43864
|
-
stringOrUint8Array: (val) => typeof val === "string" || isBytes3(val),
|
43865
|
-
isSafeInteger: (val) => Number.isSafeInteger(val),
|
43866
|
-
array: (val) => Array.isArray(val),
|
43867
|
-
field: (val, object) => object.Fp.isValid(val),
|
43868
|
-
hash: (val) => typeof val === "function" && Number.isSafeInteger(val.outputLen)
|
43869
44057
|
};
|
43870
|
-
|
43871
|
-
const checkField = (fieldName, type3, isOptional) => {
|
43872
|
-
const checkVal = validatorFns[type3];
|
43873
|
-
if (typeof checkVal !== "function")
|
43874
|
-
throw new Error(`Invalid validator "${type3}", expected function`);
|
43875
|
-
const val = object[fieldName];
|
43876
|
-
if (isOptional && val === void 0)
|
43877
|
-
return;
|
43878
|
-
if (!checkVal(val, object)) {
|
43879
|
-
throw new Error(`Invalid param ${String(fieldName)}=${val} (${typeof val}), expected ${type3}`);
|
43880
|
-
}
|
43881
|
-
};
|
43882
|
-
for (const [fieldName, type3] of Object.entries(validators))
|
43883
|
-
checkField(fieldName, type3, false);
|
43884
|
-
for (const [fieldName, type3] of Object.entries(optValidators))
|
43885
|
-
checkField(fieldName, type3, true);
|
43886
|
-
return object;
|
43887
|
-
}
|
44058
|
+
var sha2563 = /* @__PURE__ */ wrapConstructor3(() => new SHA2562());
|
43888
44059
|
|
43889
44060
|
// ../../node_modules/.pnpm/@noble+curves@1.3.0/node_modules/@noble/curves/esm/abstract/modular.js
|
43890
44061
|
var _0n4 = BigInt(0);
|
@@ -44321,7 +44492,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44321
44492
|
toSig(hex) {
|
44322
44493
|
const { Err: E } = DER;
|
44323
44494
|
const data = typeof hex === "string" ? h2b(hex) : hex;
|
44324
|
-
if (!
|
44495
|
+
if (!isBytes(data))
|
44325
44496
|
throw new Error("ui8a expected");
|
44326
44497
|
let l = data.length;
|
44327
44498
|
if (l < 2 || data[0] != 48)
|
@@ -44359,7 +44530,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44359
44530
|
const { Fp: Fp2 } = CURVE;
|
44360
44531
|
const toBytes5 = CURVE.toBytes || ((_c, point, _isCompressed) => {
|
44361
44532
|
const a = point.toAffine();
|
44362
|
-
return
|
44533
|
+
return concatBytes3(Uint8Array.from([4]), Fp2.toBytes(a.x), Fp2.toBytes(a.y));
|
44363
44534
|
});
|
44364
44535
|
const fromBytes = CURVE.fromBytes || ((bytes4) => {
|
44365
44536
|
const tail = bytes4.subarray(1);
|
@@ -44385,7 +44556,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44385
44556
|
function normPrivateKeyToScalar(key) {
|
44386
44557
|
const { allowedPrivateKeyLengths: lengths, nByteLength, wrapPrivateKey, n } = CURVE;
|
44387
44558
|
if (lengths && typeof key !== "bigint") {
|
44388
|
-
if (
|
44559
|
+
if (isBytes(key))
|
44389
44560
|
key = bytesToHex2(key);
|
44390
44561
|
if (typeof key !== "string" || !lengths.includes(key.length))
|
44391
44562
|
throw new Error("Invalid key");
|
@@ -44775,7 +44946,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44775
44946
|
toBytes(_c, point, isCompressed) {
|
44776
44947
|
const a = point.toAffine();
|
44777
44948
|
const x = Fp2.toBytes(a.x);
|
44778
|
-
const cat =
|
44949
|
+
const cat = concatBytes3;
|
44779
44950
|
if (isCompressed) {
|
44780
44951
|
return cat(Uint8Array.from([point.hasEvenY() ? 2 : 3]), x);
|
44781
44952
|
} else {
|
@@ -44920,7 +45091,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44920
45091
|
return Point2.fromPrivateKey(privateKey).toRawBytes(isCompressed);
|
44921
45092
|
}
|
44922
45093
|
function isProbPub(item) {
|
44923
|
-
const arr =
|
45094
|
+
const arr = isBytes(item);
|
44924
45095
|
const str = typeof item === "string";
|
44925
45096
|
const len = (arr || str) && item.length;
|
44926
45097
|
if (arr)
|
@@ -44972,7 +45143,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44972
45143
|
const e = ent === true ? randomBytes5(Fp2.BYTES) : ent;
|
44973
45144
|
seedArgs.push(ensureBytes("extraEntropy", e));
|
44974
45145
|
}
|
44975
|
-
const seed =
|
45146
|
+
const seed = concatBytes3(...seedArgs);
|
44976
45147
|
const m = h1int;
|
44977
45148
|
function k2sig(kBytes) {
|
44978
45149
|
const k = bits2int(kBytes);
|
@@ -45015,7 +45186,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45015
45186
|
let _sig = void 0;
|
45016
45187
|
let P;
|
45017
45188
|
try {
|
45018
|
-
if (typeof sg === "string" ||
|
45189
|
+
if (typeof sg === "string" || isBytes(sg)) {
|
45019
45190
|
try {
|
45020
45191
|
_sig = Signature2.fromDER(sg);
|
45021
45192
|
} catch (derError) {
|
@@ -45131,7 +45302,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45131
45302
|
function getHash(hash6) {
|
45132
45303
|
return {
|
45133
45304
|
hash: hash6,
|
45134
|
-
hmac: (key, ...msgs) => hmac2(hash6, key,
|
45305
|
+
hmac: (key, ...msgs) => hmac2(hash6, key, concatBytes4(...msgs)),
|
45135
45306
|
randomBytes: randomBytes4
|
45136
45307
|
};
|
45137
45308
|
}
|
@@ -45255,11 +45426,11 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45255
45426
|
* @returns hashed signature
|
45256
45427
|
*/
|
45257
45428
|
sign(data) {
|
45258
|
-
const signature = secp256k1.sign(
|
45429
|
+
const signature = secp256k1.sign(arrayify(data), arrayify(this.privateKey));
|
45259
45430
|
const r = toBytes3(`0x${signature.r.toString(16)}`, 32);
|
45260
45431
|
const s = toBytes3(`0x${signature.s.toString(16)}`, 32);
|
45261
45432
|
s[0] |= (signature.recovery || 0) << 7;
|
45262
|
-
return concat([r, s]);
|
45433
|
+
return hexlify(concat([r, s]));
|
45263
45434
|
}
|
45264
45435
|
/**
|
45265
45436
|
* Add point on the current elliptic curve
|
@@ -45268,8 +45439,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45268
45439
|
* @returns compressed point on the curve
|
45269
45440
|
*/
|
45270
45441
|
addPoint(point) {
|
45271
|
-
const p0 = secp256k1.ProjectivePoint.fromHex(
|
45272
|
-
const p1 = secp256k1.ProjectivePoint.fromHex(
|
45442
|
+
const p0 = secp256k1.ProjectivePoint.fromHex(arrayify(this.compressedPublicKey));
|
45443
|
+
const p1 = secp256k1.ProjectivePoint.fromHex(arrayify(point));
|
45273
45444
|
const result = p0.add(p1);
|
45274
45445
|
return `0x${result.toHex(true)}`;
|
45275
45446
|
}
|
@@ -45281,7 +45452,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45281
45452
|
* @returns public key from signature from the
|
45282
45453
|
*/
|
45283
45454
|
static recoverPublicKey(data, signature) {
|
45284
|
-
const signedMessageBytes =
|
45455
|
+
const signedMessageBytes = arrayify(signature);
|
45285
45456
|
const r = signedMessageBytes.slice(0, 32);
|
45286
45457
|
const s = signedMessageBytes.slice(32, 64);
|
45287
45458
|
const recoveryParam = (s[0] & 128) >> 7;
|
@@ -45289,7 +45460,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45289
45460
|
const sig = new secp256k1.Signature(BigInt(hexlify(r)), BigInt(hexlify(s))).addRecoveryBit(
|
45290
45461
|
recoveryParam
|
45291
45462
|
);
|
45292
|
-
const publicKey = sig.recoverPublicKey(
|
45463
|
+
const publicKey = sig.recoverPublicKey(arrayify(data)).toRawBytes(false).slice(1);
|
45293
45464
|
return hexlify(publicKey);
|
45294
45465
|
}
|
45295
45466
|
/**
|
@@ -45309,7 +45480,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45309
45480
|
* @returns random 32-byte hashed
|
45310
45481
|
*/
|
45311
45482
|
static generatePrivateKey(entropy) {
|
45312
|
-
return entropy ? hash3(concat([randomBytes22(32),
|
45483
|
+
return entropy ? hash3(concat([randomBytes22(32), arrayify(entropy)])) : randomBytes22(32);
|
45313
45484
|
}
|
45314
45485
|
/**
|
45315
45486
|
* Extended publicKey from a compact publicKey
|
@@ -45318,7 +45489,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45318
45489
|
* @returns extended publicKey
|
45319
45490
|
*/
|
45320
45491
|
static extendPublicKey(publicKey) {
|
45321
|
-
const point = secp256k1.ProjectivePoint.fromHex(
|
45492
|
+
const point = secp256k1.ProjectivePoint.fromHex(arrayify(publicKey));
|
45322
45493
|
return hexlify(point.toRawBytes(false).slice(1));
|
45323
45494
|
}
|
45324
45495
|
};
|
@@ -45497,7 +45668,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45497
45668
|
*/
|
45498
45669
|
async signMessage(message) {
|
45499
45670
|
const signedMessage = await this.signer().sign(hashMessage(message));
|
45500
|
-
return signedMessage;
|
45671
|
+
return hexlify(signedMessage);
|
45501
45672
|
}
|
45502
45673
|
/**
|
45503
45674
|
* Signs a transaction with the wallet's private key.
|
@@ -45510,7 +45681,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45510
45681
|
const chainId = this.provider.getChain().consensusParameters.chainId.toNumber();
|
45511
45682
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
45512
45683
|
const signature = await this.signer().sign(hashedTransaction);
|
45513
|
-
return signature;
|
45684
|
+
return hexlify(signature);
|
45514
45685
|
}
|
45515
45686
|
/**
|
45516
45687
|
* Populates a transaction with the witnesses signature.
|
@@ -45530,12 +45701,14 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45530
45701
|
* @param transactionRequestLike - The transaction request to send.
|
45531
45702
|
* @returns A promise that resolves to the TransactionResponse object.
|
45532
45703
|
*/
|
45533
|
-
async sendTransaction(transactionRequestLike,
|
45704
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
|
45534
45705
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
45535
|
-
|
45706
|
+
if (estimateTxDependencies) {
|
45707
|
+
await this.provider.estimateTxDependencies(transactionRequest);
|
45708
|
+
}
|
45536
45709
|
return this.provider.sendTransaction(
|
45537
45710
|
await this.populateTransactionWitnessesSignature(transactionRequest),
|
45538
|
-
{
|
45711
|
+
{ awaitExecution, estimateTxDependencies: false }
|
45539
45712
|
);
|
45540
45713
|
}
|
45541
45714
|
/**
|
@@ -45544,9 +45717,11 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45544
45717
|
* @param transactionRequestLike - The transaction request to simulate.
|
45545
45718
|
* @returns A promise that resolves to the CallResult object.
|
45546
45719
|
*/
|
45547
|
-
async simulateTransaction(transactionRequestLike) {
|
45720
|
+
async simulateTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
|
45548
45721
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
45549
|
-
|
45722
|
+
if (estimateTxDependencies) {
|
45723
|
+
await this.provider.estimateTxDependencies(transactionRequest);
|
45724
|
+
}
|
45550
45725
|
return this.provider.call(
|
45551
45726
|
await this.populateTransactionWitnessesSignature(transactionRequest),
|
45552
45727
|
{
|
@@ -47689,14 +47864,14 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
47689
47864
|
}
|
47690
47865
|
}
|
47691
47866
|
const checksumBits = entropy.length / 4;
|
47692
|
-
const checksum =
|
47867
|
+
const checksum = arrayify(sha2562(entropy))[0] & getUpperMask(checksumBits);
|
47693
47868
|
indices[indices.length - 1] <<= checksumBits;
|
47694
47869
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
47695
47870
|
return indices;
|
47696
47871
|
}
|
47697
47872
|
function mnemonicWordsToEntropy(words, wordlist) {
|
47698
47873
|
const size = Math.ceil(11 * words.length / 8);
|
47699
|
-
const entropy =
|
47874
|
+
const entropy = arrayify(new Uint8Array(size));
|
47700
47875
|
let offset = 0;
|
47701
47876
|
for (let i = 0; i < words.length; i += 1) {
|
47702
47877
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
@@ -47716,7 +47891,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
47716
47891
|
const entropyBits = 32 * words.length / 3;
|
47717
47892
|
const checksumBits = words.length / 3;
|
47718
47893
|
const checksumMask = getUpperMask(checksumBits);
|
47719
|
-
const checksum =
|
47894
|
+
const checksum = arrayify(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
47720
47895
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
47721
47896
|
throw new FuelError(
|
47722
47897
|
ErrorCode.INVALID_CHECKSUM,
|
@@ -47799,7 +47974,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
47799
47974
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
47800
47975
|
*/
|
47801
47976
|
static entropyToMnemonic(entropy, wordlist = english) {
|
47802
|
-
const entropyBytes =
|
47977
|
+
const entropyBytes = arrayify(entropy);
|
47803
47978
|
assertWordList(wordlist);
|
47804
47979
|
assertEntropy(entropyBytes);
|
47805
47980
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -47868,14 +48043,14 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
47868
48043
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
47869
48044
|
*/
|
47870
48045
|
static masterKeysFromSeed(seed) {
|
47871
|
-
const seedArray =
|
48046
|
+
const seedArray = arrayify(seed);
|
47872
48047
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
47873
48048
|
throw new FuelError(
|
47874
48049
|
ErrorCode.INVALID_SEED,
|
47875
48050
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
47876
48051
|
);
|
47877
48052
|
}
|
47878
|
-
return
|
48053
|
+
return arrayify(computeHmac("sha512", MasterSecret, seedArray));
|
47879
48054
|
}
|
47880
48055
|
/**
|
47881
48056
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -47886,7 +48061,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
47886
48061
|
*/
|
47887
48062
|
static seedToExtendedKey(seed, testnet = false) {
|
47888
48063
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
47889
|
-
const prefix =
|
48064
|
+
const prefix = arrayify(testnet ? TestnetPRV : MainnetPRV);
|
47890
48065
|
const depth = "0x00";
|
47891
48066
|
const fingerprint = "0x00000000";
|
47892
48067
|
const index = "0x00000000";
|
@@ -47916,7 +48091,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
47916
48091
|
* @returns A randomly generated mnemonic
|
47917
48092
|
*/
|
47918
48093
|
static generate(size = 32, extraEntropy = "") {
|
47919
|
-
const entropy = extraEntropy ? sha2562(concat([randomBytes22(size),
|
48094
|
+
const entropy = extraEntropy ? sha2562(concat([randomBytes22(size), arrayify(extraEntropy)])) : randomBytes22(size);
|
47920
48095
|
return Mnemonic.entropyToMnemonic(entropy);
|
47921
48096
|
}
|
47922
48097
|
};
|
@@ -48001,9 +48176,9 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
48001
48176
|
* @returns A new instance of HDWallet on the derived index
|
48002
48177
|
*/
|
48003
48178
|
deriveIndex(index) {
|
48004
|
-
const privateKey = this.privateKey &&
|
48005
|
-
const publicKey =
|
48006
|
-
const chainCode =
|
48179
|
+
const privateKey = this.privateKey && arrayify(this.privateKey);
|
48180
|
+
const publicKey = arrayify(this.publicKey);
|
48181
|
+
const chainCode = arrayify(this.chainCode);
|
48007
48182
|
const data = new Uint8Array(37);
|
48008
48183
|
if (index & HARDENED_INDEX) {
|
48009
48184
|
if (!privateKey) {
|
@@ -48014,10 +48189,10 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
48014
48189
|
}
|
48015
48190
|
data.set(privateKey, 1);
|
48016
48191
|
} else {
|
48017
|
-
data.set(
|
48192
|
+
data.set(arrayify(this.publicKey));
|
48018
48193
|
}
|
48019
48194
|
data.set(toBytes3(index, 4), 33);
|
48020
|
-
const bytes4 =
|
48195
|
+
const bytes4 = arrayify(computeHmac("sha512", chainCode, data));
|
48021
48196
|
const IL = bytes4.slice(0, 32);
|
48022
48197
|
const IR = bytes4.slice(32);
|
48023
48198
|
if (privateKey) {
|
@@ -48071,9 +48246,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
48071
48246
|
const index = toHex(this.index, 4);
|
48072
48247
|
const chainCode = this.chainCode;
|
48073
48248
|
const key = this.privateKey != null && !isPublic ? concat(["0x00", this.privateKey]) : this.publicKey;
|
48074
|
-
const extendedKey =
|
48075
|
-
concat([prefix, depth, parentFingerprint, index, chainCode, key])
|
48076
|
-
);
|
48249
|
+
const extendedKey = arrayify(concat([prefix, depth, parentFingerprint, index, chainCode, key]));
|
48077
48250
|
return base58check(extendedKey);
|
48078
48251
|
}
|
48079
48252
|
/**
|
@@ -48085,13 +48258,13 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
48085
48258
|
static fromSeed(seed) {
|
48086
48259
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
48087
48260
|
return new HDWallet({
|
48088
|
-
chainCode:
|
48089
|
-
privateKey:
|
48261
|
+
chainCode: arrayify(masterKey.slice(32)),
|
48262
|
+
privateKey: arrayify(masterKey.slice(0, 32))
|
48090
48263
|
});
|
48091
48264
|
}
|
48092
48265
|
static fromExtendedKey(extendedKey) {
|
48093
48266
|
const decoded = toBeHex(decodeBase58(extendedKey));
|
48094
|
-
const bytes4 =
|
48267
|
+
const bytes4 = arrayify(decoded);
|
48095
48268
|
const validChecksum = base58check(bytes4.slice(0, 78)) === extendedKey;
|
48096
48269
|
if (bytes4.length !== 82 || !isValidExtendedKey(bytes4)) {
|
48097
48270
|
throw new FuelError(ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
@@ -48757,7 +48930,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
48757
48930
|
// src/predicate/utils/getPredicateRoot.ts
|
48758
48931
|
var getPredicateRoot = (bytecode) => {
|
48759
48932
|
const chunkSize = 16 * 1024;
|
48760
|
-
const bytes4 =
|
48933
|
+
const bytes4 = arrayify(bytecode);
|
48761
48934
|
const chunks = chunkAndPadBytes(bytes4, chunkSize);
|
48762
48935
|
const codeRoot = calcRoot(chunks.map((c) => hexlify(c)));
|
48763
48936
|
const predicateRoot = hash3(concat(["0x4655454C", codeRoot]));
|
@@ -48870,7 +49043,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
48870
49043
|
* @returns An object containing the new predicate bytes and interface.
|
48871
49044
|
*/
|
48872
49045
|
static processPredicateData(bytes4, jsonAbi, configurableConstants) {
|
48873
|
-
let predicateBytes =
|
49046
|
+
let predicateBytes = arrayify(bytes4);
|
48874
49047
|
let abiInterface;
|
48875
49048
|
if (jsonAbi) {
|
48876
49049
|
abiInterface = new Interface(jsonAbi);
|
@@ -48970,14 +49143,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
48970
49143
|
})(FuelConnectorEventTypes || {});
|
48971
49144
|
var FuelConnectorEventType = "FuelConnector";
|
48972
49145
|
|
48973
|
-
// src/connectors/types/constants.ts
|
48974
|
-
var CONNECTOR_SCRIPT = "FuelConnectorScript";
|
48975
|
-
var CONTENT_SCRIPT_NAME = "FuelContentScript";
|
48976
|
-
var BACKGROUND_SCRIPT_NAME = "FuelBackgroundScript";
|
48977
|
-
var POPUP_SCRIPT_NAME = "FuelPopUpScript";
|
48978
|
-
var VAULT_SCRIPT_NAME = "FuelVaultScript";
|
48979
|
-
var EVENT_MESSAGE = "message";
|
48980
|
-
|
48981
49146
|
// src/connectors/types/data-type.ts
|
48982
49147
|
var MessageTypes = /* @__PURE__ */ ((MessageTypes2) => {
|
48983
49148
|
MessageTypes2["ping"] = "ping";
|
@@ -49227,40 +49392,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
49227
49392
|
}
|
49228
49393
|
};
|
49229
49394
|
|
49230
|
-
// src/connectors/fuel-wallet-locked.ts
|
49231
|
-
var FuelWalletLocked = class extends WalletLocked {
|
49232
|
-
connector;
|
49233
|
-
_provider;
|
49234
|
-
constructor(address, connector, provider) {
|
49235
|
-
super(address, provider);
|
49236
|
-
this.connector = connector;
|
49237
|
-
this._provider = provider;
|
49238
|
-
}
|
49239
|
-
async signMessage(message) {
|
49240
|
-
return this.connector.signMessage(this.address.toString(), message);
|
49241
|
-
}
|
49242
|
-
async sendTransaction(transaction) {
|
49243
|
-
const transactionId = await this.connector.sendTransaction(
|
49244
|
-
this.address.toString(),
|
49245
|
-
transaction
|
49246
|
-
);
|
49247
|
-
return this.provider.getTransactionResponse(transactionId);
|
49248
|
-
}
|
49249
|
-
};
|
49250
|
-
|
49251
|
-
// src/connectors/fuel-wallet-provider.ts
|
49252
|
-
var FuelWalletProvider = class extends Provider {
|
49253
|
-
static async create(url, options) {
|
49254
|
-
const provider = new FuelWalletProvider(url, options);
|
49255
|
-
await provider.fetchChainAndNodeInfo();
|
49256
|
-
return provider;
|
49257
|
-
}
|
49258
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
49259
|
-
async getTransactionResponse(transactionId) {
|
49260
|
-
return new TransactionResponse2(transactionId, this);
|
49261
|
-
}
|
49262
|
-
};
|
49263
|
-
|
49264
49395
|
// src/connectors/utils/cache.ts
|
49265
49396
|
function cacheFor(fn, { cache: cache2, cacheTime, key }) {
|
49266
49397
|
return async (...args) => {
|
@@ -49290,23 +49421,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
49290
49421
|
);
|
49291
49422
|
}
|
49292
49423
|
|
49293
|
-
// src/connectors/utils/get-asset-by-chain.ts
|
49294
|
-
function getAssetByChain(asset, chainId, network = "fuel") {
|
49295
|
-
const assetFuelNetwork = asset.networks.find(
|
49296
|
-
(item) => item.chainId === chainId && item.type === network
|
49297
|
-
);
|
49298
|
-
if (!assetFuelNetwork) {
|
49299
|
-
throw new Error("Asset not found for the given chain and network.");
|
49300
|
-
}
|
49301
|
-
return {
|
49302
|
-
...asset,
|
49303
|
-
assetId: assetFuelNetwork.assetId,
|
49304
|
-
decimals: assetFuelNetwork.decimals,
|
49305
|
-
chainId: assetFuelNetwork.chainId,
|
49306
|
-
network: assetFuelNetwork.type
|
49307
|
-
};
|
49308
|
-
}
|
49309
|
-
|
49310
49424
|
// src/connectors/utils/promises.ts
|
49311
49425
|
function deferPromise() {
|
49312
49426
|
const defer = {};
|
@@ -49328,6 +49442,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
49328
49442
|
// src/connectors/fuel.ts
|
49329
49443
|
var HAS_CONNECTOR_TIMEOUT = 2e3;
|
49330
49444
|
var PING_CACHE_TIME = 5e3;
|
49445
|
+
var { warn } = console;
|
49331
49446
|
var _Fuel = class extends FuelConnector {
|
49332
49447
|
_storage = null;
|
49333
49448
|
_connectors = [];
|
@@ -49596,14 +49711,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
49596
49711
|
* Return a Fuel Provider instance with extends features to work with
|
49597
49712
|
* connectors.
|
49598
49713
|
*
|
49599
|
-
* @deprecated
|
49714
|
+
* @deprecated getProvider is deprecated and is going to be removed in the future, use getWallet instead.
|
49600
49715
|
*/
|
49601
49716
|
async getProvider(providerOrNetwork) {
|
49602
|
-
|
49603
|
-
|
49604
|
-
|
49605
|
-
);
|
49606
|
-
}
|
49717
|
+
warn(
|
49718
|
+
"getProvider is deprecated and is going to be removed in the future, use getWallet instead."
|
49719
|
+
);
|
49607
49720
|
return this._getProvider(providerOrNetwork);
|
49608
49721
|
}
|
49609
49722
|
/**
|
@@ -49615,12 +49728,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
49615
49728
|
if (providerOrNetwork && "getTransactionResponse" in providerOrNetwork) {
|
49616
49729
|
provider = providerOrNetwork;
|
49617
49730
|
} else if (providerOrNetwork && "chainId" in providerOrNetwork && "url" in providerOrNetwork) {
|
49618
|
-
provider = await
|
49731
|
+
provider = await Provider.create(providerOrNetwork.url);
|
49619
49732
|
} else if (!providerOrNetwork) {
|
49620
49733
|
const currentNetwork = await this.currentNetwork();
|
49621
|
-
provider = await
|
49734
|
+
provider = await Provider.create(currentNetwork.url);
|
49622
49735
|
} else {
|
49623
|
-
throw new
|
49736
|
+
throw new FuelError(ErrorCode.INVALID_PROVIDER, "Provider is not valid.");
|
49624
49737
|
}
|
49625
49738
|
return provider;
|
49626
49739
|
}
|
@@ -49630,7 +49743,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
49630
49743
|
*/
|
49631
49744
|
async getWallet(address, providerOrNetwork) {
|
49632
49745
|
const provider = await this._getProvider(providerOrNetwork);
|
49633
|
-
return new
|
49746
|
+
return new Account(address, provider, this);
|
49634
49747
|
}
|
49635
49748
|
/**
|
49636
49749
|
* Remove all open listeners this is useful when you want to
|
@@ -49683,12 +49796,12 @@ mime-types/index.js:
|
|
49683
49796
|
@noble/hashes/esm/utils.js:
|
49684
49797
|
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
49685
49798
|
|
49686
|
-
@noble/hashes/esm/utils.js:
|
49687
|
-
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
49688
|
-
|
49689
49799
|
@noble/curves/esm/abstract/utils.js:
|
49690
49800
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
49691
49801
|
|
49802
|
+
@noble/hashes/esm/utils.js:
|
49803
|
+
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
49804
|
+
|
49692
49805
|
@noble/curves/esm/abstract/modular.js:
|
49693
49806
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
49694
49807
|
|