@glowlabs-org/utils 0.2.99 → 0.2.100
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/cjs/browser.js +1 -1
- package/dist/cjs/{farms-router-CJrriLMx.js → farms-router-DaFmKLaa.js} +27 -13
- package/dist/cjs/farms-router-DaFmKLaa.js.map +1 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/lib/abis/offchainFractions.d.ts +21 -0
- package/dist/cjs/lib/hooks/use-offchain-fractions.d.ts +3 -1
- package/dist/esm/browser.js +2 -2
- package/dist/esm/{farms-router-C1A8W28q.js → farms-router-CzfB_qrp.js} +27 -13
- package/dist/esm/farms-router-CzfB_qrp.js.map +1 -0
- package/dist/esm/index.js +2 -2
- package/dist/esm/lib/abis/offchainFractions.d.ts +21 -0
- package/dist/esm/lib/hooks/use-offchain-fractions.d.ts +3 -1
- package/package.json +1 -1
- package/src/constants/addresses.ts +1 -1
- package/src/lib/abis/offchainFractions.ts +13 -1
- package/src/lib/hooks/use-offchain-fractions.ts +17 -8
- package/dist/cjs/farms-router-CJrriLMx.js.map +0 -1
- package/dist/esm/farms-router-C1A8W28q.js.map +0 -1
package/dist/cjs/browser.js
CHANGED
|
@@ -225,7 +225,7 @@ const sepoliaAddresses = {
|
|
|
225
225
|
USDG_UNISWAP: "0x2a085A3aEA8982396533327c854753Ce521B666d",
|
|
226
226
|
GLW_UNISWAP: "0x8e27016D0B866a56CE74A1a280c749dD679bb0Fa",
|
|
227
227
|
FORWARDER: "0xDaC24F18171224eeaf6a9B38f5C5081aDbDff969",
|
|
228
|
-
OFFCHAIN_FRACTIONS: "
|
|
228
|
+
OFFCHAIN_FRACTIONS: "0x0095F2F0C7bbEEd97eCF058D28a8b768Ece32Ac3",
|
|
229
229
|
COUNTERFACTUAL_HOLDER_FACTORY: "0x2c3AB887746F6f4a8a4b9Db6aC800eb71945509A",
|
|
230
230
|
FOUNDATION_WALLET: "0x5e230FED487c86B90f6508104149F087d9B1B0A7",
|
|
231
231
|
UNISWAP_V2_ROUTER: "0xeE567Fe1712Faf6149d80dA1E6934E354124CfE3",
|
|
@@ -864,6 +864,7 @@ const OFFCHAIN_FRACTIONS_ABI = [
|
|
|
864
864
|
{ inputs: [], name: "MinSharesCannotBeGreaterThanTotalSteps", type: "error" },
|
|
865
865
|
{ inputs: [], name: "NoStepsPurchased", type: "error" },
|
|
866
866
|
{ inputs: [], name: "NotAllOrNothing", type: "error" },
|
|
867
|
+
{ inputs: [], name: "NotFractionsCloser", type: "error" },
|
|
867
868
|
{ inputs: [], name: "NotFractionsOwner", type: "error" },
|
|
868
869
|
{ inputs: [], name: "RecipientCannotBeSelf", type: "error" },
|
|
869
870
|
{ inputs: [], name: "ReentrancyGuardReentrantCall", type: "error" },
|
|
@@ -943,6 +944,12 @@ const OFFCHAIN_FRACTIONS_ABI = [
|
|
|
943
944
|
name: "minSharesToRaise",
|
|
944
945
|
type: "uint256",
|
|
945
946
|
},
|
|
947
|
+
{
|
|
948
|
+
indexed: false,
|
|
949
|
+
internalType: "address",
|
|
950
|
+
name: "closer",
|
|
951
|
+
type: "address",
|
|
952
|
+
},
|
|
946
953
|
],
|
|
947
954
|
name: "FractionCreated",
|
|
948
955
|
type: "event",
|
|
@@ -1063,7 +1070,10 @@ const OFFCHAIN_FRACTIONS_ABI = [
|
|
|
1063
1070
|
type: "function",
|
|
1064
1071
|
},
|
|
1065
1072
|
{
|
|
1066
|
-
inputs: [
|
|
1073
|
+
inputs: [
|
|
1074
|
+
{ internalType: "address", name: "creator", type: "address" },
|
|
1075
|
+
{ internalType: "bytes32", name: "id", type: "bytes32" },
|
|
1076
|
+
],
|
|
1067
1077
|
name: "closeFraction",
|
|
1068
1078
|
outputs: [],
|
|
1069
1079
|
stateMutability: "nonpayable",
|
|
@@ -1079,6 +1089,7 @@ const OFFCHAIN_FRACTIONS_ABI = [
|
|
|
1079
1089
|
{ internalType: "address", name: "to", type: "address" },
|
|
1080
1090
|
{ internalType: "bool", name: "useCounterfactualAddress", type: "bool" },
|
|
1081
1091
|
{ internalType: "uint256", name: "minSharesToRaise", type: "uint256" },
|
|
1092
|
+
{ internalType: "address", name: "closer", type: "address" },
|
|
1082
1093
|
],
|
|
1083
1094
|
name: "createFraction",
|
|
1084
1095
|
outputs: [],
|
|
@@ -1117,6 +1128,7 @@ const OFFCHAIN_FRACTIONS_ABI = [
|
|
|
1117
1128
|
{ internalType: "address", name: "to", type: "address" },
|
|
1118
1129
|
{ internalType: "uint256", name: "soldSteps", type: "uint256" },
|
|
1119
1130
|
{ internalType: "uint256", name: "totalSteps", type: "uint256" },
|
|
1131
|
+
{ internalType: "address", name: "closer", type: "address" },
|
|
1120
1132
|
],
|
|
1121
1133
|
internalType: "struct OffchainFractions.FractionData",
|
|
1122
1134
|
name: "",
|
|
@@ -1287,7 +1299,7 @@ function useOffchainFractions(signer, CHAIN_ID) {
|
|
|
1287
1299
|
if (!contract)
|
|
1288
1300
|
throw new Error(exports.OffchainFractionsError.CONTRACT_NOT_AVAILABLE);
|
|
1289
1301
|
setIsProcessing(true);
|
|
1290
|
-
const { id, token, step, totalSteps, expiration, to, useCounterfactualAddress, minSharesToRaise, } = params;
|
|
1302
|
+
const { id, token, step, totalSteps, expiration, to, useCounterfactualAddress, minSharesToRaise, closer, } = params;
|
|
1291
1303
|
// Validate parameters
|
|
1292
1304
|
if (!id || !token || !to) {
|
|
1293
1305
|
throw new Error(exports.OffchainFractionsError.INVALID_PARAMETERS);
|
|
@@ -1302,13 +1314,13 @@ function useOffchainFractions(signer, CHAIN_ID) {
|
|
|
1302
1314
|
try {
|
|
1303
1315
|
await contract
|
|
1304
1316
|
.getFunction("createFraction")
|
|
1305
|
-
.staticCall(id, token, step, totalSteps, expiration, to, useCounterfactualAddress, minSharesToRaise);
|
|
1317
|
+
.staticCall(id, token, step, totalSteps, expiration, to, useCounterfactualAddress, minSharesToRaise, closer);
|
|
1306
1318
|
}
|
|
1307
1319
|
catch (staticError) {
|
|
1308
1320
|
throw new Error(parseEthersError(staticError));
|
|
1309
1321
|
}
|
|
1310
1322
|
// Execute the transaction
|
|
1311
|
-
const tx = await contract.getFunction("createFraction")(id, token, step, totalSteps, expiration, to, useCounterfactualAddress, minSharesToRaise);
|
|
1323
|
+
const tx = await contract.getFunction("createFraction")(id, token, step, totalSteps, expiration, to, useCounterfactualAddress, minSharesToRaise, closer);
|
|
1312
1324
|
await tx.wait();
|
|
1313
1325
|
return tx.hash;
|
|
1314
1326
|
}
|
|
@@ -1421,10 +1433,11 @@ function useOffchainFractions(signer, CHAIN_ID) {
|
|
|
1421
1433
|
}
|
|
1422
1434
|
}
|
|
1423
1435
|
/**
|
|
1424
|
-
* Close a fraction sale manually (only by
|
|
1436
|
+
* Close a fraction sale manually (only by closer)
|
|
1437
|
+
* @param creator The address that created the fraction sale
|
|
1425
1438
|
* @param id The unique identifier of the fraction sale to close
|
|
1426
1439
|
*/
|
|
1427
|
-
async function closeFraction(id) {
|
|
1440
|
+
async function closeFraction(creator, id) {
|
|
1428
1441
|
assertSigner(signer);
|
|
1429
1442
|
try {
|
|
1430
1443
|
const contract = getOffchainFractionsContract();
|
|
@@ -1432,13 +1445,13 @@ function useOffchainFractions(signer, CHAIN_ID) {
|
|
|
1432
1445
|
throw new Error(exports.OffchainFractionsError.CONTRACT_NOT_AVAILABLE);
|
|
1433
1446
|
setIsProcessing(true);
|
|
1434
1447
|
// Validate parameters
|
|
1435
|
-
if (!id) {
|
|
1448
|
+
if (!creator || !id) {
|
|
1436
1449
|
throw new Error(exports.OffchainFractionsError.INVALID_PARAMETERS);
|
|
1437
1450
|
}
|
|
1438
1451
|
const owner = await signer.getAddress();
|
|
1439
1452
|
// Run a static call first to surface any revert reason
|
|
1440
1453
|
try {
|
|
1441
|
-
await contract.getFunction("closeFraction").staticCall(id, {
|
|
1454
|
+
await contract.getFunction("closeFraction").staticCall(creator, id, {
|
|
1442
1455
|
from: owner,
|
|
1443
1456
|
});
|
|
1444
1457
|
}
|
|
@@ -1446,7 +1459,7 @@ function useOffchainFractions(signer, CHAIN_ID) {
|
|
|
1446
1459
|
throw new Error(parseEthersError(staticError));
|
|
1447
1460
|
}
|
|
1448
1461
|
// Execute the transaction
|
|
1449
|
-
const tx = await contract.getFunction("closeFraction")(id);
|
|
1462
|
+
const tx = await contract.getFunction("closeFraction")(creator, id);
|
|
1450
1463
|
await tx.wait();
|
|
1451
1464
|
return tx.hash;
|
|
1452
1465
|
}
|
|
@@ -1481,6 +1494,7 @@ function useOffchainFractions(signer, CHAIN_ID) {
|
|
|
1481
1494
|
to: result.to,
|
|
1482
1495
|
soldSteps: result.soldSteps,
|
|
1483
1496
|
totalSteps: result.totalSteps,
|
|
1497
|
+
closer: result.closer,
|
|
1484
1498
|
};
|
|
1485
1499
|
}
|
|
1486
1500
|
catch (error) {
|
|
@@ -1587,7 +1601,7 @@ function useOffchainFractions(signer, CHAIN_ID) {
|
|
|
1587
1601
|
const contract = getOffchainFractionsContract();
|
|
1588
1602
|
if (!contract)
|
|
1589
1603
|
throw new Error(exports.OffchainFractionsError.CONTRACT_NOT_AVAILABLE);
|
|
1590
|
-
const { id, token, step, totalSteps, expiration, to, useCounterfactualAddress, minSharesToRaise, } = params;
|
|
1604
|
+
const { id, token, step, totalSteps, expiration, to, useCounterfactualAddress, minSharesToRaise, closer, } = params;
|
|
1591
1605
|
const feeData = await signer.provider?.getFeeData();
|
|
1592
1606
|
const gasPrice = feeData?.gasPrice ?? feeData?.maxFeePerGas ?? 0n;
|
|
1593
1607
|
if (gasPrice === 0n) {
|
|
@@ -1595,7 +1609,7 @@ function useOffchainFractions(signer, CHAIN_ID) {
|
|
|
1595
1609
|
}
|
|
1596
1610
|
const estimatedGas = await contract
|
|
1597
1611
|
.getFunction("createFraction")
|
|
1598
|
-
.estimateGas(id, token, step, totalSteps, expiration, to, useCounterfactualAddress, minSharesToRaise);
|
|
1612
|
+
.estimateGas(id, token, step, totalSteps, expiration, to, useCounterfactualAddress, minSharesToRaise, closer);
|
|
1599
1613
|
const estimatedCost = estimatedGas * gasPrice;
|
|
1600
1614
|
if (ethPriceInUSD) {
|
|
1601
1615
|
const estimatedCostInEth = viem.formatEther(estimatedCost);
|
|
@@ -3083,4 +3097,4 @@ exports.regionMetadata = regionMetadata;
|
|
|
3083
3097
|
exports.usStates = usStates;
|
|
3084
3098
|
exports.useForwarder = useForwarder;
|
|
3085
3099
|
exports.useOffchainFractions = useOffchainFractions;
|
|
3086
|
-
//# sourceMappingURL=farms-router-
|
|
3100
|
+
//# sourceMappingURL=farms-router-DaFmKLaa.js.map
|