Skip to content

Commit

Permalink
run linter
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Leonard authored and Robert Leonard committed Feb 8, 2024
1 parent d7fcb97 commit eb373dd
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 45 deletions.
4 changes: 4 additions & 0 deletions gateway-eth-ts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,7 @@ await gateway.issue(wallet, gatekeeperNetwork, undefined, undefined, charge)
```

);

## Running Test Suite

We currently use a local node (either foundry or hardhat) with a fork from the bsc testnet contract deployments for our test. To run the test suite locally you must specify the `$RPC_URL` enviornment variable to a bsc testnet node.
93 changes: 56 additions & 37 deletions gateway-eth-ts/src/service/GatewayStaking.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,60 @@
import { Provider } from "@ethersproject/providers";
import { GatewayStaking__factory, GatewayStaking as StakingType } from "../contracts/typechain-types";
import {
GatewayStaking__factory,
GatewayStaking as StakingType,
} from "../contracts/typechain-types";
import { ContractTransaction, Wallet, ethers } from "ethers";

export class GatewayStaking {

private gatewayStakingContract: StakingType;
readonly providerOrWallet: Provider | Wallet;

constructor(
// ethers.js requires a Wallet instead of Signer for the _signTypedData function, until v6
providerOrWallet: Provider | Wallet,
defaultGatewayStakingAddress: string
) {
this.gatewayStakingContract = GatewayStaking__factory.connect(
defaultGatewayStakingAddress,
providerOrWallet
);
this.providerOrWallet = providerOrWallet;
}

async hasMinimumGatekeeperStake(address: string): Promise<boolean> {
return await this.gatewayStakingContract.hasMinimumGatekeeperStake(address, {gasLimit: 300000});
}

async depositStake(amount: bigint): Promise<ContractTransaction> {
return await this.gatewayStakingContract.depositStake(amount, {gasLimit: 300000});
}

async depositStakeFor(amount: bigint, recipient: string): Promise<ContractTransaction> {
return await this.gatewayStakingContract.deposit(amount, recipient);
}

async withdrawStake(amount: bigint): Promise<ContractTransaction> {
return await this.gatewayStakingContract.withdrawStake(amount, {gasLimit: 300000});
}

async withdrawStakeFor(amount: bigint, stakeOwner: string): Promise<ContractTransaction> {
return await this.gatewayStakingContract.redeem(amount, stakeOwner, stakeOwner);
}
}
private gatewayStakingContract: StakingType;
readonly providerOrWallet: Provider | Wallet;

constructor(
// ethers.js requires a Wallet instead of Signer for the _signTypedData function, until v6
providerOrWallet: Provider | Wallet,
defaultGatewayStakingAddress: string
) {
this.gatewayStakingContract = GatewayStaking__factory.connect(

Check failure on line 17 in gateway-eth-ts/src/service/GatewayStaking.ts

View workflow job for this annotation

GitHub Actions / Build, lint and test the ethereum libraries on ubuntu-latest

Unsafe assignment of an `any` value

Check failure on line 17 in gateway-eth-ts/src/service/GatewayStaking.ts

View workflow job for this annotation

GitHub Actions / Build, lint and test the ethereum libraries on ubuntu-latest

Unsafe member access .connect on an `any` value

Check failure on line 17 in gateway-eth-ts/src/service/GatewayStaking.ts

View workflow job for this annotation

GitHub Actions / Build, lint and test the ethereum libraries on ubuntu-latest

Unsafe call of an `any` typed value
defaultGatewayStakingAddress,
providerOrWallet
);
this.providerOrWallet = providerOrWallet;
}

async hasMinimumGatekeeperStake(address: string): Promise<boolean> {
return await this.gatewayStakingContract.hasMinimumGatekeeperStake(

Check failure on line 25 in gateway-eth-ts/src/service/GatewayStaking.ts

View workflow job for this annotation

GitHub Actions / Build, lint and test the ethereum libraries on ubuntu-latest

Unsafe return of an `any` typed value

Check failure on line 25 in gateway-eth-ts/src/service/GatewayStaking.ts

View workflow job for this annotation

GitHub Actions / Build, lint and test the ethereum libraries on ubuntu-latest

Unsafe member access .hasMinimumGatekeeperStake on an `any` value

Check failure on line 25 in gateway-eth-ts/src/service/GatewayStaking.ts

View workflow job for this annotation

GitHub Actions / Build, lint and test the ethereum libraries on ubuntu-latest

Unsafe call of an `any` typed value
address,
{ gasLimit: 300000 }
);
}

async depositStake(amount: bigint): Promise<ContractTransaction> {
return await this.gatewayStakingContract.depositStake(amount, {

Check failure on line 32 in gateway-eth-ts/src/service/GatewayStaking.ts

View workflow job for this annotation

GitHub Actions / Build, lint and test the ethereum libraries on ubuntu-latest

Unsafe return of an `any` typed value

Check failure on line 32 in gateway-eth-ts/src/service/GatewayStaking.ts

View workflow job for this annotation

GitHub Actions / Build, lint and test the ethereum libraries on ubuntu-latest

Unsafe member access .depositStake on an `any` value

Check failure on line 32 in gateway-eth-ts/src/service/GatewayStaking.ts

View workflow job for this annotation

GitHub Actions / Build, lint and test the ethereum libraries on ubuntu-latest

Unsafe call of an `any` typed value
gasLimit: 300000,
});
}

async depositStakeFor(
amount: bigint,
recipient: string
): Promise<ContractTransaction> {
return await this.gatewayStakingContract.deposit(amount, recipient);

Check failure on line 41 in gateway-eth-ts/src/service/GatewayStaking.ts

View workflow job for this annotation

GitHub Actions / Build, lint and test the ethereum libraries on ubuntu-latest

Unsafe return of an `any` typed value
}

async withdrawStake(amount: bigint): Promise<ContractTransaction> {
return await this.gatewayStakingContract.withdrawStake(amount, {
gasLimit: 300000,
});
}

async withdrawStakeFor(
amount: bigint,
stakeOwner: string
): Promise<ContractTransaction> {
return await this.gatewayStakingContract.redeem(
amount,
stakeOwner,
stakeOwner
);
}
}
1 change: 0 additions & 1 deletion gateway-eth-ts/src/service/GatewayTs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ describe.skip("GatewayTS", function () {
);
});


it("should issue a token", async () => {
await (await gateway.issue(sampleWalletAddress, gatekeeperNetwork)).wait();

Expand Down
16 changes: 9 additions & 7 deletions gateway-eth-ts/src/service/GatewayTsInternal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ export class GatewayTsInternal<
bitmask: BigNumberish = 0,
charge: Charge = NULL_CHARGE
): Promise<O> {
const expirationTime = expiry.valueOf() as number > 0 ? getExpirationTime(expiry) : 0;
const expirationTime =
(expiry.valueOf() as number) > 0 ? getExpirationTime(expiry) : 0;

return this.gatewayTokenContract.mint(
owner,
Expand Down Expand Up @@ -119,7 +120,10 @@ export class GatewayTsInternal<

async unfreeze(owner: string, network: bigint): Promise<O> {
const tokenId = await this.checkedGetTokenId(owner, network);
return this.gatewayTokenContract.unfreeze(tokenId, {tokenSender: "", recipient: ""});
return this.gatewayTokenContract.unfreeze(tokenId, {
tokenSender: "",
recipient: "",
});
}

async refresh(
Expand Down Expand Up @@ -152,11 +156,9 @@ export class GatewayTsInternal<
}

async verify(owner: string, network: bigint): Promise<boolean> {
const result = await this.gatewayTokenContract["verifyToken(address,uint256)"](
owner,
network,
this.readOnlyOverrides
);
const result = await this.gatewayTokenContract[
"verifyToken(address,uint256)"
](owner, network, this.readOnlyOverrides);

return result.data != "0";
}
Expand Down

0 comments on commit eb373dd

Please sign in to comment.