omnipin 1.6.1 → 1.7.0
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.
- package/dist/cli.js +217 -62
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -6,8 +6,11 @@ import { styleText } from "node:util";
|
|
|
6
6
|
import * as nc from "node:crypto";
|
|
7
7
|
import { createHash, createHmac } from "node:crypto";
|
|
8
8
|
import { randomInt as randomInt2 } from "node:crypto";
|
|
9
|
+
import { setTimeout as setTimeout4 } from "node:timers/promises";
|
|
9
10
|
import crypto3 from "node:crypto";
|
|
10
11
|
import { randomInt } from "node:crypto";
|
|
12
|
+
import { setTimeout as setTimeout2 } from "node:timers/promises";
|
|
13
|
+
import { setTimeout as setTimeout3 } from "node:timers/promises";
|
|
11
14
|
import * as nodeCrypto from "crypto";
|
|
12
15
|
import crypto5 from "crypto";
|
|
13
16
|
import fs from "fs";
|
|
@@ -28,6 +31,7 @@ import { tmpdir } from "node:os";
|
|
|
28
31
|
import { styleText as styleText2 } from "node:util";
|
|
29
32
|
import path2 from "node:path";
|
|
30
33
|
import { styleText as styleText3 } from "node:util";
|
|
34
|
+
import { setTimeout as setTimeout5 } from "node:timers/promises";
|
|
31
35
|
import { styleText as styleText5 } from "node:util";
|
|
32
36
|
import { styleText as styleText6 } from "node:util";
|
|
33
37
|
import { writeFile } from "node:fs/promises";
|
|
@@ -4839,6 +4843,15 @@ function toNumber(hex, options = {}) {
|
|
|
4839
4843
|
return Number(hex);
|
|
4840
4844
|
return Number(toBigInt(hex, options));
|
|
4841
4845
|
}
|
|
4846
|
+
function toString(hex, options = {}) {
|
|
4847
|
+
const { size: size32 } = options;
|
|
4848
|
+
let bytes2 = fromHex(hex);
|
|
4849
|
+
if (size32) {
|
|
4850
|
+
assertSize(bytes2, size32);
|
|
4851
|
+
bytes2 = trimRight(bytes2);
|
|
4852
|
+
}
|
|
4853
|
+
return new TextDecoder().decode(bytes2);
|
|
4854
|
+
}
|
|
4842
4855
|
function validate(value, options = {}) {
|
|
4843
4856
|
const { strict = false } = options;
|
|
4844
4857
|
try {
|
|
@@ -5043,7 +5056,7 @@ function toNumber2(bytes2, options = {}) {
|
|
|
5043
5056
|
const hex = fromBytes(bytes2, options);
|
|
5044
5057
|
return toNumber(hex, options);
|
|
5045
5058
|
}
|
|
5046
|
-
function
|
|
5059
|
+
function toString2(bytes2, options = {}) {
|
|
5047
5060
|
const { size: size32 } = options;
|
|
5048
5061
|
let bytes_ = bytes2;
|
|
5049
5062
|
if (typeof size32 !== "undefined") {
|
|
@@ -8156,7 +8169,7 @@ var EMPTY = from7(new Uint8Array(NODE_SIZE).fill(0));
|
|
|
8156
8169
|
Object.freeze(EMPTY.buffer);
|
|
8157
8170
|
var exports_bytes2 = {};
|
|
8158
8171
|
__export(exports_bytes2, {
|
|
8159
|
-
toString: () =>
|
|
8172
|
+
toString: () => toString3,
|
|
8160
8173
|
toHex: () => toHex4,
|
|
8161
8174
|
isBinary: () => isBinary,
|
|
8162
8175
|
fromString: () => fromString3,
|
|
@@ -8205,7 +8218,7 @@ function isBinary(o) {
|
|
|
8205
8218
|
function fromString3(str) {
|
|
8206
8219
|
return new TextEncoder().encode(str);
|
|
8207
8220
|
}
|
|
8208
|
-
function
|
|
8221
|
+
function toString3(b) {
|
|
8209
8222
|
return new TextDecoder().decode(b);
|
|
8210
8223
|
}
|
|
8211
8224
|
var exports_sha256 = {};
|
|
@@ -8367,7 +8380,7 @@ function asU8A(buf2) {
|
|
|
8367
8380
|
}
|
|
8368
8381
|
return isBuffer2(buf2) ? new Uint8Array(buf2.buffer, buf2.byteOffset, buf2.byteLength) : buf2;
|
|
8369
8382
|
}
|
|
8370
|
-
var
|
|
8383
|
+
var toString4 = useBuffer ? (bytes2, start, end) => {
|
|
8371
8384
|
return end - start > 64 ? globalThis.Buffer.from(bytes2.subarray(start, end)).toString("utf8") : utf8Slice(bytes2, start, end);
|
|
8372
8385
|
} : (bytes2, start, end) => {
|
|
8373
8386
|
return end - start > 64 ? textDecoder.decode(bytes2.subarray(start, end)) : utf8Slice(bytes2, start, end);
|
|
@@ -8810,7 +8823,7 @@ function compareBytes(b1, b2) {
|
|
|
8810
8823
|
function toToken2(data, pos, prefix2, length3, options) {
|
|
8811
8824
|
const totLength = prefix2 + length3;
|
|
8812
8825
|
assertEnoughData(data, pos, totLength);
|
|
8813
|
-
const tok = new Token(Type.string,
|
|
8826
|
+
const tok = new Token(Type.string, toString4(data, pos + prefix2, pos + totLength), totLength);
|
|
8814
8827
|
if (options.retainStringBytes === true) {
|
|
8815
8828
|
tok.byteValue = slice3(data, pos + prefix2, pos + totLength);
|
|
8816
8829
|
}
|
|
@@ -12708,10 +12721,10 @@ function from12(abiItem, options = {}) {
|
|
|
12708
12721
|
...prepare3 ? { hash: getSignatureHash(item) } : {}
|
|
12709
12722
|
};
|
|
12710
12723
|
}
|
|
12711
|
-
function fromAbi(
|
|
12724
|
+
function fromAbi(abi16, name62, options) {
|
|
12712
12725
|
const { args = [], prepare: prepare3 = true } = options ?? {};
|
|
12713
12726
|
const isSelector = validate(name62, { strict: false });
|
|
12714
|
-
const abiItems =
|
|
12727
|
+
const abiItems = abi16.filter((abiItem2) => {
|
|
12715
12728
|
if (isSelector) {
|
|
12716
12729
|
if (abiItem2.type === "function" || abiItem2.type === "error")
|
|
12717
12730
|
return getSelector(abiItem2) === slice(name62, 0, 4);
|
|
@@ -12783,8 +12796,8 @@ function fromAbi(abi14, name62, options) {
|
|
|
12783
12796
|
function getSelector(...parameters) {
|
|
12784
12797
|
const abiItem = (() => {
|
|
12785
12798
|
if (Array.isArray(parameters[0])) {
|
|
12786
|
-
const [
|
|
12787
|
-
return fromAbi(
|
|
12799
|
+
const [abi16, name62] = parameters;
|
|
12800
|
+
return fromAbi(abi16, name62);
|
|
12788
12801
|
}
|
|
12789
12802
|
return parameters[0];
|
|
12790
12803
|
})();
|
|
@@ -12793,8 +12806,8 @@ function getSelector(...parameters) {
|
|
|
12793
12806
|
function getSignature(...parameters) {
|
|
12794
12807
|
const abiItem = (() => {
|
|
12795
12808
|
if (Array.isArray(parameters[0])) {
|
|
12796
|
-
const [
|
|
12797
|
-
return fromAbi(
|
|
12809
|
+
const [abi16, name62] = parameters;
|
|
12810
|
+
return fromAbi(abi16, name62);
|
|
12798
12811
|
}
|
|
12799
12812
|
return parameters[0];
|
|
12800
12813
|
})();
|
|
@@ -12808,8 +12821,8 @@ function getSignature(...parameters) {
|
|
|
12808
12821
|
function getSignatureHash(...parameters) {
|
|
12809
12822
|
const abiItem = (() => {
|
|
12810
12823
|
if (Array.isArray(parameters[0])) {
|
|
12811
|
-
const [
|
|
12812
|
-
return fromAbi(
|
|
12824
|
+
const [abi16, name62] = parameters;
|
|
12825
|
+
return fromAbi(abi16, name62);
|
|
12813
12826
|
}
|
|
12814
12827
|
return parameters[0];
|
|
12815
12828
|
})();
|
|
@@ -13018,7 +13031,7 @@ function decodeString(cursor, { staticPosition }) {
|
|
|
13018
13031
|
return ["", 32];
|
|
13019
13032
|
}
|
|
13020
13033
|
const data = cursor.readBytes(length22, 32);
|
|
13021
|
-
const value =
|
|
13034
|
+
const value = toString2(trimLeft2(data));
|
|
13022
13035
|
cursor.setPosition(staticPosition + 32);
|
|
13023
13036
|
return [value, 32];
|
|
13024
13037
|
}
|
|
@@ -13653,8 +13666,8 @@ class InvalidTypeError extends BaseError {
|
|
|
13653
13666
|
function decode9(...parameters) {
|
|
13654
13667
|
const [abiError, data, options = {}] = (() => {
|
|
13655
13668
|
if (Array.isArray(parameters[0])) {
|
|
13656
|
-
const [
|
|
13657
|
-
return [fromAbi2(
|
|
13669
|
+
const [abi16, name62, data2, options2] = parameters;
|
|
13670
|
+
return [fromAbi2(abi16, name62), data2, options2];
|
|
13658
13671
|
}
|
|
13659
13672
|
return parameters;
|
|
13660
13673
|
})();
|
|
@@ -13673,7 +13686,7 @@ function decode9(...parameters) {
|
|
|
13673
13686
|
function from14(abiError, options = {}) {
|
|
13674
13687
|
return from12(abiError, options);
|
|
13675
13688
|
}
|
|
13676
|
-
function fromAbi2(
|
|
13689
|
+
function fromAbi2(abi16, name62, options) {
|
|
13677
13690
|
if (name62 === "Error")
|
|
13678
13691
|
return solidityError;
|
|
13679
13692
|
if (name62 === "Panic")
|
|
@@ -13685,7 +13698,7 @@ function fromAbi2(abi14, name62, options) {
|
|
|
13685
13698
|
if (selector === solidityPanicSelector)
|
|
13686
13699
|
return solidityPanic;
|
|
13687
13700
|
}
|
|
13688
|
-
const item = fromAbi(
|
|
13701
|
+
const item = fromAbi(abi16, name62, options);
|
|
13689
13702
|
if (item.type !== "error")
|
|
13690
13703
|
throw new NotFoundError({ name: name62, type: "error" });
|
|
13691
13704
|
return item;
|
|
@@ -14431,15 +14444,15 @@ var waitForTransaction = async (provider, hash2) => {
|
|
|
14431
14444
|
return fromRpc3({ ...rawReceipt, chainId });
|
|
14432
14445
|
}
|
|
14433
14446
|
const delay = Math.min(1e3 * 2 ** attempt, 3e4);
|
|
14434
|
-
await
|
|
14447
|
+
await setTimeout2(delay);
|
|
14435
14448
|
}
|
|
14436
14449
|
throw new Error(`Transaction ${hash2} not mined within timeout period`);
|
|
14437
14450
|
};
|
|
14438
14451
|
function decodeResult(...parameters) {
|
|
14439
14452
|
const [abiFunction, data, options = {}] = (() => {
|
|
14440
14453
|
if (Array.isArray(parameters[0])) {
|
|
14441
|
-
const [
|
|
14442
|
-
return [fromAbi3(
|
|
14454
|
+
const [abi16, name62, data2, options2] = parameters;
|
|
14455
|
+
return [fromAbi3(abi16, name62), data2, options2];
|
|
14443
14456
|
}
|
|
14444
14457
|
return parameters;
|
|
14445
14458
|
})();
|
|
@@ -14456,8 +14469,8 @@ function decodeResult(...parameters) {
|
|
|
14456
14469
|
function encodeData2(...parameters) {
|
|
14457
14470
|
const [abiFunction, args = []] = (() => {
|
|
14458
14471
|
if (Array.isArray(parameters[0])) {
|
|
14459
|
-
const [
|
|
14460
|
-
return [fromAbi3(
|
|
14472
|
+
const [abi16, name62, args3] = parameters;
|
|
14473
|
+
return [fromAbi3(abi16, name62, { args: args3 }), args3];
|
|
14461
14474
|
}
|
|
14462
14475
|
const [abiFunction2, args2] = parameters;
|
|
14463
14476
|
return [abiFunction2, args2];
|
|
@@ -14470,8 +14483,8 @@ function encodeData2(...parameters) {
|
|
|
14470
14483
|
const data = args.length > 0 ? encode7(item.inputs, args) : void 0;
|
|
14471
14484
|
return data ? concat(selector, data) : selector;
|
|
14472
14485
|
}
|
|
14473
|
-
function fromAbi3(
|
|
14474
|
-
const item = fromAbi(
|
|
14486
|
+
function fromAbi3(abi16, name62, options) {
|
|
14487
|
+
const item = fromAbi(abi16, name62, options);
|
|
14475
14488
|
if (item.type !== "function")
|
|
14476
14489
|
throw new NotFoundError({ name: name62, type: "function" });
|
|
14477
14490
|
return item;
|
|
@@ -15003,6 +15016,88 @@ var getProviderIdByAddress = async ({
|
|
|
15003
15016
|
return decodeResult(abi6, result);
|
|
15004
15017
|
};
|
|
15005
15018
|
var abi7 = {
|
|
15019
|
+
type: "function",
|
|
15020
|
+
inputs: [
|
|
15021
|
+
{ name: "providerId", internalType: "uint256", type: "uint256" },
|
|
15022
|
+
{
|
|
15023
|
+
name: "productType",
|
|
15024
|
+
internalType: "enum ServiceProviderRegistryStorage.ProductType",
|
|
15025
|
+
type: "uint8"
|
|
15026
|
+
}
|
|
15027
|
+
],
|
|
15028
|
+
name: "getProviderWithProduct",
|
|
15029
|
+
outputs: [
|
|
15030
|
+
{
|
|
15031
|
+
name: "",
|
|
15032
|
+
internalType: "struct ServiceProviderRegistryStorage.ProviderWithProduct",
|
|
15033
|
+
type: "tuple",
|
|
15034
|
+
components: [
|
|
15035
|
+
{ name: "providerId", internalType: "uint256", type: "uint256" },
|
|
15036
|
+
{
|
|
15037
|
+
name: "providerInfo",
|
|
15038
|
+
internalType: "struct ServiceProviderRegistryStorage.ServiceProviderInfo",
|
|
15039
|
+
type: "tuple",
|
|
15040
|
+
components: [
|
|
15041
|
+
{
|
|
15042
|
+
name: "serviceProvider",
|
|
15043
|
+
internalType: "address",
|
|
15044
|
+
type: "address"
|
|
15045
|
+
},
|
|
15046
|
+
{ name: "payee", internalType: "address", type: "address" },
|
|
15047
|
+
{ name: "name", internalType: "string", type: "string" },
|
|
15048
|
+
{ name: "description", internalType: "string", type: "string" },
|
|
15049
|
+
{ name: "isActive", internalType: "bool", type: "bool" }
|
|
15050
|
+
]
|
|
15051
|
+
},
|
|
15052
|
+
{
|
|
15053
|
+
name: "product",
|
|
15054
|
+
internalType: "struct ServiceProviderRegistryStorage.ServiceProduct",
|
|
15055
|
+
type: "tuple",
|
|
15056
|
+
components: [
|
|
15057
|
+
{
|
|
15058
|
+
name: "productType",
|
|
15059
|
+
internalType: "enum ServiceProviderRegistryStorage.ProductType",
|
|
15060
|
+
type: "uint8"
|
|
15061
|
+
},
|
|
15062
|
+
{
|
|
15063
|
+
name: "capabilityKeys",
|
|
15064
|
+
internalType: "string[]",
|
|
15065
|
+
type: "string[]"
|
|
15066
|
+
},
|
|
15067
|
+
{ name: "isActive", internalType: "bool", type: "bool" }
|
|
15068
|
+
]
|
|
15069
|
+
},
|
|
15070
|
+
{
|
|
15071
|
+
name: "productCapabilityValues",
|
|
15072
|
+
internalType: "bytes[]",
|
|
15073
|
+
type: "bytes[]"
|
|
15074
|
+
}
|
|
15075
|
+
]
|
|
15076
|
+
}
|
|
15077
|
+
],
|
|
15078
|
+
stateMutability: "view"
|
|
15079
|
+
};
|
|
15080
|
+
var getProviderMetadata = async ({
|
|
15081
|
+
chain,
|
|
15082
|
+
providerId
|
|
15083
|
+
}) => {
|
|
15084
|
+
const provider = filProvider[chain.id];
|
|
15085
|
+
const result = await provider.request({
|
|
15086
|
+
method: "eth_call",
|
|
15087
|
+
params: [
|
|
15088
|
+
{
|
|
15089
|
+
data: encodeData2(abi7, [providerId, 0]),
|
|
15090
|
+
to: chain.contracts.providerRegistry.address
|
|
15091
|
+
},
|
|
15092
|
+
"latest"
|
|
15093
|
+
]
|
|
15094
|
+
});
|
|
15095
|
+
const { providerInfo, productCapabilityValues, product } = decodeResult(abi7, result);
|
|
15096
|
+
const { capabilityKeys } = product;
|
|
15097
|
+
const serviceURL = toString(productCapabilityValues[capabilityKeys.indexOf("serviceURL")]);
|
|
15098
|
+
return { address: providerInfo.payee, serviceURL };
|
|
15099
|
+
};
|
|
15100
|
+
var abi8 = {
|
|
15006
15101
|
type: "function",
|
|
15007
15102
|
name: "getProviderPayee",
|
|
15008
15103
|
stateMutability: "view",
|
|
@@ -15028,15 +15123,57 @@ var getProviderPayee = async ({
|
|
|
15028
15123
|
method: "eth_call",
|
|
15029
15124
|
params: [
|
|
15030
15125
|
{
|
|
15031
|
-
data: encodeData2(
|
|
15126
|
+
data: encodeData2(abi8, [id]),
|
|
15032
15127
|
to: chain.contracts.providerRegistry.address
|
|
15033
15128
|
},
|
|
15034
15129
|
"latest"
|
|
15035
15130
|
]
|
|
15036
15131
|
});
|
|
15037
|
-
return checksum2(decodeResult(
|
|
15132
|
+
return checksum2(decodeResult(abi8, result));
|
|
15038
15133
|
};
|
|
15039
|
-
var
|
|
15134
|
+
var abi9 = {
|
|
15135
|
+
inputs: [
|
|
15136
|
+
{
|
|
15137
|
+
internalType: "uint256",
|
|
15138
|
+
name: "offset",
|
|
15139
|
+
type: "uint256"
|
|
15140
|
+
},
|
|
15141
|
+
{
|
|
15142
|
+
internalType: "uint256",
|
|
15143
|
+
name: "limit",
|
|
15144
|
+
type: "uint256"
|
|
15145
|
+
}
|
|
15146
|
+
],
|
|
15147
|
+
name: "getApprovedProviders",
|
|
15148
|
+
outputs: [
|
|
15149
|
+
{
|
|
15150
|
+
internalType: "uint256[]",
|
|
15151
|
+
name: "providerIds",
|
|
15152
|
+
type: "uint256[]"
|
|
15153
|
+
}
|
|
15154
|
+
],
|
|
15155
|
+
stateMutability: "view",
|
|
15156
|
+
type: "function"
|
|
15157
|
+
};
|
|
15158
|
+
var getRandomProviderId = async ({
|
|
15159
|
+
chain
|
|
15160
|
+
}) => {
|
|
15161
|
+
const provider = filProvider[chain.id];
|
|
15162
|
+
const result = await provider.request({
|
|
15163
|
+
method: "eth_call",
|
|
15164
|
+
params: [
|
|
15165
|
+
{
|
|
15166
|
+
data: encodeData2(abi9, [0n, 100n]),
|
|
15167
|
+
to: chain.contracts.storageView.address
|
|
15168
|
+
},
|
|
15169
|
+
"latest"
|
|
15170
|
+
]
|
|
15171
|
+
});
|
|
15172
|
+
const ids = decodeResult(abi9, result);
|
|
15173
|
+
const randomIndex = Math.floor(Math.random() * ids.length);
|
|
15174
|
+
return ids[randomIndex];
|
|
15175
|
+
};
|
|
15176
|
+
var abi10 = {
|
|
15040
15177
|
constant: true,
|
|
15041
15178
|
inputs: [
|
|
15042
15179
|
{
|
|
@@ -15064,15 +15201,15 @@ var getUSDfcBalance = async ({
|
|
|
15064
15201
|
method: "eth_call",
|
|
15065
15202
|
params: [
|
|
15066
15203
|
{
|
|
15067
|
-
data: encodeData2(
|
|
15204
|
+
data: encodeData2(abi10, [address]),
|
|
15068
15205
|
to: chain.contracts.usdfc.address
|
|
15069
15206
|
},
|
|
15070
15207
|
"latest"
|
|
15071
15208
|
]
|
|
15072
15209
|
});
|
|
15073
|
-
return decodeResult(
|
|
15210
|
+
return decodeResult(abi10, result);
|
|
15074
15211
|
};
|
|
15075
|
-
var
|
|
15212
|
+
var abi11 = {
|
|
15076
15213
|
type: "function",
|
|
15077
15214
|
inputs: [],
|
|
15078
15215
|
name: "getServicePrice",
|
|
@@ -15124,12 +15261,12 @@ var getServicePrice = async ({
|
|
|
15124
15261
|
params: [
|
|
15125
15262
|
{
|
|
15126
15263
|
to: chain.contracts.storage.address,
|
|
15127
|
-
data: encodeData2(
|
|
15264
|
+
data: encodeData2(abi11)
|
|
15128
15265
|
},
|
|
15129
15266
|
"latest"
|
|
15130
15267
|
]
|
|
15131
15268
|
});
|
|
15132
|
-
const { minimumPricePerMonth, pricePerTiBPerMonthNoCDN, epochsPerMonth } = decodeResult(
|
|
15269
|
+
const { minimumPricePerMonth, pricePerTiBPerMonthNoCDN, epochsPerMonth } = decodeResult(abi11, result);
|
|
15133
15270
|
const linearCost = BigInt(sizeInBytes) * pricePerTiBPerMonthNoCDN / TiB;
|
|
15134
15271
|
const actualCost = linearCost > minimumPricePerMonth ? linearCost : minimumPricePerMonth;
|
|
15135
15272
|
const costWithBuffer = actualCost * 110n / 100n;
|
|
@@ -15141,7 +15278,7 @@ var getServicePrice = async ({
|
|
|
15141
15278
|
linearCost
|
|
15142
15279
|
};
|
|
15143
15280
|
};
|
|
15144
|
-
var
|
|
15281
|
+
var abi12 = {
|
|
15145
15282
|
type: "function",
|
|
15146
15283
|
inputs: [{ name: "dataSetId", internalType: "uint256", type: "uint256" }],
|
|
15147
15284
|
name: "getDataSet",
|
|
@@ -15176,16 +15313,16 @@ var getDataSet = async ({
|
|
|
15176
15313
|
method: "eth_call",
|
|
15177
15314
|
params: [
|
|
15178
15315
|
{
|
|
15179
|
-
data: encodeData2(
|
|
15316
|
+
data: encodeData2(abi12, [dataSetId]),
|
|
15180
15317
|
to: chain.contracts.storageView.address
|
|
15181
15318
|
},
|
|
15182
15319
|
"latest"
|
|
15183
15320
|
]
|
|
15184
15321
|
});
|
|
15185
|
-
return decodeResult(
|
|
15322
|
+
return decodeResult(abi12, result);
|
|
15186
15323
|
};
|
|
15187
15324
|
var metadata2 = [{ key: "withIPFSIndexing", value: "" }];
|
|
15188
|
-
var
|
|
15325
|
+
var abi13 = [
|
|
15189
15326
|
{ type: "uint256" },
|
|
15190
15327
|
{ type: "string[][]" },
|
|
15191
15328
|
{ type: "string[][]" },
|
|
@@ -15249,7 +15386,7 @@ var uploadPieceToDataSet = async ({
|
|
|
15249
15386
|
const signature = toHex3(sign({ payload, privateKey }));
|
|
15250
15387
|
const keys2 = [metadata2.map((m) => m.key)];
|
|
15251
15388
|
const values2 = [metadata2.map((m) => m.value)];
|
|
15252
|
-
const extraData = encode7(from13(
|
|
15389
|
+
const extraData = encode7(from13(abi13), [
|
|
15253
15390
|
nonce,
|
|
15254
15391
|
keys2,
|
|
15255
15392
|
values2,
|
|
@@ -15319,7 +15456,7 @@ var waitForDatasetReady = async (statusUrl) => {
|
|
|
15319
15456
|
${await res.text()}`);
|
|
15320
15457
|
}
|
|
15321
15458
|
if (!json.dataSetCreated) {
|
|
15322
|
-
await
|
|
15459
|
+
await setTimeout3(3e3);
|
|
15323
15460
|
continue;
|
|
15324
15461
|
}
|
|
15325
15462
|
if (json.txStatus === "confirmed" && json.dataSetCreated) {
|
|
@@ -15340,9 +15477,9 @@ var uploadToFilecoin = async ({
|
|
|
15340
15477
|
filecoinChain = "mainnet",
|
|
15341
15478
|
size: size42
|
|
15342
15479
|
}) => {
|
|
15343
|
-
if (!providerURL)
|
|
15480
|
+
if (!providerURL && providerAddress)
|
|
15344
15481
|
throw new MissingKeyError("FILECOIN_SP_URL");
|
|
15345
|
-
if (!providerAddress)
|
|
15482
|
+
if (!providerAddress && providerURL)
|
|
15346
15483
|
throw new MissingKeyError("FILECOIN_SP_ADDRESS");
|
|
15347
15484
|
const publicKey = getPublicKey({ privateKey });
|
|
15348
15485
|
const address = fromPublicKey(publicKey);
|
|
@@ -15354,20 +15491,36 @@ var uploadToFilecoin = async ({
|
|
|
15354
15491
|
logger.info(`USDfc balance: ${format(balance, 18)}`);
|
|
15355
15492
|
if (balance === 0n)
|
|
15356
15493
|
throw new DeployError(providerName4, "No USDfc on account");
|
|
15357
|
-
|
|
15358
|
-
|
|
15359
|
-
|
|
15360
|
-
|
|
15494
|
+
if (verbose)
|
|
15495
|
+
logger.info("Looking up existing data sets");
|
|
15496
|
+
const dataSets = await getClientDataSets({ address, chain });
|
|
15497
|
+
let providerId;
|
|
15498
|
+
if (dataSets.length > 0) {
|
|
15499
|
+
const lastProvider = dataSets.at(-1);
|
|
15500
|
+
providerId = lastProvider.providerId;
|
|
15501
|
+
} else if (providerAddress) {
|
|
15502
|
+
providerId = await getProviderIdByAddress({
|
|
15503
|
+
providerAddress,
|
|
15504
|
+
chain
|
|
15505
|
+
});
|
|
15506
|
+
} else {
|
|
15507
|
+
providerId = await getRandomProviderId({ chain });
|
|
15508
|
+
}
|
|
15361
15509
|
if (verbose)
|
|
15362
15510
|
logger.info(`Filecoin SP ID: ${providerId}`);
|
|
15511
|
+
if (!providerURL) {
|
|
15512
|
+
const { serviceURL, address: address2 } = await getProviderMetadata({
|
|
15513
|
+
chain,
|
|
15514
|
+
providerId
|
|
15515
|
+
});
|
|
15516
|
+
providerURL = serviceURL;
|
|
15517
|
+
providerAddress = address2;
|
|
15518
|
+
}
|
|
15363
15519
|
const payee = await getProviderPayee({ id: providerId, chain });
|
|
15364
15520
|
if (verbose)
|
|
15365
15521
|
logger.info(`Filecoin SP Payee: ${payee}`);
|
|
15366
15522
|
const { perMonth } = await getServicePrice({ size: size42, chain });
|
|
15367
15523
|
logger.info(`Price for storage: ${format(perMonth, 18)} USDfc/month`);
|
|
15368
|
-
if (verbose)
|
|
15369
|
-
logger.info("Looking up existing datasets");
|
|
15370
|
-
const dataSets = await getClientDataSets({ address, chain });
|
|
15371
15524
|
let datasetId;
|
|
15372
15525
|
let clientDataSetId;
|
|
15373
15526
|
const providerDataSets = dataSets.filter((set) => set.providerId === providerId);
|
|
@@ -15393,6 +15546,8 @@ var uploadToFilecoin = async ({
|
|
|
15393
15546
|
await waitForTransaction(filProvider[chainId], hash3);
|
|
15394
15547
|
await waitForDatasetReady(statusUrl2);
|
|
15395
15548
|
logger.success("Data set registered");
|
|
15549
|
+
logger.info("Waiting for 5 seconds to ensure everything is in sync");
|
|
15550
|
+
await setTimeout4(5e3);
|
|
15396
15551
|
} else {
|
|
15397
15552
|
logger.info(`Using existing dataset: ${providerDataSets[0].dataSetId}`);
|
|
15398
15553
|
datasetId = providerDataSets[0].dataSetId;
|
|
@@ -15452,7 +15607,7 @@ var uploadToFilecoin = async ({
|
|
|
15452
15607
|
if (res.ok) {
|
|
15453
15608
|
break;
|
|
15454
15609
|
}
|
|
15455
|
-
await
|
|
15610
|
+
await setTimeout4(1e3);
|
|
15456
15611
|
}
|
|
15457
15612
|
logger.success("Piece found");
|
|
15458
15613
|
const { hash: hash2, statusUrl } = await uploadPieceToDataSet({
|
|
@@ -18713,7 +18868,7 @@ __export(exports_schema3, {
|
|
|
18713
18868
|
uint64: () => uint64,
|
|
18714
18869
|
typeError: () => typeError,
|
|
18715
18870
|
tuple: () => tuple,
|
|
18716
|
-
toString: () =>
|
|
18871
|
+
toString: () => toString5,
|
|
18717
18872
|
text: () => match5,
|
|
18718
18873
|
struct: () => struct,
|
|
18719
18874
|
string: () => string,
|
|
@@ -19291,7 +19446,7 @@ class Literal extends API {
|
|
|
19291
19446
|
return super.default(value);
|
|
19292
19447
|
}
|
|
19293
19448
|
toString() {
|
|
19294
|
-
return `literal(${
|
|
19449
|
+
return `literal(${toString5(this.value)})`;
|
|
19295
19450
|
}
|
|
19296
19451
|
}
|
|
19297
19452
|
var literal = (value) => new Literal(value);
|
|
@@ -19416,11 +19571,11 @@ class TypeError2 extends SchemaError {
|
|
|
19416
19571
|
return "TypeError";
|
|
19417
19572
|
}
|
|
19418
19573
|
describe() {
|
|
19419
|
-
return `Expected value of type ${this.expect} instead got ${
|
|
19574
|
+
return `Expected value of type ${this.expect} instead got ${toString5(this.actual)}`;
|
|
19420
19575
|
}
|
|
19421
19576
|
}
|
|
19422
19577
|
var typeError = (data) => ({ error: new TypeError2(data) });
|
|
19423
|
-
var
|
|
19578
|
+
var toString5 = (value) => {
|
|
19424
19579
|
const type4 = typeof value;
|
|
19425
19580
|
switch (type4) {
|
|
19426
19581
|
case "boolean":
|
|
@@ -19448,7 +19603,7 @@ class LiteralError extends SchemaError {
|
|
|
19448
19603
|
return "LiteralError";
|
|
19449
19604
|
}
|
|
19450
19605
|
describe() {
|
|
19451
|
-
return `Expected literal ${
|
|
19606
|
+
return `Expected literal ${toString5(this.expect)} instead got ${toString5(this.actual)}`;
|
|
19452
19607
|
}
|
|
19453
19608
|
}
|
|
19454
19609
|
class ElementError extends SchemaError {
|
|
@@ -21012,7 +21167,7 @@ __export(exports_identity2, {
|
|
|
21012
21167
|
var identity2 = from8({
|
|
21013
21168
|
prefix: "\0",
|
|
21014
21169
|
name: "identity",
|
|
21015
|
-
encode: (buf2) =>
|
|
21170
|
+
encode: (buf2) => toString3(buf2),
|
|
21016
21171
|
decode: (str) => fromString3(str)
|
|
21017
21172
|
});
|
|
21018
21173
|
var textEncoder2 = new TextEncoder();
|
|
@@ -29160,7 +29315,7 @@ function namehash(name12) {
|
|
|
29160
29315
|
function normalize(name12) {
|
|
29161
29316
|
return ens_normalize(name12);
|
|
29162
29317
|
}
|
|
29163
|
-
var
|
|
29318
|
+
var abi14 = {
|
|
29164
29319
|
constant: true,
|
|
29165
29320
|
inputs: [
|
|
29166
29321
|
{
|
|
@@ -29179,8 +29334,8 @@ var abi12 = {
|
|
|
29179
29334
|
stateMutability: "view",
|
|
29180
29335
|
type: "function"
|
|
29181
29336
|
};
|
|
29182
|
-
var encodeEnsAddressRecordRequest = (name12) => encodeData2(
|
|
29183
|
-
var
|
|
29337
|
+
var encodeEnsAddressRecordRequest = (name12) => encodeData2(abi14, [namehash(name12)]);
|
|
29338
|
+
var abi15 = {
|
|
29184
29339
|
inputs: [
|
|
29185
29340
|
{
|
|
29186
29341
|
name: "name",
|
|
@@ -29245,7 +29400,7 @@ var resolveEnsName = async ({
|
|
|
29245
29400
|
method: "eth_call",
|
|
29246
29401
|
params: [
|
|
29247
29402
|
{
|
|
29248
|
-
data: encodeData2(
|
|
29403
|
+
data: encodeData2(abi15, [
|
|
29249
29404
|
toHex(packetToBytes(name12)),
|
|
29250
29405
|
encodeEnsAddressRecordRequest(name12)
|
|
29251
29406
|
]),
|
|
@@ -29254,7 +29409,7 @@ var resolveEnsName = async ({
|
|
|
29254
29409
|
"latest"
|
|
29255
29410
|
]
|
|
29256
29411
|
});
|
|
29257
|
-
return `0x${decodeResult(
|
|
29412
|
+
return `0x${decodeResult(abi15, result2)[0].slice(-40)}`;
|
|
29258
29413
|
};
|
|
29259
29414
|
function parseEip3770Address(fullAddress) {
|
|
29260
29415
|
const parts = fullAddress.split(":");
|
|
@@ -30150,7 +30305,7 @@ var pingAction = async ({
|
|
|
30150
30305
|
if (response.status === 504) {
|
|
30151
30306
|
if (attempt < maxRetries) {
|
|
30152
30307
|
logger.text(`\u{1F504} Retrying in ${retryInterval / 1e3} seconds...`);
|
|
30153
|
-
await
|
|
30308
|
+
await setTimeout5(retryInterval);
|
|
30154
30309
|
} else {
|
|
30155
30310
|
return logger.error(gwOfflineMessage);
|
|
30156
30311
|
}
|
|
@@ -30160,7 +30315,7 @@ var pingAction = async ({
|
|
|
30160
30315
|
} catch (error3) {
|
|
30161
30316
|
if (error3 instanceof DOMException && attempt < maxRetries) {
|
|
30162
30317
|
logger.info(`\u231B Timed out. Retrying...`);
|
|
30163
|
-
await
|
|
30318
|
+
await setTimeout5(retryInterval);
|
|
30164
30319
|
} else {
|
|
30165
30320
|
logger.error(error3 instanceof DOMException ? gwOfflineMessage : `Error fetching endpoint: ${error3.message}`);
|
|
30166
30321
|
throw error3;
|