omnipin 2.2.2 → 2.2.3

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.
Files changed (2) hide show
  1. package/dist/index.js +151 -11
  2. package/package.json +2 -2
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: '0x638a4986332bF9B889E5D7435B966C5ecdE077Fa'
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: '0x53d235D474585EC102ccaB7e0cdcE951dD00f716'
10149
+ address: '0x537320bd004a7FDd3c1932ca64BD88268301322A'
10144
10150
  }
10145
10151
  },
10146
10152
  blockExplorer: 'https://filecoin-testnet.blockscout.com'
@@ -10576,6 +10582,140 @@ let getClientDatasets_abi = {
10576
10582
  ]
10577
10583
  });
10578
10584
  return AbiFunction_decodeResult(getAccountInfo_abi, result);
10585
+ }, getAvailableFunds = async ({ address, chain })=>{
10586
+ let [funds, lockupCurrent, lockupRate, lockupLastSettledAt] = await getAccountInfo({
10587
+ address,
10588
+ chain
10589
+ }), currentEpoch = BigInt(await constants_filProvider[chain.id].request({
10590
+ method: 'eth_blockNumber'
10591
+ })), epochsSinceSettlement = currentEpoch > lockupLastSettledAt ? currentEpoch - lockupLastSettledAt : 0n, settledLockupCurrent = lockupCurrent + epochsSinceSettlement * lockupRate;
10592
+ return {
10593
+ funds,
10594
+ lockupCurrent,
10595
+ lockupRate,
10596
+ lockupLastSettledAt,
10597
+ currentEpoch,
10598
+ epochsSinceSettlement,
10599
+ settledLockupCurrent,
10600
+ availableFunds: funds > settledLockupCurrent ? funds - settledLockupCurrent : 0n
10601
+ };
10602
+ }, DEFAULT_LOCKUP_PERIOD = 30n * 2880n, serviceAbi = [
10603
+ {
10604
+ type: 'function',
10605
+ name: 'getServicePrice',
10606
+ inputs: [],
10607
+ outputs: [
10608
+ {
10609
+ name: 'pricing',
10610
+ internalType: 'struct FilecoinWarmStorageService.ServicePricing',
10611
+ type: 'tuple',
10612
+ components: [
10613
+ {
10614
+ name: 'pricePerTiBPerMonthNoCDN',
10615
+ internalType: 'uint256',
10616
+ type: 'uint256'
10617
+ },
10618
+ {
10619
+ name: 'pricePerTiBCdnEgress',
10620
+ internalType: 'uint256',
10621
+ type: 'uint256'
10622
+ },
10623
+ {
10624
+ name: 'pricePerTiBCacheMissEgress',
10625
+ internalType: 'uint256',
10626
+ type: 'uint256'
10627
+ },
10628
+ {
10629
+ name: 'tokenAddress',
10630
+ internalType: 'contract IERC20',
10631
+ type: 'address'
10632
+ },
10633
+ {
10634
+ name: 'epochsPerMonth',
10635
+ internalType: 'uint256',
10636
+ type: 'uint256'
10637
+ },
10638
+ {
10639
+ name: 'minimumPricePerMonth',
10640
+ internalType: 'uint256',
10641
+ type: 'uint256'
10642
+ }
10643
+ ]
10644
+ }
10645
+ ],
10646
+ stateMutability: 'view'
10647
+ },
10648
+ {
10649
+ type: 'function',
10650
+ name: 'pdpVerifierAddress',
10651
+ inputs: [],
10652
+ outputs: [
10653
+ {
10654
+ name: '',
10655
+ internalType: 'address',
10656
+ type: 'address'
10657
+ }
10658
+ ],
10659
+ stateMutability: 'view'
10660
+ }
10661
+ ], pdpVerifierAbi = {
10662
+ type: 'function',
10663
+ name: 'USDFC_SYBIL_FEE',
10664
+ inputs: [],
10665
+ outputs: [
10666
+ {
10667
+ name: '',
10668
+ internalType: 'uint256',
10669
+ type: 'uint256'
10670
+ }
10671
+ ],
10672
+ stateMutability: 'view'
10673
+ }, getDataSetCreationRequirements = async ({ chain })=>{
10674
+ let provider = constants_filProvider[chain.id], [servicePriceResult, pdpVerifierResult] = await Promise.all([
10675
+ provider.request({
10676
+ method: 'eth_call',
10677
+ params: [
10678
+ {
10679
+ to: chain.contracts.storage.address,
10680
+ data: AbiFunction_encodeData(serviceAbi[0])
10681
+ },
10682
+ 'latest'
10683
+ ]
10684
+ }),
10685
+ provider.request({
10686
+ method: 'eth_call',
10687
+ params: [
10688
+ {
10689
+ to: chain.contracts.storage.address,
10690
+ data: AbiFunction_encodeData(serviceAbi[1])
10691
+ },
10692
+ 'latest'
10693
+ ]
10694
+ })
10695
+ ]), { minimumPricePerMonth } = AbiFunction_decodeResult(serviceAbi[0], servicePriceResult), pdpVerifierAddress = AbiFunction_decodeResult(serviceAbi[1], pdpVerifierResult), verifierAddress = '0x0000000000000000000000000000000000000000' === pdpVerifierAddress ? chain.contracts.pdpVerifier.address : pdpVerifierAddress, sybilFeeResult = await provider.request({
10696
+ method: 'eth_call',
10697
+ params: [
10698
+ {
10699
+ to: verifierAddress,
10700
+ data: AbiFunction_encodeData(pdpVerifierAbi)
10701
+ },
10702
+ 'latest'
10703
+ ]
10704
+ }), sybilFee = AbiFunction_decodeResult(pdpVerifierAbi, sybilFeeResult), requirements = (({ minimumPricePerMonth, sybilFee })=>({
10705
+ defaultLockupPeriod: DEFAULT_LOCKUP_PERIOD,
10706
+ epochsPerMonth: DEFAULT_LOCKUP_PERIOD,
10707
+ minimumLockupRequired: minimumPricePerMonth,
10708
+ creationRequirement: minimumPricePerMonth + sybilFee
10709
+ }))({
10710
+ minimumPricePerMonth,
10711
+ sybilFee
10712
+ });
10713
+ return {
10714
+ minimumPricePerMonth,
10715
+ pdpVerifierAddress: verifierAddress,
10716
+ sybilFee,
10717
+ ...requirements
10718
+ };
10579
10719
  }, getServicePrice_abi = {
10580
10720
  type: 'function',
10581
10721
  inputs: [],
@@ -11968,7 +12108,7 @@ let serializedType = '0x02', TxEnvelopeEip1559_type = 'eip1559', SIMULATION_GAS_
11968
12108
  address,
11969
12109
  chain
11970
12110
  });
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'));
12111
+ 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
12112
  let providerId = await pickProvider({
11973
12113
  chain,
11974
12114
  ...providerAddress ? {
@@ -12053,16 +12193,16 @@ let serializedType = '0x02', TxEnvelopeEip1559_type = 'eip1559', SIMULATION_GAS_
12053
12193
  }(bytes))), providerActiveDataSets = (await getClientDataSets({
12054
12194
  chain,
12055
12195
  address
12056
- })).filter((ds)=>ds.providerId === providerId && 0n === ds.pdpEndEpoch), isNewDataSet = 0 === providerActiveDataSets.length || filecoinForceNewDataset, sybilFee = isNewDataSet ? 100000000000000000n : 0n, totalRequired = perMonth + sybilFee;
12057
- verbose && (logger.info(`Required lockup: ${Value_format(perMonth, 18)} USDFC`), isNewDataSet && logger.info(`Sybil fee: ${Value_format(sybilFee, 18)} USDFC`), logger.info(`Total required: ${Value_format(totalRequired, 18)} USDFC`));
12058
- let [funds, lockupCurrent, lockupRate, lockupLastSettledAt] = await getAccountInfo({
12196
+ })).filter((ds)=>ds.providerId === providerId && 0n === ds.pdpEndEpoch), isNewDataSet = 0 === providerActiveDataSets.length || filecoinForceNewDataset, creationRequirement = isNewDataSet ? (await getDataSetCreationRequirements({
12197
+ chain
12198
+ })).creationRequirement : 0n, requiredAmount = isNewDataSet && creationRequirement > perMonth ? creationRequirement : perMonth;
12199
+ verbose && (logger.info(`Storage price: ${Value_format(perMonth, 18)} USDFC/month`), isNewDataSet && logger.info(`Creation requirement: ${Value_format(creationRequirement, 18)} USDFC`), logger.info(`Required funds: ${Value_format(requiredAmount, 18)} USDFC`));
12200
+ let { funds, availableFunds } = await getAvailableFunds({
12059
12201
  address,
12060
12202
  chain
12061
- }), actualLockup = lockupCurrent + (BigInt(await constants_filProvider[chain.id].request({
12062
- method: 'eth_blockNumber'
12063
- })) - lockupLastSettledAt) * lockupRate, availableFunds = funds > actualLockup ? funds - actualLockup : 0n;
12064
- logger.info(`Available funds: ${Value_format(availableFunds, 18)} USDFC`);
12065
- let depositNeeded = totalRequired > availableFunds ? totalRequired - availableFunds : 0n;
12203
+ });
12204
+ verbose && logger.info(`Filecoin Pay deposited funds: ${Value_format(funds, 18)} USDFC`), logger.info(`Filecoin Pay available funds: ${Value_format(availableFunds, 18)} USDFC`);
12205
+ let depositNeeded = requiredAmount > availableFunds ? requiredAmount - availableFunds : 0n;
12066
12206
  if (depositNeeded > 0n) {
12067
12207
  verbose && logger.info(`Depositing ${Value_format(depositNeeded, 18)} USDFC`);
12068
12208
  let params = await depositAndApproveOperatorWriteParameters({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omnipin",
3
- "version": "2.2.2",
3
+ "version": "2.2.3",
4
4
  "author": "v1rtl <hi@v1rtl.site>",
5
5
  "repository": {
6
6
  "type": "git",
@@ -10,7 +10,7 @@
10
10
  "@biomejs/biome": "^2.4.7",
11
11
  "@ipld/car": "^5.4.2",
12
12
  "@ipld/dag-ucan": "^3.4.5",
13
- "@omnipin/foc": "npm:@jsr/omnipin__foc@0.0.11",
13
+ "@omnipin/foc": "npm:@jsr/omnipin__foc@0.0.12",
14
14
  "@rslib/core": "^0.20.0",
15
15
  "@size-limit/file": "^12.0.1",
16
16
  "@stauro/filebase-upload": "npm:@jsr/stauro__filebase-upload",