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

Commit

Permalink
remove register and complete withdraw all workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
kaihirota committed Feb 27, 2024
1 parent 955c8ed commit e605e31
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 94 deletions.
18 changes: 0 additions & 18 deletions src/ImmutableX.ts
Original file line number Diff line number Diff line change
Expand Up @@ -620,24 +620,6 @@ export class ImmutableX {
});
}

/**
* Register and complete a Withdrawal
* @param walletConnection - the pair of L1/L2 signers
* @param token - the token
* @returns a promise that resolves with the transaction
* @throws {@link index.IMXError}
*/
public registerAndCompleteWithdrawal(
walletConnection: WalletConnection,
token: AnyToken,
) {
return this.workflows
.registerAndCompleteWithdrawal(walletConnection, token)
.catch(err => {
throw formatError(err);
});
}

/**
* Get details of an Order with the given ID
* @param request - the request object containing the parameters to be provided in the API request
Expand Down
76 changes: 0 additions & 76 deletions src/workflows/workflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ 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 Expand Up @@ -348,81 +347,6 @@ export class Workflows {
token,
);

if (v3Balance.gt(0)) {
const isRegistered = await this.isRegisteredOnchain(walletConnection);
if (isRegistered) {
return completeAllWithdrawalWorkflow(
walletConnection.ethSigner,
starkPublicKey,
token,
this.encodingApi,
this.mintsApi,
this.config,
);
}
throw new Error('User unregistered');
}
if (v4Balance.gt(0)) {
return completeWithdrawalV2Workflow(
walletConnection.ethSigner,
ethAddress,
token,
this.encodingApi,
this.mintsApi,
this.config,
);
}
throw new Error('Nothing to withdraw');
}

public async registerAndCompleteWithdrawal(
walletConnection: WalletConnection,
token: AnyToken,
): Promise<TransactionResponse> {
await this.validateChain(walletConnection.ethSigner);

const starkExContractInfo = await this.getStarkExContractVersion();
const majorContractVersion = await this.parseMajorContractVersion(
starkExContractInfo.data.version,
);
const starkPublicKey = await walletConnection.starkSigner.getAddress();

if (majorContractVersion === 3) {
return completeWithdrawalV1Workflow(
walletConnection.ethSigner,
starkPublicKey,
token,
this.encodingApi,
this.usersApi,
this.mintsApi,
this.config,
);
} else if (majorContractVersion >= 4) {
return this.registerAndCompleteWithdrawalAll(
walletConnection,
starkPublicKey,
token,
);
} else {
throw new Error(
`Invalid StarkEx contract version (${majorContractVersion}). Please try again later.`,
);
}
}

private async registerAndCompleteWithdrawalAll(
walletConnection: WalletConnection,
starkPublicKey: string,
token: AnyToken,
): Promise<TransactionResponse> {
const ethAddress = await walletConnection.ethSigner.getAddress();
const { v3Balance, v4Balance } = await this.getWithdrawalBalances(
walletConnection.ethSigner,
starkPublicKey,
ethAddress,
token,
);

if (v3Balance.gt(0)) {
const isRegistered = await this.isRegisteredOnchain(walletConnection);
if (isRegistered) {
Expand Down

0 comments on commit e605e31

Please sign in to comment.