Skip to content

Commit

Permalink
lib-ethers: More implementation hiding
Browse files Browse the repository at this point in the history
  • Loading branch information
danielattilasimon committed Feb 4, 2021
1 parent a2bae97 commit 48ff08e
Show file tree
Hide file tree
Showing 25 changed files with 438 additions and 325 deletions.
21 changes: 0 additions & 21 deletions docs/sdk/lib-ethers.connectedliquitydeployment.md

This file was deleted.

4 changes: 2 additions & 2 deletions docs/sdk/lib-ethers.connecttoliquity.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<b>Signature:</b>

```typescript
export declare function connectToLiquity(signerOrProvider: Signer | Provider, network?: string | number): ConnectedLiquityDeployment;
export declare function connectToLiquity(signerOrProvider: Signer | Provider, network?: string | number): LiquityConnection;
```

## Parameters
Expand All @@ -19,5 +19,5 @@ export declare function connectToLiquity(signerOrProvider: Signer | Provider, ne

<b>Returns:</b>

[ConnectedLiquityDeployment](./lib-ethers.connectedliquitydeployment.md)
[LiquityConnection](./lib-ethers.liquityconnection.md)

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@liquity/lib-ethers](./lib-ethers.md) &gt; [ConnectedLiquityDeployment](./lib-ethers.connectedliquitydeployment.md) &gt; [addresses](./lib-ethers.connectedliquitydeployment.addresses.md)
[Home](./index.md) &gt; [@liquity/lib-ethers](./lib-ethers.md) &gt; [LiquityConnection](./lib-ethers.liquityconnection.md) &gt; [addresses](./lib-ethers.liquityconnection.addresses.md)

## ConnectedLiquityDeployment.addresses property
## LiquityConnection.addresses property

<b>Signature:</b>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@liquity/lib-ethers](./lib-ethers.md) &gt; [ConnectedLiquityDeployment](./lib-ethers.connectedliquitydeployment.md) &gt; [deploymentDate](./lib-ethers.connectedliquitydeployment.deploymentdate.md)
[Home](./index.md) &gt; [@liquity/lib-ethers](./lib-ethers.md) &gt; [LiquityConnection](./lib-ethers.liquityconnection.md) &gt; [deploymentDate](./lib-ethers.liquityconnection.deploymentdate.md)

## ConnectedLiquityDeployment.deploymentDate property
## LiquityConnection.deploymentDate property

<b>Signature:</b>

Expand Down
21 changes: 21 additions & 0 deletions docs/sdk/lib-ethers.liquityconnection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@liquity/lib-ethers](./lib-ethers.md) &gt; [LiquityConnection](./lib-ethers.liquityconnection.md)

## LiquityConnection interface

<b>Signature:</b>

```typescript
export interface LiquityConnection
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [addresses](./lib-ethers.liquityconnection.addresses.md) | Record&lt;string, string&gt; | |
| [deploymentDate](./lib-ethers.liquityconnection.deploymentdate.md) | number | |
| [signerOrProvider](./lib-ethers.liquityconnection.signerorprovider.md) | Signer \| Provider | |
| [version](./lib-ethers.liquityconnection.version.md) | string | |

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@liquity/lib-ethers](./lib-ethers.md) &gt; [ConnectedLiquityDeployment](./lib-ethers.connectedliquitydeployment.md) &gt; [signerOrProvider](./lib-ethers.connectedliquitydeployment.signerorprovider.md)
[Home](./index.md) &gt; [@liquity/lib-ethers](./lib-ethers.md) &gt; [LiquityConnection](./lib-ethers.liquityconnection.md) &gt; [signerOrProvider](./lib-ethers.liquityconnection.signerorprovider.md)

## ConnectedLiquityDeployment.signerOrProvider property
## LiquityConnection.signerOrProvider property

<b>Signature:</b>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@liquity/lib-ethers](./lib-ethers.md) &gt; [ConnectedLiquityDeployment](./lib-ethers.connectedliquitydeployment.md) &gt; [version](./lib-ethers.connectedliquitydeployment.version.md)
[Home](./index.md) &gt; [@liquity/lib-ethers](./lib-ethers.md) &gt; [LiquityConnection](./lib-ethers.liquityconnection.md) &gt; [version](./lib-ethers.liquityconnection.version.md)

## ConnectedLiquityDeployment.version property
## LiquityConnection.version property

<b>Signature:</b>

Expand Down
2 changes: 1 addition & 1 deletion docs/sdk/lib-ethers.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
| Interface | Description |
| --- | --- |
| [BlockPolledLiquityStoreExtraState](./lib-ethers.blockpolledliquitystoreextrastate.md) | Extra state added to [LiquityStoreState](./lib-base.liquitystorestate.md) by [BlockPolledLiquityStore](./lib-ethers.blockpolledliquitystore.md)<!-- -->. |
| [ConnectedLiquityDeployment](./lib-ethers.connectedliquitydeployment.md) | |
| [EthersCallOverrides](./lib-ethers.etherscalloverrides.md) | |
| [EthersTransactionOverrides](./lib-ethers.etherstransactionoverrides.md) | |
| [LiquityConnection](./lib-ethers.liquityconnection.md) | |

## Type Aliases

Expand Down
4 changes: 2 additions & 2 deletions docs/sdk/lib-ethers.populatableethersliquity._constructor_.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ Constructs a new instance of the `PopulatableEthersLiquity` class
<b>Signature:</b>

```typescript
constructor(deployment: ConnectedLiquityDeployment, readableLiquity: ReadableLiquity, store?: LiquityStore);
constructor(connection: LiquityConnection, readableLiquity: ReadableLiquity, store?: LiquityStore);
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| deployment | [ConnectedLiquityDeployment](./lib-ethers.connectedliquitydeployment.md) | |
| connection | [LiquityConnection](./lib-ethers.liquityconnection.md) | |
| readableLiquity | [ReadableLiquity](./lib-base.readableliquity.md) | |
| store | [LiquityStore](./lib-base.liquitystore.md) | |

2 changes: 1 addition & 1 deletion docs/sdk/lib-ethers.populatableethersliquity.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export declare class PopulatableEthersLiquity extends _PopulatableEthersLiquityB
| Constructor | Modifiers | Description |
| --- | --- | --- |
| [(constructor)(deployment, readableLiquity, store)](./lib-ethers.populatableethersliquity._constructor_.md) | | Constructs a new instance of the <code>PopulatableEthersLiquity</code> class |
| [(constructor)(connection, readableLiquity, store)](./lib-ethers.populatableethersliquity._constructor_.md) | | Constructs a new instance of the <code>PopulatableEthersLiquity</code> class |
## Methods
Expand Down
4 changes: 2 additions & 2 deletions docs/sdk/lib-ethers.readableethersliquity._constructor_.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ Constructs a new instance of the `ReadableEthersLiquity` class
<b>Signature:</b>

```typescript
constructor(deployment: ConnectedLiquityDeployment, userAddress?: string);
constructor(connection: LiquityConnection, userAddress?: string);
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| deployment | [ConnectedLiquityDeployment](./lib-ethers.connectedliquitydeployment.md) | |
| connection | [LiquityConnection](./lib-ethers.liquityconnection.md) | |
| userAddress | string | |

2 changes: 1 addition & 1 deletion docs/sdk/lib-ethers.readableethersliquity.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export declare class ReadableEthersLiquity extends _EthersLiquityBase implements
| Constructor | Modifiers | Description |
| --- | --- | --- |
| [(constructor)(deployment, userAddress)](./lib-ethers.readableethersliquity._constructor_.md) | | Constructs a new instance of the <code>ReadableEthersLiquity</code> class |
| [(constructor)(connection, userAddress)](./lib-ethers.readableethersliquity._constructor_.md) | | Constructs a new instance of the <code>ReadableEthersLiquity</code> class |
## Methods
Expand Down
4 changes: 2 additions & 2 deletions packages/dev-frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ type LiquityFrontendProps = {
};

const LiquityFrontend: React.FC<LiquityFrontendProps> = ({ loader }) => {
const { account, provider, deployment, liquity, store } = useLiquity();
const { account, provider, connection, liquity, store } = useLiquity();

// For console tinkering ;-)
Object.assign(window, {
account,
provider,
deployment,
connection,
liquity,
store,
SubgraphLiquity,
Expand Down
2 changes: 1 addition & 1 deletion packages/dev-frontend/src/components/PriceManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const selectPrice = ({ price }: LiquityStoreState) => price;

export const PriceManager: React.FC = () => {
const {
deployment: { _priceFeedIsTestnet: canSetPrice },
connection: { _priceFeedIsTestnet: canSetPrice },
liquity: { send: liquity }
} = useLiquity();
const price = useLiquitySelector(selectPrice);
Expand Down
2 changes: 1 addition & 1 deletion packages/dev-frontend/src/components/SystemStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const select = ({

export const SystemStats: React.FC<SystemStatsProps> = ({ variant = "info", showBalances }) => {
const {
deployment: { version: contractsVersion, deploymentDate }
connection: { version: contractsVersion, deploymentDate }
} = useLiquity();
const {
numberOfTroves,
Expand Down
20 changes: 10 additions & 10 deletions packages/dev-frontend/src/hooks/LiquityContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
BlockPolledLiquityStore,
ReadableEthersLiquity,
PopulatableEthersLiquity,
ConnectedLiquityDeployment,
LiquityConnection,
connectToLiquity
} from "@liquity/lib-ethers";

Expand All @@ -21,7 +21,7 @@ type LiquityContextValue = {
config: LiquityFrontendConfig;
account: string;
provider: Provider;
deployment: ConnectedLiquityDeployment;
connection: LiquityConnection;
liquity: EthersLiquity;
store: BlockPolledLiquityStore;
};
Expand Down Expand Up @@ -56,7 +56,7 @@ export const LiquityProvider: React.FC<LiquityProviderProps> = ({
const { library: provider, account, chainId } = useWeb3React<Web3Provider>();
const [config, setConfig] = useState<LiquityFrontendConfig>();

const deployment =
const connection =
provider && account && chainId
? tryConnectToLiquity(provider.getSigner(account), chainId)
: undefined;
Expand All @@ -66,7 +66,7 @@ export const LiquityProvider: React.FC<LiquityProviderProps> = ({
}, []);

useEffect(() => {
if (config && provider && chainId && deployment) {
if (config && provider && chainId && connection) {
if (isBatchedProvider(provider)) {
provider.chainId = chainId;
}
Expand All @@ -76,7 +76,7 @@ export const LiquityProvider: React.FC<LiquityProviderProps> = ({

if (network.name && supportedNetworks.includes(network.name) && config.infuraApiKey) {
provider.openWebSocket(...wsParams(network.name, config.infuraApiKey));
} else if (deployment._isDev) {
} else if (connection._isDev) {
provider.openWebSocket(`ws://${window.location.hostname}:8546`, chainId);
}

Expand All @@ -85,19 +85,19 @@ export const LiquityProvider: React.FC<LiquityProviderProps> = ({
};
}
}
}, [config, provider, chainId, deployment]);
}, [config, provider, chainId, connection]);

if (!config || !provider || !account || !chainId) {
return <>{loader}</>;
}

if (!deployment) {
if (!connection) {
return unsupportedNetworkFallback ? <>{unsupportedNetworkFallback(chainId)}</> : null;
}

const readable = new ReadableEthersLiquity(deployment, account);
const readable = new ReadableEthersLiquity(connection, account);
const store = new BlockPolledLiquityStore(provider, account, readable, config.frontendTag);
const populatable = new PopulatableEthersLiquity(deployment, readable, store);
const populatable = new PopulatableEthersLiquity(connection, readable, store);
const liquity = new EthersLiquity(readable, populatable);

store.logging = true;
Expand All @@ -108,7 +108,7 @@ export const LiquityProvider: React.FC<LiquityProviderProps> = ({
config,
account,
provider,
deployment,
connection,
liquity,
store
}}
Expand Down
Loading

0 comments on commit 48ff08e

Please sign in to comment.