omnipin 2.2.2 → 2.2.4
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/index.js +481 -194
- package/package.json +79 -77
package/dist/index.js
CHANGED
|
@@ -10112,11 +10112,14 @@ let filecoinMainnet = {
|
|
|
10112
10112
|
storage: {
|
|
10113
10113
|
address: '0x8408502033C418E1bbC97cE9ac48E5528F371A9f'
|
|
10114
10114
|
},
|
|
10115
|
+
pdpVerifier: {
|
|
10116
|
+
address: '0xBADd0B92C1c71d02E7d520f64c0876538fa2557F'
|
|
10117
|
+
},
|
|
10115
10118
|
providerRegistry: {
|
|
10116
10119
|
address: '0xf55dDbf63F1b55c3F1D4FA7e339a68AB7b64A5eB'
|
|
10117
10120
|
},
|
|
10118
10121
|
storageView: {
|
|
10119
|
-
address: '
|
|
10122
|
+
address: '0xB1B3A3d979c1f233c1021EF98dff9c0932FF1bb9'
|
|
10120
10123
|
}
|
|
10121
10124
|
},
|
|
10122
10125
|
blockExplorer: 'https://filecoin.blockscout.com'
|
|
@@ -10136,11 +10139,14 @@ let filecoinMainnet = {
|
|
|
10136
10139
|
storage: {
|
|
10137
10140
|
address: '0x02925630df557F957f70E112bA06e50965417CA0'
|
|
10138
10141
|
},
|
|
10142
|
+
pdpVerifier: {
|
|
10143
|
+
address: '0x85e366Cf9DD2c0aE37E963d9556F5f4718d6417C'
|
|
10144
|
+
},
|
|
10139
10145
|
providerRegistry: {
|
|
10140
10146
|
address: '0x839e5c9988e4e9977d40708d0094103c0839Ac9D'
|
|
10141
10147
|
},
|
|
10142
10148
|
storageView: {
|
|
10143
|
-
address: '
|
|
10149
|
+
address: '0x537320bd004a7FDd3c1932ca64BD88268301322A'
|
|
10144
10150
|
}
|
|
10145
10151
|
},
|
|
10146
10152
|
blockExplorer: 'https://filecoin-testnet.blockscout.com'
|
|
@@ -10149,7 +10155,9 @@ let filecoinMainnet = {
|
|
|
10149
10155
|
[filecoinCalibration.id]: Provider_from(fromHttp('https://api.calibration.node.glif.io/rpc/v1'))
|
|
10150
10156
|
};
|
|
10151
10157
|
filecoinMainnet.id, filecoinCalibration.id;
|
|
10152
|
-
let
|
|
10158
|
+
let SIZE_CONSTANTS = {
|
|
10159
|
+
TiB: 1n << 40n
|
|
10160
|
+
}, LOCKUP_PERIOD = 30n * 2880n, getClientDatasets_abi = {
|
|
10153
10161
|
type: 'function',
|
|
10154
10162
|
name: 'getClientDataSets',
|
|
10155
10163
|
inputs: [
|
|
@@ -10238,6 +10246,70 @@ let getClientDatasets_abi = {
|
|
|
10238
10246
|
'latest'
|
|
10239
10247
|
]
|
|
10240
10248
|
}));
|
|
10249
|
+
}, accounts_abi = {
|
|
10250
|
+
type: 'function',
|
|
10251
|
+
inputs: [
|
|
10252
|
+
{
|
|
10253
|
+
name: 'token',
|
|
10254
|
+
internalType: 'contract IERC20',
|
|
10255
|
+
type: 'address'
|
|
10256
|
+
},
|
|
10257
|
+
{
|
|
10258
|
+
name: 'owner',
|
|
10259
|
+
internalType: 'address',
|
|
10260
|
+
type: 'address'
|
|
10261
|
+
}
|
|
10262
|
+
],
|
|
10263
|
+
name: 'accounts',
|
|
10264
|
+
outputs: [
|
|
10265
|
+
{
|
|
10266
|
+
name: 'funds',
|
|
10267
|
+
internalType: 'uint256',
|
|
10268
|
+
type: 'uint256'
|
|
10269
|
+
},
|
|
10270
|
+
{
|
|
10271
|
+
name: 'lockupCurrent',
|
|
10272
|
+
internalType: 'uint256',
|
|
10273
|
+
type: 'uint256'
|
|
10274
|
+
},
|
|
10275
|
+
{
|
|
10276
|
+
name: 'lockupRate',
|
|
10277
|
+
internalType: 'uint256',
|
|
10278
|
+
type: 'uint256'
|
|
10279
|
+
},
|
|
10280
|
+
{
|
|
10281
|
+
name: 'lockupLastSettledAt',
|
|
10282
|
+
internalType: 'uint256',
|
|
10283
|
+
type: 'uint256'
|
|
10284
|
+
}
|
|
10285
|
+
],
|
|
10286
|
+
stateMutability: 'view'
|
|
10287
|
+
}, accounts_accounts = async (options)=>{
|
|
10288
|
+
let { address, chain } = options, provider = constants_filProvider[chain.id], token = options.token ?? chain.contracts.usdfc.address, [result, currentEpochHex] = await Promise.all([
|
|
10289
|
+
provider.request({
|
|
10290
|
+
method: 'eth_call',
|
|
10291
|
+
params: [
|
|
10292
|
+
{
|
|
10293
|
+
data: AbiFunction_encodeData(accounts_abi, [
|
|
10294
|
+
token,
|
|
10295
|
+
address
|
|
10296
|
+
]),
|
|
10297
|
+
to: chain.contracts.payments.address
|
|
10298
|
+
},
|
|
10299
|
+
'latest'
|
|
10300
|
+
]
|
|
10301
|
+
}),
|
|
10302
|
+
provider.request({
|
|
10303
|
+
method: 'eth_blockNumber'
|
|
10304
|
+
})
|
|
10305
|
+
]), [funds, lockupCurrent, lockupRate, lockupLastSettledAt] = AbiFunction_decodeResult(accounts_abi, result), currentEpoch = BigInt(currentEpochHex), actualLockup = lockupCurrent + (currentEpoch > lockupLastSettledAt ? currentEpoch - lockupLastSettledAt : 0n) * lockupRate;
|
|
10306
|
+
return {
|
|
10307
|
+
funds,
|
|
10308
|
+
lockupCurrent,
|
|
10309
|
+
lockupRate,
|
|
10310
|
+
lockupLastSettledAt,
|
|
10311
|
+
availableFunds: funds > actualLockup ? funds - actualLockup : 0n
|
|
10312
|
+
};
|
|
10241
10313
|
}, exponents = {
|
|
10242
10314
|
wei: 0,
|
|
10243
10315
|
gwei: 9,
|
|
@@ -10380,7 +10452,126 @@ let getClientDatasets_abi = {
|
|
|
10380
10452
|
AbiFunction_decodeResult(erc20Abi[2], results[2]),
|
|
10381
10453
|
AbiFunction_decodeResult(erc20Abi[3], results[3])
|
|
10382
10454
|
];
|
|
10383
|
-
},
|
|
10455
|
+
}, signErc20Permit = ({ privateKey, address, amount, nonce, deadline, name, version, chain })=>Secp256k1_sign({
|
|
10456
|
+
privateKey,
|
|
10457
|
+
payload: getSignPayload({
|
|
10458
|
+
domain: {
|
|
10459
|
+
chainId: chain.id,
|
|
10460
|
+
name,
|
|
10461
|
+
version,
|
|
10462
|
+
verifyingContract: chain.contracts.usdfc.address
|
|
10463
|
+
},
|
|
10464
|
+
message: {
|
|
10465
|
+
owner: address,
|
|
10466
|
+
spender: chain.contracts.payments.address,
|
|
10467
|
+
value: amount,
|
|
10468
|
+
nonce,
|
|
10469
|
+
deadline
|
|
10470
|
+
},
|
|
10471
|
+
primaryType: 'Permit',
|
|
10472
|
+
types: {
|
|
10473
|
+
Permit: [
|
|
10474
|
+
{
|
|
10475
|
+
name: 'owner',
|
|
10476
|
+
type: 'address'
|
|
10477
|
+
},
|
|
10478
|
+
{
|
|
10479
|
+
name: 'spender',
|
|
10480
|
+
type: 'address'
|
|
10481
|
+
},
|
|
10482
|
+
{
|
|
10483
|
+
name: 'value',
|
|
10484
|
+
type: 'uint256'
|
|
10485
|
+
},
|
|
10486
|
+
{
|
|
10487
|
+
name: 'nonce',
|
|
10488
|
+
type: 'uint256'
|
|
10489
|
+
},
|
|
10490
|
+
{
|
|
10491
|
+
name: 'deadline',
|
|
10492
|
+
type: 'uint256'
|
|
10493
|
+
}
|
|
10494
|
+
]
|
|
10495
|
+
}
|
|
10496
|
+
})
|
|
10497
|
+
}), deposit_with_permit_abi = {
|
|
10498
|
+
type: 'function',
|
|
10499
|
+
inputs: [
|
|
10500
|
+
{
|
|
10501
|
+
name: 'token',
|
|
10502
|
+
internalType: 'contract IERC20',
|
|
10503
|
+
type: 'address'
|
|
10504
|
+
},
|
|
10505
|
+
{
|
|
10506
|
+
name: 'to',
|
|
10507
|
+
internalType: 'address',
|
|
10508
|
+
type: 'address'
|
|
10509
|
+
},
|
|
10510
|
+
{
|
|
10511
|
+
name: 'amount',
|
|
10512
|
+
internalType: 'uint256',
|
|
10513
|
+
type: 'uint256'
|
|
10514
|
+
},
|
|
10515
|
+
{
|
|
10516
|
+
name: 'deadline',
|
|
10517
|
+
internalType: 'uint256',
|
|
10518
|
+
type: 'uint256'
|
|
10519
|
+
},
|
|
10520
|
+
{
|
|
10521
|
+
name: 'v',
|
|
10522
|
+
internalType: 'uint8',
|
|
10523
|
+
type: 'uint8'
|
|
10524
|
+
},
|
|
10525
|
+
{
|
|
10526
|
+
name: 'r',
|
|
10527
|
+
internalType: 'bytes32',
|
|
10528
|
+
type: 'bytes32'
|
|
10529
|
+
},
|
|
10530
|
+
{
|
|
10531
|
+
name: 's',
|
|
10532
|
+
internalType: 'bytes32',
|
|
10533
|
+
type: 'bytes32'
|
|
10534
|
+
}
|
|
10535
|
+
],
|
|
10536
|
+
name: 'depositWithPermit',
|
|
10537
|
+
outputs: [],
|
|
10538
|
+
stateMutability: 'nonpayable'
|
|
10539
|
+
}, depositWithPermitWriteParameters = async ({ privateKey, address, amount, deadline = BigInt(Math.floor(Date.now() / 1000) + 3600), chain })=>{
|
|
10540
|
+
let [balance, name, nonce, version] = await getErc20WithPermitData({
|
|
10541
|
+
address,
|
|
10542
|
+
chain
|
|
10543
|
+
});
|
|
10544
|
+
if (balance < amount) throw Error(`Not enough USDfc to deposit (need: ${Value_format(amount - balance, 18).slice(0, 5)})`);
|
|
10545
|
+
let { r, s, yParity } = await signErc20Permit({
|
|
10546
|
+
privateKey,
|
|
10547
|
+
address,
|
|
10548
|
+
amount,
|
|
10549
|
+
deadline,
|
|
10550
|
+
name,
|
|
10551
|
+
nonce,
|
|
10552
|
+
version,
|
|
10553
|
+
chain
|
|
10554
|
+
}), data = AbiFunction_encodeData(deposit_with_permit_abi, [
|
|
10555
|
+
chain.contracts.usdfc.address,
|
|
10556
|
+
address,
|
|
10557
|
+
amount,
|
|
10558
|
+
deadline,
|
|
10559
|
+
void 0 !== yParity ? yParityToV(yParity) : 27,
|
|
10560
|
+
fromNumber(r, {
|
|
10561
|
+
size: 32
|
|
10562
|
+
}),
|
|
10563
|
+
fromNumber(s, {
|
|
10564
|
+
size: 32
|
|
10565
|
+
})
|
|
10566
|
+
]);
|
|
10567
|
+
return {
|
|
10568
|
+
provider: constants_filProvider[chain.id],
|
|
10569
|
+
abi: deposit_with_permit_abi,
|
|
10570
|
+
from: address,
|
|
10571
|
+
to: chain.contracts.payments.address,
|
|
10572
|
+
data
|
|
10573
|
+
};
|
|
10574
|
+
}, deposit_with_permit_and_approve_operator_abi = {
|
|
10384
10575
|
type: 'function',
|
|
10385
10576
|
inputs: [
|
|
10386
10577
|
{
|
|
@@ -10442,55 +10633,13 @@ let getClientDatasets_abi = {
|
|
|
10442
10633
|
name: 'depositWithPermitAndApproveOperator',
|
|
10443
10634
|
outputs: [],
|
|
10444
10635
|
stateMutability: 'nonpayable'
|
|
10445
|
-
},
|
|
10636
|
+
}, depositWithPermitAndApproveOperatorWriteParameters = async ({ privateKey, address, amount, deadline = BigInt(Math.floor(Date.now() / 1000) + 3600), chain })=>{
|
|
10446
10637
|
let [balance, name, nonce, version] = await getErc20WithPermitData({
|
|
10447
10638
|
address,
|
|
10448
10639
|
chain
|
|
10449
10640
|
});
|
|
10450
10641
|
if (balance < amount) throw Error(`Not enough USDfc to deposit (need: ${Value_format(amount - balance, 18).slice(0, 5)})`);
|
|
10451
|
-
let { r, s, yParity } = await (
|
|
10452
|
-
privateKey,
|
|
10453
|
-
payload: getSignPayload({
|
|
10454
|
-
domain: {
|
|
10455
|
-
chainId: chain.id,
|
|
10456
|
-
name,
|
|
10457
|
-
version,
|
|
10458
|
-
verifyingContract: chain.contracts.usdfc.address
|
|
10459
|
-
},
|
|
10460
|
-
message: {
|
|
10461
|
-
owner: address,
|
|
10462
|
-
spender: chain.contracts.payments.address,
|
|
10463
|
-
value: amount,
|
|
10464
|
-
nonce,
|
|
10465
|
-
deadline
|
|
10466
|
-
},
|
|
10467
|
-
primaryType: 'Permit',
|
|
10468
|
-
types: {
|
|
10469
|
-
Permit: [
|
|
10470
|
-
{
|
|
10471
|
-
name: 'owner',
|
|
10472
|
-
type: 'address'
|
|
10473
|
-
},
|
|
10474
|
-
{
|
|
10475
|
-
name: 'spender',
|
|
10476
|
-
type: 'address'
|
|
10477
|
-
},
|
|
10478
|
-
{
|
|
10479
|
-
name: 'value',
|
|
10480
|
-
type: 'uint256'
|
|
10481
|
-
},
|
|
10482
|
-
{
|
|
10483
|
-
name: 'nonce',
|
|
10484
|
-
type: 'uint256'
|
|
10485
|
-
},
|
|
10486
|
-
{
|
|
10487
|
-
name: 'deadline',
|
|
10488
|
-
type: 'uint256'
|
|
10489
|
-
}
|
|
10490
|
-
]
|
|
10491
|
-
}
|
|
10492
|
-
})
|
|
10493
|
-
}))({
|
|
10642
|
+
let { r, s, yParity } = await signErc20Permit({
|
|
10494
10643
|
privateKey,
|
|
10495
10644
|
address,
|
|
10496
10645
|
amount,
|
|
@@ -10499,7 +10648,7 @@ let getClientDatasets_abi = {
|
|
|
10499
10648
|
nonce,
|
|
10500
10649
|
version,
|
|
10501
10650
|
chain
|
|
10502
|
-
}), data = AbiFunction_encodeData(
|
|
10651
|
+
}), data = AbiFunction_encodeData(deposit_with_permit_and_approve_operator_abi, [
|
|
10503
10652
|
chain.contracts.usdfc.address,
|
|
10504
10653
|
address,
|
|
10505
10654
|
amount,
|
|
@@ -10514,161 +10663,110 @@ let getClientDatasets_abi = {
|
|
|
10514
10663
|
chain.contracts.storage.address,
|
|
10515
10664
|
maxUint256,
|
|
10516
10665
|
maxUint256,
|
|
10517
|
-
|
|
10666
|
+
LOCKUP_PERIOD
|
|
10518
10667
|
]);
|
|
10519
10668
|
return {
|
|
10520
10669
|
provider: constants_filProvider[chain.id],
|
|
10521
|
-
abi:
|
|
10670
|
+
abi: deposit_with_permit_and_approve_operator_abi,
|
|
10522
10671
|
from: address,
|
|
10523
10672
|
to: chain.contracts.payments.address,
|
|
10524
10673
|
data
|
|
10525
10674
|
};
|
|
10526
|
-
},
|
|
10527
|
-
|
|
10675
|
+
}, getUSDfcBalance_abi = {
|
|
10676
|
+
constant: !0,
|
|
10528
10677
|
inputs: [
|
|
10529
10678
|
{
|
|
10530
|
-
name: '
|
|
10531
|
-
internalType: 'contract IERC20',
|
|
10532
|
-
type: 'address'
|
|
10533
|
-
},
|
|
10534
|
-
{
|
|
10535
|
-
name: 'owner',
|
|
10536
|
-
internalType: 'address',
|
|
10679
|
+
name: 'account',
|
|
10537
10680
|
type: 'address'
|
|
10538
10681
|
}
|
|
10539
10682
|
],
|
|
10540
|
-
name: '
|
|
10683
|
+
name: 'balanceOf',
|
|
10541
10684
|
outputs: [
|
|
10542
10685
|
{
|
|
10543
|
-
name: '
|
|
10544
|
-
internalType: 'uint256',
|
|
10545
|
-
type: 'uint256'
|
|
10546
|
-
},
|
|
10547
|
-
{
|
|
10548
|
-
name: 'lockupCurrent',
|
|
10549
|
-
internalType: 'uint256',
|
|
10550
|
-
type: 'uint256'
|
|
10551
|
-
},
|
|
10552
|
-
{
|
|
10553
|
-
name: 'lockupRate',
|
|
10554
|
-
internalType: 'uint256',
|
|
10555
|
-
type: 'uint256'
|
|
10556
|
-
},
|
|
10557
|
-
{
|
|
10558
|
-
name: 'lockupLastSettledAt',
|
|
10559
|
-
internalType: 'uint256',
|
|
10686
|
+
name: '',
|
|
10560
10687
|
type: 'uint256'
|
|
10561
10688
|
}
|
|
10562
10689
|
],
|
|
10563
|
-
|
|
10564
|
-
|
|
10690
|
+
payable: !1,
|
|
10691
|
+
stateMutability: 'view',
|
|
10692
|
+
type: 'function'
|
|
10693
|
+
}, getUSDfcBalance = async ({ address, chain })=>{
|
|
10565
10694
|
let provider = constants_filProvider[chain.id], result = await provider.request({
|
|
10566
10695
|
method: 'eth_call',
|
|
10567
10696
|
params: [
|
|
10568
10697
|
{
|
|
10569
|
-
data: AbiFunction_encodeData(
|
|
10570
|
-
chain.contracts.usdfc.address,
|
|
10698
|
+
data: AbiFunction_encodeData(getUSDfcBalance_abi, [
|
|
10571
10699
|
address
|
|
10572
10700
|
]),
|
|
10573
|
-
to: chain.contracts.
|
|
10701
|
+
to: chain.contracts.usdfc.address
|
|
10574
10702
|
},
|
|
10575
10703
|
'latest'
|
|
10576
10704
|
]
|
|
10577
10705
|
});
|
|
10578
|
-
return AbiFunction_decodeResult(
|
|
10579
|
-
},
|
|
10706
|
+
return AbiFunction_decodeResult(getUSDfcBalance_abi, result);
|
|
10707
|
+
}, is_fwss_max_approved_abi = {
|
|
10580
10708
|
type: 'function',
|
|
10581
|
-
inputs: [],
|
|
10582
|
-
name: 'getServicePrice',
|
|
10583
|
-
outputs: [
|
|
10584
|
-
{
|
|
10585
|
-
name: 'pricing',
|
|
10586
|
-
internalType: 'struct FilecoinWarmStorageService.ServicePricing',
|
|
10587
|
-
type: 'tuple',
|
|
10588
|
-
components: [
|
|
10589
|
-
{
|
|
10590
|
-
name: 'pricePerTiBPerMonthNoCDN',
|
|
10591
|
-
internalType: 'uint256',
|
|
10592
|
-
type: 'uint256'
|
|
10593
|
-
},
|
|
10594
|
-
{
|
|
10595
|
-
name: 'pricePerTiBCdnEgress',
|
|
10596
|
-
internalType: 'uint256',
|
|
10597
|
-
type: 'uint256'
|
|
10598
|
-
},
|
|
10599
|
-
{
|
|
10600
|
-
name: 'pricePerTiBCacheMissEgress',
|
|
10601
|
-
internalType: 'uint256',
|
|
10602
|
-
type: 'uint256'
|
|
10603
|
-
},
|
|
10604
|
-
{
|
|
10605
|
-
name: 'tokenAddress',
|
|
10606
|
-
internalType: 'contract IERC20',
|
|
10607
|
-
type: 'address'
|
|
10608
|
-
},
|
|
10609
|
-
{
|
|
10610
|
-
name: 'epochsPerMonth',
|
|
10611
|
-
internalType: 'uint256',
|
|
10612
|
-
type: 'uint256'
|
|
10613
|
-
},
|
|
10614
|
-
{
|
|
10615
|
-
name: 'minimumPricePerMonth',
|
|
10616
|
-
internalType: 'uint256',
|
|
10617
|
-
type: 'uint256'
|
|
10618
|
-
}
|
|
10619
|
-
]
|
|
10620
|
-
}
|
|
10621
|
-
],
|
|
10622
|
-
stateMutability: 'view'
|
|
10623
|
-
}, TiB = 1024n ** 4n, getServicePrice = async ({ chain, size: sizeInBytes })=>{
|
|
10624
|
-
let provider = constants_filProvider[chain.id], result = await provider.request({
|
|
10625
|
-
method: 'eth_call',
|
|
10626
|
-
params: [
|
|
10627
|
-
{
|
|
10628
|
-
to: chain.contracts.storage.address,
|
|
10629
|
-
data: AbiFunction_encodeData(getServicePrice_abi)
|
|
10630
|
-
},
|
|
10631
|
-
'latest'
|
|
10632
|
-
]
|
|
10633
|
-
}), { minimumPricePerMonth, pricePerTiBPerMonthNoCDN, epochsPerMonth } = AbiFunction_decodeResult(getServicePrice_abi, result), linearCost = BigInt(sizeInBytes) * pricePerTiBPerMonthNoCDN / TiB, costWithBuffer = 110n * (linearCost > minimumPricePerMonth ? linearCost : minimumPricePerMonth) / 100n;
|
|
10634
|
-
return {
|
|
10635
|
-
perMonth: costWithBuffer,
|
|
10636
|
-
perEpoch: costWithBuffer / epochsPerMonth,
|
|
10637
|
-
minimumFloor: minimumPricePerMonth,
|
|
10638
|
-
linearCost
|
|
10639
|
-
};
|
|
10640
|
-
}, getUSDfcBalance_abi = {
|
|
10641
|
-
constant: !0,
|
|
10642
10709
|
inputs: [
|
|
10643
10710
|
{
|
|
10644
|
-
name: '
|
|
10711
|
+
name: 'token',
|
|
10712
|
+
internalType: 'contract IERC20',
|
|
10713
|
+
type: 'address'
|
|
10714
|
+
},
|
|
10715
|
+
{
|
|
10716
|
+
name: 'client',
|
|
10717
|
+
internalType: 'address',
|
|
10718
|
+
type: 'address'
|
|
10719
|
+
},
|
|
10720
|
+
{
|
|
10721
|
+
name: 'operator',
|
|
10722
|
+
internalType: 'address',
|
|
10645
10723
|
type: 'address'
|
|
10646
10724
|
}
|
|
10647
10725
|
],
|
|
10648
|
-
name: '
|
|
10726
|
+
name: 'operatorApprovals',
|
|
10649
10727
|
outputs: [
|
|
10650
10728
|
{
|
|
10651
|
-
name: '',
|
|
10729
|
+
name: 'isApproved',
|
|
10730
|
+
type: 'bool'
|
|
10731
|
+
},
|
|
10732
|
+
{
|
|
10733
|
+
name: 'rateAllowance',
|
|
10734
|
+
type: 'uint256'
|
|
10735
|
+
},
|
|
10736
|
+
{
|
|
10737
|
+
name: 'lockupAllowance',
|
|
10738
|
+
type: 'uint256'
|
|
10739
|
+
},
|
|
10740
|
+
{
|
|
10741
|
+
name: 'rateUsage',
|
|
10742
|
+
type: 'uint256'
|
|
10743
|
+
},
|
|
10744
|
+
{
|
|
10745
|
+
name: 'lockupUsage',
|
|
10746
|
+
type: 'uint256'
|
|
10747
|
+
},
|
|
10748
|
+
{
|
|
10749
|
+
name: 'maxLockupPeriod',
|
|
10652
10750
|
type: 'uint256'
|
|
10653
10751
|
}
|
|
10654
10752
|
],
|
|
10655
|
-
|
|
10656
|
-
|
|
10657
|
-
|
|
10658
|
-
}, getUSDfcBalance = async ({ address, chain })=>{
|
|
10659
|
-
let provider = constants_filProvider[chain.id], result = await provider.request({
|
|
10753
|
+
stateMutability: 'view'
|
|
10754
|
+
}, isFwssMaxApproved = async (options)=>{
|
|
10755
|
+
let { clientAddress, chain } = options, provider = constants_filProvider[chain.id], token = options.token ?? chain.contracts.usdfc.address, result = await provider.request({
|
|
10660
10756
|
method: 'eth_call',
|
|
10661
10757
|
params: [
|
|
10662
10758
|
{
|
|
10663
|
-
data: AbiFunction_encodeData(
|
|
10664
|
-
|
|
10759
|
+
data: AbiFunction_encodeData(is_fwss_max_approved_abi, [
|
|
10760
|
+
token,
|
|
10761
|
+
clientAddress,
|
|
10762
|
+
chain.contracts.storage.address
|
|
10665
10763
|
]),
|
|
10666
|
-
to: chain.contracts.
|
|
10764
|
+
to: chain.contracts.payments.address
|
|
10667
10765
|
},
|
|
10668
10766
|
'latest'
|
|
10669
10767
|
]
|
|
10670
|
-
});
|
|
10671
|
-
return
|
|
10768
|
+
}), [isApproved, rateAllowance, lockupAllowance] = AbiFunction_decodeResult(is_fwss_max_approved_abi, result);
|
|
10769
|
+
return isApproved && rateAllowance === maxUint256 && lockupAllowance === maxUint256;
|
|
10672
10770
|
}, uploadPiece = async ({ providerURL, pieceCid, bytes })=>{
|
|
10673
10771
|
let res = await fetch(new URL('/pdp/piece', providerURL), {
|
|
10674
10772
|
method: 'POST',
|
|
@@ -11685,7 +11783,182 @@ class cid_CID {
|
|
|
11685
11783
|
return cid_baseCache(cid).set(prefix, source), cid;
|
|
11686
11784
|
}
|
|
11687
11785
|
}
|
|
11688
|
-
let DAG_PB_CODE = 0x70, SHA_256_CODE = 0x12, cidSymbol = Symbol.for('@ipld/js-cid/CID'), link_DAG_PB_CODE = 0x70, varint_0 = __webpack_require__("./node_modules/varint/index.js"), calculatePieceCID_FR_RATIO = 254 / 256, MIN_PAYLOAD_SIZE = 127,
|
|
11786
|
+
let DAG_PB_CODE = 0x70, SHA_256_CODE = 0x12, cidSymbol = Symbol.for('@ipld/js-cid/CID'), link_DAG_PB_CODE = 0x70, varint_0 = __webpack_require__("./node_modules/varint/index.js"), calculatePieceCID_FR_RATIO = 254 / 256, MIN_PAYLOAD_SIZE = 127, calculateEffectiveRate = (params)=>{
|
|
11787
|
+
let { sizeInBytes, pricePerTiBPerMonth, minimumPricePerMonth, epochsPerMonth } = params, naturalPerMonth = pricePerTiBPerMonth * sizeInBytes / SIZE_CONSTANTS.TiB, naturalPerEpoch = pricePerTiBPerMonth * sizeInBytes / (SIZE_CONSTANTS.TiB * epochsPerMonth), minimumPerEpoch = minimumPricePerMonth / epochsPerMonth;
|
|
11788
|
+
return {
|
|
11789
|
+
ratePerEpoch: naturalPerEpoch > minimumPerEpoch ? naturalPerEpoch : minimumPerEpoch,
|
|
11790
|
+
ratePerMonth: naturalPerMonth > minimumPricePerMonth ? naturalPerMonth : minimumPricePerMonth
|
|
11791
|
+
};
|
|
11792
|
+
}, get_service_pricing_abi = {
|
|
11793
|
+
type: 'function',
|
|
11794
|
+
inputs: [],
|
|
11795
|
+
name: 'getServicePrice',
|
|
11796
|
+
outputs: [
|
|
11797
|
+
{
|
|
11798
|
+
name: 'pricing',
|
|
11799
|
+
internalType: 'struct FilecoinWarmStorageService.ServicePricing',
|
|
11800
|
+
type: 'tuple',
|
|
11801
|
+
components: [
|
|
11802
|
+
{
|
|
11803
|
+
name: 'pricePerTiBPerMonthNoCDN',
|
|
11804
|
+
internalType: 'uint256',
|
|
11805
|
+
type: 'uint256'
|
|
11806
|
+
},
|
|
11807
|
+
{
|
|
11808
|
+
name: 'pricePerTiBCdnEgress',
|
|
11809
|
+
internalType: 'uint256',
|
|
11810
|
+
type: 'uint256'
|
|
11811
|
+
},
|
|
11812
|
+
{
|
|
11813
|
+
name: 'pricePerTiBCacheMissEgress',
|
|
11814
|
+
internalType: 'uint256',
|
|
11815
|
+
type: 'uint256'
|
|
11816
|
+
},
|
|
11817
|
+
{
|
|
11818
|
+
name: 'tokenAddress',
|
|
11819
|
+
internalType: 'contract IERC20',
|
|
11820
|
+
type: 'address'
|
|
11821
|
+
},
|
|
11822
|
+
{
|
|
11823
|
+
name: 'epochsPerMonth',
|
|
11824
|
+
internalType: 'uint256',
|
|
11825
|
+
type: 'uint256'
|
|
11826
|
+
},
|
|
11827
|
+
{
|
|
11828
|
+
name: 'minimumPricePerMonth',
|
|
11829
|
+
internalType: 'uint256',
|
|
11830
|
+
type: 'uint256'
|
|
11831
|
+
}
|
|
11832
|
+
]
|
|
11833
|
+
}
|
|
11834
|
+
],
|
|
11835
|
+
stateMutability: 'view'
|
|
11836
|
+
}, getServicePricing = async ({ chain })=>{
|
|
11837
|
+
let provider = constants_filProvider[chain.id], result = await provider.request({
|
|
11838
|
+
method: 'eth_call',
|
|
11839
|
+
params: [
|
|
11840
|
+
{
|
|
11841
|
+
to: chain.contracts.storage.address,
|
|
11842
|
+
data: AbiFunction_encodeData(get_service_pricing_abi)
|
|
11843
|
+
},
|
|
11844
|
+
'latest'
|
|
11845
|
+
]
|
|
11846
|
+
});
|
|
11847
|
+
return AbiFunction_decodeResult(get_service_pricing_abi, result);
|
|
11848
|
+
}, getUploadCosts = async (options)=>{
|
|
11849
|
+
var params;
|
|
11850
|
+
let lockup, netRateAfterUpload, extraRunwayEpochs, bufferEpochs, runway, rawDepositNeeded, buffer, isNewDataSet = options.isNewDataSet ?? !0, currentDataSetSize = options.currentDataSetSize ?? 0n, extraRunwayEpochs1 = options.extraRunwayEpochs ?? 0n, bufferEpochs1 = options.bufferEpochs ?? 5n, provider = constants_filProvider[options.chain.id], [accountInfo, pricing, approved, currentEpochHex] = await Promise.all([
|
|
11851
|
+
accounts_accounts({
|
|
11852
|
+
address: options.clientAddress,
|
|
11853
|
+
chain: options.chain
|
|
11854
|
+
}),
|
|
11855
|
+
getServicePricing({
|
|
11856
|
+
chain: options.chain
|
|
11857
|
+
}),
|
|
11858
|
+
isFwssMaxApproved({
|
|
11859
|
+
clientAddress: options.clientAddress,
|
|
11860
|
+
chain: options.chain
|
|
11861
|
+
}),
|
|
11862
|
+
provider.request({
|
|
11863
|
+
method: 'eth_blockNumber'
|
|
11864
|
+
})
|
|
11865
|
+
]), currentEpoch = BigInt(currentEpochHex), rate = calculateEffectiveRate({
|
|
11866
|
+
sizeInBytes: currentDataSetSize + options.dataSize,
|
|
11867
|
+
pricePerTiBPerMonth: pricing.pricePerTiBPerMonthNoCDN,
|
|
11868
|
+
minimumPricePerMonth: pricing.minimumPricePerMonth,
|
|
11869
|
+
epochsPerMonth: pricing.epochsPerMonth
|
|
11870
|
+
}), accountParams = {
|
|
11871
|
+
funds: accountInfo.funds,
|
|
11872
|
+
lockupCurrent: accountInfo.lockupCurrent,
|
|
11873
|
+
lockupRate: accountInfo.lockupRate,
|
|
11874
|
+
lockupLastSettledAt: accountInfo.lockupLastSettledAt,
|
|
11875
|
+
currentEpoch
|
|
11876
|
+
}, debt = ((params)=>{
|
|
11877
|
+
let { funds, lockupCurrent, lockupRate, lockupLastSettledAt, currentEpoch } = params, totalOwed = lockupCurrent + lockupRate * (currentEpoch > lockupLastSettledAt ? currentEpoch - lockupLastSettledAt : 0n);
|
|
11878
|
+
return totalOwed > funds ? totalOwed - funds : 0n;
|
|
11879
|
+
})(accountParams), { availableFunds, fundedUntilEpoch } = ((params)=>{
|
|
11880
|
+
let { funds, lockupCurrent, lockupRate, lockupLastSettledAt, currentEpoch } = params, fundedUntilEpoch = 0n === lockupRate ? 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn : lockupLastSettledAt + (funds - lockupCurrent) / lockupRate, simulatedSettledAt = fundedUntilEpoch < currentEpoch ? fundedUntilEpoch : currentEpoch, simulatedLockupCurrent = lockupCurrent + lockupRate * (simulatedSettledAt > lockupLastSettledAt ? simulatedSettledAt - lockupLastSettledAt : 0n);
|
|
11881
|
+
return {
|
|
11882
|
+
fundedUntilEpoch,
|
|
11883
|
+
availableFunds: funds > simulatedLockupCurrent ? funds - simulatedLockupCurrent : 0n
|
|
11884
|
+
};
|
|
11885
|
+
})(accountParams), depositNeeded = (lockup = ((params)=>{
|
|
11886
|
+
let rateDeltaPerEpoch, { dataSize, currentDataSetSize, pricePerTiBPerMonth, minimumPricePerMonth, epochsPerMonth = 86400n, lockupEpochs = LOCKUP_PERIOD, isNewDataSet } = params, rateParams = {
|
|
11887
|
+
pricePerTiBPerMonth,
|
|
11888
|
+
minimumPricePerMonth,
|
|
11889
|
+
epochsPerMonth
|
|
11890
|
+
};
|
|
11891
|
+
if (currentDataSetSize > 0n && !isNewDataSet) {
|
|
11892
|
+
let newRate = calculateEffectiveRate({
|
|
11893
|
+
...rateParams,
|
|
11894
|
+
sizeInBytes: currentDataSetSize + dataSize
|
|
11895
|
+
}), currentRate = calculateEffectiveRate({
|
|
11896
|
+
...rateParams,
|
|
11897
|
+
sizeInBytes: currentDataSetSize
|
|
11898
|
+
});
|
|
11899
|
+
(rateDeltaPerEpoch = newRate.ratePerEpoch - currentRate.ratePerEpoch) < 0n && (rateDeltaPerEpoch = 0n);
|
|
11900
|
+
} else rateDeltaPerEpoch = calculateEffectiveRate({
|
|
11901
|
+
...rateParams,
|
|
11902
|
+
sizeInBytes: dataSize
|
|
11903
|
+
}).ratePerEpoch;
|
|
11904
|
+
let rateLockupDelta = rateDeltaPerEpoch * lockupEpochs, sybilFee = isNewDataSet ? 100000000000000000n : 0n;
|
|
11905
|
+
return {
|
|
11906
|
+
rateDeltaPerEpoch,
|
|
11907
|
+
rateLockupDelta,
|
|
11908
|
+
sybilFee,
|
|
11909
|
+
total: rateLockupDelta + sybilFee
|
|
11910
|
+
};
|
|
11911
|
+
})({
|
|
11912
|
+
dataSize: (params = {
|
|
11913
|
+
dataSize: options.dataSize,
|
|
11914
|
+
currentDataSetSize,
|
|
11915
|
+
pricePerTiBPerMonth: pricing.pricePerTiBPerMonthNoCDN,
|
|
11916
|
+
minimumPricePerMonth: pricing.minimumPricePerMonth,
|
|
11917
|
+
epochsPerMonth: pricing.epochsPerMonth,
|
|
11918
|
+
lockupEpochs: LOCKUP_PERIOD,
|
|
11919
|
+
isNewDataSet,
|
|
11920
|
+
currentLockupRate: accountInfo.lockupRate,
|
|
11921
|
+
extraRunwayEpochs: extraRunwayEpochs1,
|
|
11922
|
+
debt,
|
|
11923
|
+
availableFunds,
|
|
11924
|
+
fundedUntilEpoch,
|
|
11925
|
+
currentEpoch,
|
|
11926
|
+
bufferEpochs: bufferEpochs1
|
|
11927
|
+
}).dataSize,
|
|
11928
|
+
currentDataSetSize: params.currentDataSetSize,
|
|
11929
|
+
pricePerTiBPerMonth: params.pricePerTiBPerMonth,
|
|
11930
|
+
minimumPricePerMonth: params.minimumPricePerMonth,
|
|
11931
|
+
epochsPerMonth: params.epochsPerMonth,
|
|
11932
|
+
lockupEpochs: params.lockupEpochs,
|
|
11933
|
+
isNewDataSet: params.isNewDataSet
|
|
11934
|
+
}), netRateAfterUpload = params.currentLockupRate + lockup.rateDeltaPerEpoch, extraRunwayEpochs = params.extraRunwayEpochs ?? 0n, bufferEpochs = params.bufferEpochs ?? 5n, runway = (({ netRateAfterUpload, extraRunwayEpochs })=>netRateAfterUpload * extraRunwayEpochs)({
|
|
11935
|
+
netRateAfterUpload,
|
|
11936
|
+
extraRunwayEpochs
|
|
11937
|
+
}), rawDepositNeeded = lockup.total + runway + params.debt - params.availableFunds, buffer = 0n === params.currentLockupRate && params.isNewDataSet ? 0n : (({ rawDepositNeeded, netRateAfterUpload, fundedUntilEpoch, currentEpoch, availableFunds, bufferEpochs })=>{
|
|
11938
|
+
if (rawDepositNeeded > 0n) return netRateAfterUpload * bufferEpochs;
|
|
11939
|
+
if (fundedUntilEpoch <= currentEpoch + bufferEpochs) {
|
|
11940
|
+
let needed = netRateAfterUpload * bufferEpochs - availableFunds;
|
|
11941
|
+
return needed > 0n ? needed : 0n;
|
|
11942
|
+
}
|
|
11943
|
+
return 0n;
|
|
11944
|
+
})({
|
|
11945
|
+
rawDepositNeeded,
|
|
11946
|
+
netRateAfterUpload,
|
|
11947
|
+
fundedUntilEpoch: params.fundedUntilEpoch,
|
|
11948
|
+
currentEpoch: params.currentEpoch,
|
|
11949
|
+
availableFunds: params.availableFunds,
|
|
11950
|
+
bufferEpochs
|
|
11951
|
+
}), (rawDepositNeeded > 0n ? rawDepositNeeded : 0n) + buffer), needsFwssMaxApproval = !approved;
|
|
11952
|
+
return {
|
|
11953
|
+
rate: {
|
|
11954
|
+
perEpoch: rate.ratePerEpoch,
|
|
11955
|
+
perMonth: rate.ratePerMonth
|
|
11956
|
+
},
|
|
11957
|
+
depositNeeded,
|
|
11958
|
+
needsFwssMaxApproval,
|
|
11959
|
+
ready: 0n === depositNeeded && !needsFwssMaxApproval
|
|
11960
|
+
};
|
|
11961
|
+
}, fromRpcStatus = {
|
|
11689
11962
|
'0x0': 'reverted',
|
|
11690
11963
|
'0x1': 'success'
|
|
11691
11964
|
}, fromRpcType = {
|
|
@@ -11968,7 +12241,7 @@ let serializedType = '0x02', TxEnvelopeEip1559_type = 'eip1559', SIMULATION_GAS_
|
|
|
11968
12241
|
address,
|
|
11969
12242
|
chain
|
|
11970
12243
|
});
|
|
11971
|
-
verbose && (logger.info(`Payer address: ${address}`), logger.info(`Filecoin chain: ${chain.name}`), logger.info(`USDfc balance: ${Value_format(balance, 18)}`), logger.info('Looking up existing data sets'));
|
|
12244
|
+
verbose && (logger.info(`Payer address: ${address}`), logger.info(`Filecoin chain: ${chain.name}`), logger.info(`Wallet USDfc balance: ${Value_format(balance, 18)}`), logger.info('Looking up existing data sets'));
|
|
11972
12245
|
let providerId = await pickProvider({
|
|
11973
12246
|
chain,
|
|
11974
12247
|
...providerAddress ? {
|
|
@@ -11989,11 +12262,6 @@ let serializedType = '0x02', TxEnvelopeEip1559_type = 'eip1559', SIMULATION_GAS_
|
|
|
11989
12262
|
chain
|
|
11990
12263
|
});
|
|
11991
12264
|
verbose && logger.info(`Filecoin SP Payee: ${payee}`);
|
|
11992
|
-
let { perMonth } = await getServicePrice({
|
|
11993
|
-
size,
|
|
11994
|
-
chain
|
|
11995
|
-
});
|
|
11996
|
-
logger.info(`Price for storage: ${Value_format(perMonth, 18)} USDfc/month`);
|
|
11997
12265
|
let pieceCid = link_create(raw_code, digest_create(0x1011, function(data) {
|
|
11998
12266
|
let fr32 = function(source) {
|
|
11999
12267
|
let output = new Uint8Array(Math.floor(toZeroPaddedSize(source.length) / calculatePieceCID_FR_RATIO)), quadCount = toZeroPaddedSize(source.length) / 127;
|
|
@@ -12053,22 +12321,23 @@ let serializedType = '0x02', TxEnvelopeEip1559_type = 'eip1559', SIMULATION_GAS_
|
|
|
12053
12321
|
}(bytes))), providerActiveDataSets = (await getClientDataSets({
|
|
12054
12322
|
chain,
|
|
12055
12323
|
address
|
|
12056
|
-
})).filter((ds)=>ds.providerId === providerId && 0n === ds.pdpEndEpoch), isNewDataSet = 0 === providerActiveDataSets.length || filecoinForceNewDataset,
|
|
12057
|
-
|
|
12058
|
-
|
|
12059
|
-
|
|
12324
|
+
})).filter((ds)=>ds.providerId === providerId && 0n === ds.pdpEndEpoch), isNewDataSet = 0 === providerActiveDataSets.length || filecoinForceNewDataset, costs = await getUploadCosts({
|
|
12325
|
+
clientAddress: address,
|
|
12326
|
+
dataSize: BigInt(size),
|
|
12327
|
+
isNewDataSet,
|
|
12060
12328
|
chain
|
|
12061
|
-
})
|
|
12062
|
-
|
|
12063
|
-
|
|
12064
|
-
|
|
12065
|
-
|
|
12066
|
-
|
|
12067
|
-
|
|
12068
|
-
|
|
12329
|
+
});
|
|
12330
|
+
if (logger.info(`Price for storage: ${Value_format(costs.rate.perMonth, 18)} USDfc/month`), verbose && (logger.info(`Storage price: ${Value_format(costs.rate.perMonth, 18)} USDFC/month`), logger.info(`Required deposit: ${Value_format(costs.depositNeeded, 18)} USDFC`), logger.info(`FWSS max-approved: ${costs.needsFwssMaxApproval ? 'no' : 'yes'}`)), costs.depositNeeded > 0n) {
|
|
12331
|
+
verbose && logger.info(`Depositing ${Value_format(costs.depositNeeded, 18)} USDFC`);
|
|
12332
|
+
let params = costs.needsFwssMaxApproval ? await depositWithPermitAndApproveOperatorWriteParameters({
|
|
12333
|
+
privateKey,
|
|
12334
|
+
address,
|
|
12335
|
+
amount: costs.depositNeeded,
|
|
12336
|
+
chain
|
|
12337
|
+
}) : await depositWithPermitWriteParameters({
|
|
12069
12338
|
privateKey,
|
|
12070
12339
|
address,
|
|
12071
|
-
amount: depositNeeded,
|
|
12340
|
+
amount: costs.depositNeeded,
|
|
12072
12341
|
chain
|
|
12073
12342
|
});
|
|
12074
12343
|
await simulateTransaction(params);
|
|
@@ -12078,7 +12347,7 @@ let serializedType = '0x02', TxEnvelopeEip1559_type = 'eip1559', SIMULATION_GAS_
|
|
|
12078
12347
|
privateKey
|
|
12079
12348
|
});
|
|
12080
12349
|
verbose && logger.info(`Deposit transaction: ${hash}`), await waitForTransaction(constants_filProvider[chain.id], hash), logger.success('Deposit confirmed');
|
|
12081
|
-
} else logger.info('Sufficient funds available, no deposit needed');
|
|
12350
|
+
} else costs.needsFwssMaxApproval ? logger.info('Operator approval needed but no deposit; skipping (no-op).') : logger.info('Sufficient funds available, no deposit needed');
|
|
12082
12351
|
let nonce = BigInt(randomInt(100000000));
|
|
12083
12352
|
if (isNewDataSet) {
|
|
12084
12353
|
logger.info('Creating new data set'), verbose && logger.info('Uploading piece to provider'), await uploadPiece({
|
|
@@ -17708,7 +17977,7 @@ let uploadCAR = async (conf, car)=>{
|
|
|
17708
17977
|
return multihash = digest_create(0x1b, function(hex, options = {}) {
|
|
17709
17978
|
return fromHex(hex, options);
|
|
17710
17979
|
}(ref)).bytes, bytes = new Uint8Array((hashOffset = (codeOffset = varint_0.encodingLength(1)) + varint_0.encodingLength(0xfa)) + multihash.byteLength), varint_0.encode(1, bytes, 0), varint_0.encode(0xfa, bytes, codeOffset), bytes.set(multihash, hashOffset), bytes;
|
|
17711
|
-
}, swarmy_providerName = 'Swarmy', PROVIDERS = {
|
|
17980
|
+
}, referenceToCIDString = (ref)=>base32.encode(referenceToCID(ref)), swarmy_providerName = 'Swarmy', PROVIDERS = {
|
|
17712
17981
|
STORACHA_TOKEN: {
|
|
17713
17982
|
name: 'Storacha',
|
|
17714
17983
|
upload: async ({ token, bytes, proof })=>{
|
|
@@ -17810,7 +18079,7 @@ let uploadCAR = async (conf, car)=>{
|
|
|
17810
18079
|
}), json = await res.json();
|
|
17811
18080
|
if (verbose && logger.request('POST', res.url, res.status), !res.ok) throw new DeployError(swarmy_providerName, json.message);
|
|
17812
18081
|
return {
|
|
17813
|
-
cid:
|
|
18082
|
+
cid: referenceToCIDString(`0x${json.swarmReference}`),
|
|
17814
18083
|
rID: json.swarmReference
|
|
17815
18084
|
};
|
|
17816
18085
|
},
|
|
@@ -17836,7 +18105,7 @@ let uploadCAR = async (conf, car)=>{
|
|
|
17836
18105
|
}), json = await res.json();
|
|
17837
18106
|
if (verbose && logger.request('POST', res.url, res.status), !res.ok) throw new DeployError('Bee', json.message);
|
|
17838
18107
|
return {
|
|
17839
|
-
cid:
|
|
18108
|
+
cid: referenceToCIDString(`0x${json.reference}`),
|
|
17840
18109
|
rID: json.reference
|
|
17841
18110
|
};
|
|
17842
18111
|
},
|
|
@@ -21189,7 +21458,7 @@ let ENS_DEPLOYER_ROLE = keccak256(Bytes_fromString('ENS_DEPLOYER')), execTransac
|
|
|
21189
21458
|
let browserLink = `https://${domain}.limo`;
|
|
21190
21459
|
logger.info(`Open in a browser: ${isTTY ? styleText('underline', browserLink) : browserLink}`);
|
|
21191
21460
|
}
|
|
21192
|
-
}, packTAR = async (files)=>{
|
|
21461
|
+
}, tar_tmp = tmpdir(), packTAR = async (files, name, dir = tar_tmp)=>{
|
|
21193
21462
|
let entries = [];
|
|
21194
21463
|
for (let { path, content } of files){
|
|
21195
21464
|
let chunks = [], totalLength = 0;
|
|
@@ -21201,7 +21470,7 @@ let ENS_DEPLOYER_ROLE = keccak256(Bytes_fromString('ENS_DEPLOYER')), execTransac
|
|
|
21201
21470
|
data: fileData
|
|
21202
21471
|
});
|
|
21203
21472
|
}
|
|
21204
|
-
|
|
21473
|
+
let bytes = function(files, opts = {}) {
|
|
21205
21474
|
let _files = files.map((file)=>{
|
|
21206
21475
|
let data = function(data) {
|
|
21207
21476
|
if (null != data) return "string" == typeof data ? new TextEncoder().encode(data) : data instanceof ArrayBuffer ? new Uint8Array(data) : data;
|
|
@@ -21233,6 +21502,15 @@ let ENS_DEPLOYER_ROLE = keccak256(Bytes_fromString('ENS_DEPLOYER')), execTransac
|
|
|
21233
21502
|
}
|
|
21234
21503
|
return new Uint8Array(buffer);
|
|
21235
21504
|
}(entries);
|
|
21505
|
+
if (!name) return {
|
|
21506
|
+
bytes,
|
|
21507
|
+
output: null
|
|
21508
|
+
};
|
|
21509
|
+
let output = `${dir}/${name}.tar`;
|
|
21510
|
+
return await writeFile(output, bytes), {
|
|
21511
|
+
bytes,
|
|
21512
|
+
output
|
|
21513
|
+
};
|
|
21236
21514
|
}, packAction = async ({ dir, options = {} })=>{
|
|
21237
21515
|
let { name: customName, dist, verbose, 'only-hash': onlyHash, tar } = options;
|
|
21238
21516
|
dir || (dir = await exists('dist') ? 'dist' : await exists('.vitepress/dist') ? '.vitepress/dist' : '.');
|
|
@@ -21242,20 +21520,23 @@ let ENS_DEPLOYER_ROLE = keccak256(Bytes_fromString('ENS_DEPLOYER')), execTransac
|
|
|
21242
21520
|
'.',
|
|
21243
21521
|
'dist'
|
|
21244
21522
|
].includes(dir) ? name : dir;
|
|
21245
|
-
if (onlyHash || logger.start(`Packing ${isTTY ? styleText('cyan', distName) : distName} (${fileSize(size, 2)})`), tar)
|
|
21246
|
-
bytes
|
|
21247
|
-
|
|
21248
|
-
};
|
|
21249
|
-
{
|
|
21250
|
-
let { rootCID, bytes } = await packCAR(files, name, dist), cid = rootCID.toString();
|
|
21251
|
-
return onlyHash ? console.log(cid) : logger.info(`Root CID: ${isTTY ? styleText('white', cid) : cid}`), {
|
|
21523
|
+
if (onlyHash || logger.start(`Packing ${isTTY ? styleText('cyan', distName) : distName} (${fileSize(size, 2)})`), tar) {
|
|
21524
|
+
let { bytes, output } = await packTAR(files, name, dist);
|
|
21525
|
+
return !onlyHash && output && logger.info(`TAR: ${isTTY ? styleText('white', output) : output}`), {
|
|
21252
21526
|
name,
|
|
21253
|
-
cid,
|
|
21254
21527
|
bytes,
|
|
21255
21528
|
files,
|
|
21256
21529
|
size
|
|
21257
21530
|
};
|
|
21258
21531
|
}
|
|
21532
|
+
let { rootCID, bytes } = await packCAR(files, name, dist), cid = rootCID.toString();
|
|
21533
|
+
return onlyHash ? console.log(cid) : logger.info(`Root CID: ${isTTY ? styleText('white', cid) : cid}`), {
|
|
21534
|
+
name,
|
|
21535
|
+
cid,
|
|
21536
|
+
bytes,
|
|
21537
|
+
files,
|
|
21538
|
+
size
|
|
21539
|
+
};
|
|
21259
21540
|
}, deployAction = async ({ dir, options = {} })=>{
|
|
21260
21541
|
let cid, { strict, ens, chain = 'mainnet', name: customName, dist, verbose = !1, providers: providersList, dnslink, 'progress-bar': progressBar, 'filecoin-chain': filecoinChain, 'filecoin-force-new-dataset': filecoinForceNewDataset, ...opts } = options, apiTokens = parseTokensFromEnv(), allProviders = (providersList ? providersList.split(',') : tokensToProviderNames(apiTokens.keys())).map((providerName)=>PROVIDERS[findEnvVarProviderName(providerName)]), ipfsProviders = allProviders.filter((p)=>'ipfs' === p.protocol), swarmProviders = allProviders.filter((p)=>'swarm' === p.protocol);
|
|
21261
21542
|
if (ipfsProviders.sort((a)=>'both' === a.supported || 'upload' === a.supported ? -1 : 1), !allProviders.length) throw new NoProvidersError();
|
|
@@ -21800,9 +22081,15 @@ cli_cli.command('deploy', ([dir], options)=>deployAction({
|
|
|
21800
22081
|
description: 'More verbose logs',
|
|
21801
22082
|
type: 'boolean',
|
|
21802
22083
|
short: 'v'
|
|
22084
|
+
},
|
|
22085
|
+
{
|
|
22086
|
+
name: 'tar',
|
|
22087
|
+
description: 'Pack as a TAR archive (for Swarm) instead of a CAR',
|
|
22088
|
+
type: 'boolean',
|
|
22089
|
+
short: 't'
|
|
21803
22090
|
}
|
|
21804
22091
|
],
|
|
21805
|
-
description: 'Pack websites files into a CAR without uploading it anywhere'
|
|
22092
|
+
description: 'Pack websites files into a CAR (or TAR with --tar) without uploading it anywhere'
|
|
21806
22093
|
}), cli_cli.command('pin', ([cid], options)=>pinAction({
|
|
21807
22094
|
cid,
|
|
21808
22095
|
options
|
package/package.json
CHANGED
|
@@ -1,79 +1,81 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
2
|
+
"name": "omnipin",
|
|
3
|
+
"version": "2.2.4",
|
|
4
|
+
"author": "v1rtl <hi@v1rtl.site>",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/omnipin/omnipin.git"
|
|
8
|
+
},
|
|
9
|
+
"devDependencies": {
|
|
10
|
+
"@biomejs/biome": "^2.4.7",
|
|
11
|
+
"@ipld/car": "^5.4.2",
|
|
12
|
+
"@ipld/dag-ucan": "^3.4.5",
|
|
13
|
+
"@omnipin/foc": "npm:@jsr/omnipin__foc@0.0.14",
|
|
14
|
+
"@rslib/core": "^0.20.0",
|
|
15
|
+
"@size-limit/file": "^12.0.1",
|
|
16
|
+
"@stauro/filebase-upload": "npm:@jsr/stauro__filebase-upload",
|
|
17
|
+
"@storacha/capabilities": "^2.3.0",
|
|
18
|
+
"@types/bun": "^1.3.10",
|
|
19
|
+
"@types/varint": "^6.0.3",
|
|
20
|
+
"@ucanto/client": "^9.0.2",
|
|
21
|
+
"@ucanto/core": "^10.4.6",
|
|
22
|
+
"@ucanto/principal": "^9.0.3",
|
|
23
|
+
"@ucanto/transport": "^9.2.1",
|
|
24
|
+
"@web3-storage/data-segment": "^5.3.0",
|
|
25
|
+
"cborg": "^4.5.8",
|
|
26
|
+
"ipfs-unixfs-importer": "^16.1.4",
|
|
27
|
+
"multiformats": "13.4.2",
|
|
28
|
+
"nanotar": "^0.3.0",
|
|
29
|
+
"ox": "^0.14.8",
|
|
30
|
+
"prool": "^0.2.4",
|
|
31
|
+
"size-limit": "^12.0.1",
|
|
32
|
+
"spektr": "^0.2.0",
|
|
33
|
+
"tinyglobby": "^0.2.15",
|
|
34
|
+
"typescript": "^5.9.3",
|
|
35
|
+
"varint": "^6.0.0",
|
|
36
|
+
"vitepress": "^1.6.4"
|
|
37
|
+
},
|
|
38
|
+
"bin": {
|
|
39
|
+
"omnipin": "dist/index.js"
|
|
40
|
+
},
|
|
41
|
+
"description": "🌸 Self-custodial decentralized deployments",
|
|
42
|
+
"engineStrict": true,
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": "^20.10.0 || >=21.1.0"
|
|
45
|
+
},
|
|
46
|
+
"files": [
|
|
47
|
+
"dist"
|
|
48
|
+
],
|
|
49
|
+
"homepage": "https://github.com/omnipin/omnipin",
|
|
50
|
+
"keywords": [
|
|
51
|
+
"ipfs",
|
|
52
|
+
"filecoin",
|
|
53
|
+
"deploy",
|
|
54
|
+
"cli"
|
|
55
|
+
],
|
|
56
|
+
"license": "MIT",
|
|
57
|
+
"overrides": {
|
|
58
|
+
"multiformats": "13.4.2"
|
|
59
|
+
},
|
|
60
|
+
"release": {
|
|
61
|
+
"branches": [
|
|
62
|
+
"main"
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
"scripts": {
|
|
66
|
+
"build": "rslib",
|
|
67
|
+
"prepublishOnly": "bun run build && bun size-limit",
|
|
68
|
+
"check": "biome check",
|
|
69
|
+
"types": "tsc --noEmit",
|
|
70
|
+
"test:report": "bun test test/ --coverage --coverage-reporter=lcov --coverage-dir=coverage",
|
|
71
|
+
"test:e2e": "bun test e2e/"
|
|
72
|
+
},
|
|
73
|
+
"size-limit": [
|
|
74
|
+
{
|
|
75
|
+
"path": "dist/index.js",
|
|
76
|
+
"limit": "1MB",
|
|
77
|
+
"brotli": false
|
|
78
|
+
}
|
|
79
|
+
],
|
|
80
|
+
"type": "module"
|
|
79
81
|
}
|