epistery 1.5.7 → 1.5.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "epistery",
3
- "version": "1.5.7",
3
+ "version": "1.5.8",
4
4
  "description": "Epistery brings blockchain capabilities to mundane web tasks like engagement metrics, authentication and commerce of all sorts.",
5
5
  "author": "Rootz Corp.",
6
6
  "license": "MIT",
@@ -15,6 +15,32 @@ function loadChainPolicy(chainId) {
15
15
  return data?.default?.rpc?.[String(chainId)]?.policy || {};
16
16
  }
17
17
 
18
+ /**
19
+ * Build legacy gasPrice overrides for JOC (81): apply the 30 gwei minimum
20
+ * (JOC RPC enforces this), enforce the same ceiling as Polygon, and force
21
+ * type=0 so hardhat doesn't construct an EIP-1559 typed tx — JOC doesn't
22
+ * honor maxFeePerGas/maxPriorityFeePerGas and the tx will sit in mempool.
23
+ */
24
+ async function jocDeployOverrides(provider, policy) {
25
+ const fd = await provider.getFeeData();
26
+ const minPrice = hre.ethers.utils.parseUnits(
27
+ String(policy.minGasPriceGwei ?? 30), "gwei"
28
+ );
29
+ const networkPrice = fd.gasPrice || minPrice;
30
+ const gasPrice = networkPrice.gt(minPrice) ? networkPrice : minPrice;
31
+
32
+ const ceiling = hre.ethers.utils.parseUnits(
33
+ String(policy.maxGasPriceGwei ?? 1000), "gwei"
34
+ );
35
+ if (gasPrice.gt(ceiling)) {
36
+ throw new Error(
37
+ `Aborting deploy: JOC gas price ${hre.ethers.utils.formatUnits(gasPrice, "gwei")} gwei ` +
38
+ `exceeds cap ${hre.ethers.utils.formatUnits(ceiling, "gwei")} gwei.`
39
+ );
40
+ }
41
+ return { gasPrice, type: 0 };
42
+ }
43
+
18
44
  /**
19
45
  * Build EIP-1559 overrides for Polygon (137) and Amoy (80002): apply the
20
46
  * 25 gwei priority floor, then enforce a configurable ceiling so a base-fee
@@ -85,19 +111,27 @@ async function main() {
85
111
  console.log("\nDeploying Agent contract...");
86
112
  const Agent = await hre.ethers.getContractFactory("Agent");
87
113
 
88
- // Apply fee cap on Polygon family protects against base-fee spikes or
89
- // RPC misreports that would otherwise drain the deployer wallet.
114
+ // Apply fee cap and per-chain tx-type. Without this, hardhat builds an
115
+ // EIP-1559 tx by default fine for Polygon, but JOC rejects/drops those
116
+ // because it only honors legacy gasPrice.
90
117
  const chainId = hre.network.config.chainId;
91
118
  let overrides = {};
92
119
  if (chainId === 137 || chainId === 80002) {
93
120
  const policy = loadChainPolicy(chainId);
94
121
  overrides = await polygonDeployOverrides(deployer.provider, policy);
95
122
  console.log(
96
- "Gas overrides: maxFeePerGas=" +
123
+ "Gas overrides (EIP-1559): maxFeePerGas=" +
97
124
  hre.ethers.utils.formatUnits(overrides.maxFeePerGas, "gwei") + " gwei, " +
98
125
  "maxPriorityFeePerGas=" +
99
126
  hre.ethers.utils.formatUnits(overrides.maxPriorityFeePerGas, "gwei") + " gwei"
100
127
  );
128
+ } else if (chainId === 81) {
129
+ const policy = loadChainPolicy(chainId);
130
+ overrides = await jocDeployOverrides(deployer.provider, policy);
131
+ console.log(
132
+ "Gas overrides (legacy): gasPrice=" +
133
+ hre.ethers.utils.formatUnits(overrides.gasPrice, "gwei") + " gwei"
134
+ );
101
135
  }
102
136
 
103
137
  const agent = await Agent.deploy(domain, sponsor, overrides);