Skip to content

Commit

Permalink
chore: remove staking implementation from the wallet api
Browse files Browse the repository at this point in the history
  • Loading branch information
ac10n committed Sep 14, 2023
1 parent 0645ed7 commit 5ff53cf
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 84 deletions.
16 changes: 0 additions & 16 deletions packages/taquito-beacon-wallet/src/taquito-beacon-wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
WalletIncreasePaidStorageParams,
WalletOriginateParams,
WalletProvider,
WalletStakingParams,
WalletTransferParams,
} from '@taquito/taquito';
import { buf2hex, hex2buf, mergebuf } from '@taquito/utils';
Expand Down Expand Up @@ -127,21 +126,6 @@ export class BeaconWallet implements WalletProvider {
);
}

async mapStakingParamsToWalletParams(params: () => Promise<WalletStakingParams>) {
let walletParams: WalletStakingParams;
await this.client.showPrepare();
try {
walletParams = await params();
} catch (err) {
await this.client.hideUI();
throw err;
}
return this.removeDefaultParams(
walletParams,
await createTransferOperation(this.formatParameters(walletParams))
);
}

formatParameters(params: any) {
if (params.fee) {
params.fee = params.fee.toString();
Expand Down
5 changes: 0 additions & 5 deletions packages/taquito/src/wallet/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,4 @@ export interface WalletProvider {
* @description Get the public key from the wallet
*/
getPK(): Promise<string>;

/**
* @description Transform WalletStakingParams into a format compliant with the underlying wallet
*/
mapStakingParamsToWalletParams: (params: () => Promise<WalletStakingParams>) => Promise<any>;
}
5 changes: 0 additions & 5 deletions packages/taquito/src/wallet/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
WalletIncreasePaidStorageParams,
WalletOriginateParams,
WalletProvider,
WalletStakingParams,
WalletTransferParams,
} from './interface';
import { WalletParamsWithKind } from './wallet';
Expand Down Expand Up @@ -46,8 +45,4 @@ export class LegacyWalletProvider implements WalletProvider {
getPK() {
return this.context.signer.publicKey();
}

async mapStakingParamsToWalletParams(params: () => Promise<WalletStakingParams>) {
return attachKind(await params(), OpKind.TRANSACTION);
}
}
59 changes: 1 addition & 58 deletions packages/taquito/src/wallet/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from '../contract';
import { ContractMethod } from '../contract/contract-methods/contract-method-flat-param';
import { ContractMethodObject } from '../contract/contract-methods/contract-method-object-param';
import { OpKind, StakingParams, withKind } from '../operations/types';
import { OpKind, withKind } from '../operations/types';
import { OriginationWalletOperation } from './origination-operation';
import {
WalletDelegateParams,
Expand Down Expand Up @@ -409,61 +409,4 @@ export class Wallet {
getPK() {
return this.walletProvider.getPK();
}

/**
*
* @description Stake funds.
*
* @returns An operation handle with the result from the rpc node
*
* @param Stake operation parameter
*/
stake(params: StakingParams) {
// TODO: validate the baker
return this.walletCommand(async () => {
const mappedParams = await this.walletProvider.mapStakingParamsToWalletParams(
async () => params
);
const opHash = await this.walletProvider.sendOperations([mappedParams]);
return this.context.operationFactory.createTransactionOperation(opHash);
});
}

/**
*
* @description Unstake funds.
*
* @returns An operation handle with the result from the rpc node
*
* @param Unstake operation parameter
*/
unstake(params: StakingParams) {
// TODO: validate the baker
return this.walletCommand(async () => {
const mappedParams = await this.walletProvider.mapStakingParamsToWalletParams(
async () => params
);
const opHash = await this.walletProvider.sendOperations([mappedParams]);
return this.context.operationFactory.createTransactionOperation(opHash);
});
}

/**
*
* @description FinalizeUnstake funds.
*
* @returns An operation handle with the result from the rpc node
*
* @param Unstake operation parameter
*/
finalizeUnstake(params: StakingParams) {
// TODO: validate the baker
return this.walletCommand(async () => {
const mappedParams = await this.walletProvider.mapStakingParamsToWalletParams(
async () => params
);
const opHash = await this.walletProvider.sendOperations([mappedParams]);
return this.context.operationFactory.createTransactionOperation(opHash);
});
}
}

0 comments on commit 5ff53cf

Please sign in to comment.