Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

Commit

Permalink
Merge branch 'CORE-2033-add-v2-registration-contract' into CORE-2033-…
Browse files Browse the repository at this point in the history
…add-withdrawal-all-function-for-registered-user
  • Loading branch information
kaihirota committed Feb 19, 2024
2 parents cbf663e + d41c00d commit c95b022
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import type {
OnEvent,
} from "../common";

export interface CoreInterface extends utils.Interface {
export interface StarkV3Interface extends utils.Interface {
functions: {
"announceAvailabilityVerifierRemovalIntent(address)": FunctionFragment;
"announceVerifierRemovalIntent(address)": FunctionFragment;
Expand Down Expand Up @@ -864,12 +864,12 @@ export type LogWithdrawalPerformedEvent = TypedEvent<
export type LogWithdrawalPerformedEventFilter =
TypedEventFilter<LogWithdrawalPerformedEvent>;

export interface Core extends BaseContract {
export interface StarkV3 extends BaseContract {
connect(signerOrProvider: Signer | Provider | string): this;
attach(addressOrName: string): this;
deployed(): Promise<this>;

interface: CoreInterface;
interface: StarkV3Interface;

queryFilter<TEvent extends TypedEvent>(
event: TypedEventFilter<TEvent>,
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/contracts/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export type { Core } from "./Core";
export type { StarkV3 } from "./StarkV3";
export type { StarkV4 } from "./StarkV4";
export type { Registration } from "./Registration";
export type { RegistrationV2 } from "./RegistrationV2";
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import { Contract, Signer, utils } from "ethers";
import type { Provider } from "@ethersproject/providers";
import type { Core, CoreInterface } from "../../contracts/Core";
import type { StarkV3, StarkV3Interface } from "../../contracts/StarkV3";

const _abi = [
{
Expand Down Expand Up @@ -1597,12 +1597,12 @@ const _abi = [
},
];

export class Core__factory {
export class StarkV3__factory {
static readonly abi = _abi;
static createInterface(): CoreInterface {
return new utils.Interface(_abi) as CoreInterface;
static createInterface(): StarkV3Interface {
return new utils.Interface(_abi) as StarkV3Interface;
}
static connect(address: string, signerOrProvider: Signer | Provider): Core {
return new Contract(address, _abi, signerOrProvider) as Core;
static connect(address: string, signerOrProvider: Signer | Provider): StarkV3 {
return new Contract(address, _abi, signerOrProvider) as StarkV3;
}
}
2 changes: 1 addition & 1 deletion src/contracts/factories/contracts/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export { Core__factory } from "./Core__factory";
export { StarkV3__factory } from "./StarkV3__factory";
export { StarkV4__factory } from "./StarkV4__factory";
export { Registration__factory } from "./Registration__factory";
export { RegistrationV2__factory } from "./RegistrationV2__factory";
4 changes: 2 additions & 2 deletions src/contracts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export type { IERC721 } from './@openzeppelin/contracts/token/ERC721/IERC721';
export { IERC721__factory } from './factories/@openzeppelin/contracts/token/ERC721/IERC721__factory';
export type { IERC165 } from './@openzeppelin/contracts/utils/introspection/IERC165';
export { IERC165__factory } from './factories/@openzeppelin/contracts/utils/introspection/IERC165__factory';
export type { Core } from './contracts/Core';
export { Core__factory } from './factories/contracts/Core__factory';
export type { StarkV3 } from './contracts/StarkV3';
export { StarkV3__factory } from './factories/contracts/StarkV3__factory';
export type { StarkV4 } from './contracts/StarkV4';
export { StarkV4__factory } from './factories/contracts/StarkV4__factory';
export type { Registration } from './contracts/Registration';
Expand Down
2 changes: 1 addition & 1 deletion src/exportContracts.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export {
Core__factory as Core,
StarkV3__factory as StarkV3,
Registration__factory as Registration,
IERC20__factory as IERC20,
IERC721__factory as IERC721,
Expand Down
10 changes: 5 additions & 5 deletions src/workflows/deposit/depositERC20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { TransactionResponse } from '@ethersproject/providers';
import { DepositsApi, EncodingApi, TokensApi, UsersApi } from '../../api';
import { parseUnits } from '@ethersproject/units';
import {
Core,
Core__factory,
StarkV3,
StarkV3__factory,
IERC20__factory,
Registration__factory,
} from '../../contracts';
Expand All @@ -27,7 +27,7 @@ async function executeDepositERC20(
assetType: string,
starkPublicKey: string,
vaultId: number,
contract: Core,
contract: StarkV3,
): Promise<TransactionResponse> {
const populatedTransaction = await contract.populateTransaction.depositERC20(
starkPublicKey,
Expand All @@ -45,7 +45,7 @@ async function executeRegisterAndDepositERC20(
assetType: string,
starkPublicKey: string,
vaultId: number,
contract: Core,
contract: StarkV3,
usersApi: UsersApi,
): Promise<TransactionResponse> {
const etherKey = await signer.getAddress();
Expand Down Expand Up @@ -130,7 +130,7 @@ export async function depositERC20Workflow(
const vaultId = signableDepositResult.data.vault_id;
const quantizedAmount = BigNumber.from(signableDepositResult.data.amount);

const coreContract = Core__factory.connect(
const coreContract = StarkV3__factory.connect(
config.ethConfiguration.coreContractAddress,
signer,
);
Expand Down
8 changes: 4 additions & 4 deletions src/workflows/deposit/depositERC721.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { Signer } from '@ethersproject/abstract-signer';
import { TransactionResponse } from '@ethersproject/providers';
import { DepositsApi, EncodingApi, UsersApi } from '../../api';
import {
Core,
Core__factory,
StarkV3,
StarkV3__factory,
IERC721__factory,
Registration__factory,
} from '../../contracts';
Expand All @@ -25,7 +25,7 @@ async function executeDepositERC721(
assetType: string,
starkPublicKey: string,
vaultId: number,
contract: Core,
contract: StarkV3,
): Promise<TransactionResponse> {
const populatedTransaction = await contract.populateTransaction.depositNft(
starkPublicKey,
Expand Down Expand Up @@ -85,7 +85,7 @@ export async function depositERC721Workflow(
const starkPublicKey = signableDepositResult.data.stark_key;
const vaultId = signableDepositResult.data.vault_id;

const coreContract = Core__factory.connect(
const coreContract = StarkV3__factory.connect(
config.ethConfiguration.coreContractAddress,
signer,
);
Expand Down
12 changes: 8 additions & 4 deletions src/workflows/deposit/depositEth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import { Signer } from '@ethersproject/abstract-signer';
import { TransactionResponse } from '@ethersproject/providers';
import { DepositsApi, EncodingApi, UsersApi } from '../../api';
import { parseUnits } from '@ethersproject/units';
import { Core, Core__factory, Registration__factory } from '../../contracts';
import {
StarkV3,
StarkV3__factory,
Registration__factory,
} from '../../contracts';
import {
getSignableRegistrationOnchain,
isRegisteredOnChainWorkflow,
Expand All @@ -21,7 +25,7 @@ async function executeRegisterAndDepositEth(
assetType: string,
starkPublicKey: string,
vaultId: number,
contract: Core,
contract: StarkV3,
usersApi: UsersApi,
): Promise<TransactionResponse> {
const etherKey = await signer.getAddress();
Expand Down Expand Up @@ -50,7 +54,7 @@ async function executeDepositEth(
assetType: string,
starkPublicKey: string,
vaultId: number,
contract: Core,
contract: StarkV3,
): Promise<TransactionResponse> {
const populatedTransaction = await contract.populateTransaction[
'deposit(uint256,uint256,uint256)'
Expand Down Expand Up @@ -99,7 +103,7 @@ export async function depositEthWorkflow(
const starkPublicKey = signableDepositResult.data.stark_key;
const vaultId = signableDepositResult.data.vault_id;

const coreContract = Core__factory.connect(
const coreContract = StarkV3__factory.connect(
config.ethConfiguration.coreContractAddress,
signer,
);
Expand Down
8 changes: 4 additions & 4 deletions src/workflows/withdrawal/completeERC20Withdrawal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { TransactionResponse } from '@ethersproject/providers';
import { EncodingApi, UsersApi } from '../../api';
import { ImmutableXConfiguration } from '../../config';
import {
Core,
Core__factory,
StarkV3,
StarkV3__factory,
StarkV4__factory,
Registration,
Registration__factory,
Expand Down Expand Up @@ -47,7 +47,7 @@ async function executeWithdrawERC20(
signer: Signer,
assetType: string,
starkPublicKey: string,
contract: Core,
contract: StarkV3,
): Promise<TransactionResponse> {
const populatedTransaction = await contract.populateTransaction.withdraw(
starkPublicKey,
Expand All @@ -69,7 +69,7 @@ export async function completeERC20WithdrawalV1Workflow(
token_address: token.tokenAddress,
});

const coreContract = Core__factory.connect(
const coreContract = StarkV3__factory.connect(
config.ethConfiguration.coreContractAddress,
signer,
);
Expand Down
12 changes: 6 additions & 6 deletions src/workflows/withdrawal/completeERC721Withdrawal.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Signer } from '@ethersproject/abstract-signer';
import { EncodingApi, MintsApi, UsersApi } from '../../api';
import {
Core,
Core__factory,
StarkV3,
StarkV3__factory,
Registration,
Registration__factory,
StarkV4__factory,
Expand Down Expand Up @@ -31,7 +31,7 @@ async function executeWithdrawMintableERC721(
assetType: string,
starkPublicKey: string,
mintingBlob: string,
contract: Core,
contract: StarkV3,
): Promise<TransactionResponse> {
const populatedTransaction =
await contract.populateTransaction.withdrawAndMint(
Expand Down Expand Up @@ -96,7 +96,7 @@ async function completeMintableERC721WithdrawalV1(
);
const mintingBlob = getMintingBlob(token);

const coreContract = Core__factory.connect(
const coreContract = StarkV3__factory.connect(
config.ethConfiguration.coreContractAddress,
signer,
);
Expand Down Expand Up @@ -164,7 +164,7 @@ async function executeWithdrawERC721(
assetType: string,
starkPublicKey: string,
tokenId: string,
contract: Core,
contract: StarkV3,
): Promise<TransactionResponse> {
const populatedTransaction = await contract.populateTransaction.withdrawNft(
starkPublicKey,
Expand All @@ -187,7 +187,7 @@ async function completeERC721WithdrawalV1(
token_address: token.tokenAddress,
});

const coreContract = Core__factory.connect(
const coreContract = StarkV3__factory.connect(
config.ethConfiguration.coreContractAddress,
signer,
);
Expand Down
8 changes: 4 additions & 4 deletions src/workflows/withdrawal/completeEthWithdrawal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { TransactionResponse } from '@ethersproject/providers';
import { EncodingApi, UsersApi } from '../../api';
import { ImmutableXConfiguration } from '../../config';
import {
Core,
Core__factory,
StarkV3,
StarkV3__factory,
StarkV4__factory,
Registration,
Registration__factory,
Expand Down Expand Up @@ -46,7 +46,7 @@ async function executeWithdrawEth(
signer: Signer,
assetType: string,
starkPublicKey: string,
contract: Core,
contract: StarkV3,
): Promise<TransactionResponse> {
const populatedTransaction = await contract.populateTransaction.withdraw(
starkPublicKey,
Expand All @@ -65,7 +65,7 @@ export async function completeEthWithdrawalV1Workflow(
): Promise<TransactionResponse> {
const assetType = await getEncodeAssetInfo('asset', 'ETH', encodingApi);

const coreContract = Core__factory.connect(
const coreContract = StarkV3__factory.connect(
config.ethConfiguration.coreContractAddress,
signer,
);
Expand Down
4 changes: 2 additions & 2 deletions src/workflows/withdrawal/completeWithdrawal.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Signer } from '@ethersproject/abstract-signer';
import { TransactionResponse } from '@ethersproject/providers';
import { AnyToken } from 'src/types';
import { EncodingApi, MintsApi, UsersApi } from 'src/api';
import { ImmutableXConfiguration } from 'src/config';
import {
completeAllEthWithdrawalWorkflow,
completeEthWithdrawalV1Workflow,
completeEthWithdrawalV2Workflow,
} from './completeEthWithdrawal';
import { EncodingApi, MintsApi, UsersApi } from 'src/api';
import { ImmutableXConfiguration } from 'src/config';
import {
completeAllERC20WithdrawalWorkflow,
completeERC20WithdrawalV1Workflow,
Expand Down
11 changes: 6 additions & 5 deletions src/workflows/workflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ import {
prepareWithdrawalV2Workflow,
prepareWithdrawalWorkflow,
} from './withdrawal';
import {
completeAllWithdrawalWorkflow,
completeWithdrawalV1Workflow,
completeWithdrawalV2Workflow,
} from './withdrawal/completeWithdrawal';
import { cancelOrderWorkflow, createOrderWorkflow } from './orders';
import { createTradeWorkflow } from './trades';
import { generateIMXAuthorisationHeaders } from '../utils';
Expand All @@ -63,11 +68,6 @@ import axios, { AxiosResponse } from 'axios';
import { BigNumber } from 'ethers';
import { Signer } from '@ethersproject/abstract-signer';
import { TransactionResponse } from '@ethersproject/providers';
import {
completeAllWithdrawalWorkflow,
completeWithdrawalV1Workflow,
completeWithdrawalV2Workflow,
} from './withdrawal/completeWithdrawal';

export class Workflows {
private readonly depositsApi: DepositsApi;
Expand Down Expand Up @@ -296,6 +296,7 @@ export class Workflows {
const starkPublicKey = await walletConnection.starkSigner.getAddress();

if (majorContractVersion === 3) {
const starkPublicKey = await walletConnection.starkSigner.getAddress();
return completeWithdrawalV1Workflow(
walletConnection.ethSigner,
starkPublicKey,
Expand Down

0 comments on commit c95b022

Please sign in to comment.