diff --git a/integration-tests/__tests__/wallet/staking-pseudo-operations.spec.ts b/integration-tests/__tests__/wallet/staking-pseudo-operations.spec.ts index 4aa9137437..3b34f4ee0d 100644 --- a/integration-tests/__tests__/wallet/staking-pseudo-operations.spec.ts +++ b/integration-tests/__tests__/wallet/staking-pseudo-operations.spec.ts @@ -3,7 +3,7 @@ import { Protocols } from '@taquito/taquito'; import { ProtoGreaterOrEqual } from '@taquito/michel-codec'; import { InvalidStakingAddressError, InvalidFinalizeUnstakeAmountError } from '@taquito/core'; -CONFIGS().forEach(({ lib, rpc, setup, protocol }) => { +CONFIGS().forEach(({ lib, rpc, setup, protocol, knownBaker }) => { const Tezos = lib; const parisAndAlpha = ProtoGreaterOrEqual(protocol, Protocols.PtParisBQ) ? test : test.skip; describe(`Test staking pseudo operations using: ${rpc}`, () => { @@ -11,7 +11,7 @@ CONFIGS().forEach(({ lib, rpc, setup, protocol }) => { await setup(true); try { const delegateOp = await Tezos.contract.setDelegate({ - delegate: 'tz1PZY3tEWmXGasYeehXYqwXuw2Z3iZ6QDnA', // can use knownBaker in future + delegate: knownBaker, source: await Tezos.signer.publicKeyHash() }); await delegateOp.confirmation(); @@ -21,27 +21,27 @@ CONFIGS().forEach(({ lib, rpc, setup, protocol }) => { }); parisAndAlpha(`should be able to stake successfully: ${rpc}`, async () => { - const op = await Tezos.wallet.stake({ amount: 3000000, mutez: true }).send() + const op = await Tezos.wallet.stake({ amount: 3 }).send() await op.confirmation(); - expect(op.status).toBeTruthy(); + expect(await op.status()).toBe('applied'); const stakedBalance = await Tezos.rpc.getStakedBalance(await Tezos.signer.publicKeyHash()); - expect(stakedBalance.toNumber()).toEqual(3000000); + expect(Math.round(stakedBalance.toNumber()/1000000)).toEqual(3); // staked balance returned in mutez therefore dividing by 1000000 }); parisAndAlpha(`should be able to unstake successfully: ${rpc}`, async () => { const op = await Tezos.wallet.unstake({ amount: 1 }).send() await op.confirmation(); - expect(op.status).toBeTruthy(); + expect(await op.status()).toBe('applied'); const UnstakedBalance = await Tezos.rpc.getUnstakedFrozenBalance(await Tezos.signer.publicKeyHash()); - expect(UnstakedBalance.toNumber()).toEqual(1000000); // 1000000 mutez = 1 tez + expect(Math.round(UnstakedBalance.toNumber()/1000000)).toEqual(1); // unstaked balance returned in mutez therefore dividing by 1000000 }); parisAndAlpha(`should be able to finalizeUnstake successfully: ${rpc}`, async () => { const op = await Tezos.wallet.finalizeUnstake({ }).send() await op.confirmation(); - expect(op.status).toBeTruthy(); + expect(await op.status()).toBe('applied'); }); parisAndAlpha('should throw error when param is against pseudo operation', async () => { diff --git a/packages/taquito/src/wallet/wallet.ts b/packages/taquito/src/wallet/wallet.ts index 11ed4826e7..0af50df660 100644 --- a/packages/taquito/src/wallet/wallet.ts +++ b/packages/taquito/src/wallet/wallet.ts @@ -54,9 +54,7 @@ export class WalletOperationBatch { ) {} /** - * * @description Add a transaction operation to the batch - * * @param params Transfer operation parameter */ withTransfer(params: WalletTransferParams) { @@ -69,9 +67,7 @@ export class WalletOperationBatch { } /** - * * @description Add a contract call to the batch - * * @param params Call a contract method * @param options Generic operation parameters */ @@ -83,9 +79,7 @@ export class WalletOperationBatch { } /** - * * @description Add a delegation operation to the batch - * * @param params Delegation operation parameter */ withDelegation(params: WalletDelegateParams) { @@ -98,9 +92,7 @@ export class WalletOperationBatch { } /** - * * @description Add an origination operation to the batch - * * @param params Origination operation parameter */ withOrigination( @@ -111,9 +103,7 @@ export class WalletOperationBatch { } /** - * * @description Add an IncreasePaidStorage operation to the batch - * * @param param IncreasePaidStorage operation parameter */ withIncreasePaidStorage(params: WalletIncreasePaidStorageParams) { @@ -145,9 +135,7 @@ export class WalletOperationBatch { } /** - * * @description Add a group operation to the batch. Operation will be applied in the order they are in the params array - * * @param params Operations parameter * @throws {@link InvalidOperationKindError} */ @@ -175,9 +163,7 @@ export class WalletOperationBatch { } /** - * * @description Submit batch operation to wallet - * */ async send() { const ops: WalletParamsWithKind[] = []; @@ -204,7 +190,6 @@ export class Wallet { /** * @description Retrieve the PKH of the account that is currently in use by the wallet - * * @param option Option to use while fetching the PKH. * If forceRefetch is specified the wallet provider implementation will refetch the PKH from the wallet */ @@ -217,7 +202,6 @@ export class Wallet { /** * @description Retrieve the PK of the account that is currently in use by the wallet - * * @param option Option to use while fetching the PK. * If forceRefetch is specified the wallet provider implementation will refetch the PK from the wallet */ @@ -235,11 +219,8 @@ export class Wallet { }; /** - * * @description Originate a new contract according to the script in parameters. - * * @returns An operation handle with the result from the rpc node - * * @param originateParams Originate operation parameter */ originate( @@ -259,11 +240,8 @@ export class Wallet { } /** - * * @description Set the delegate for a contract. - * * @returns An operation handle with the result from the rpc node - * * @param delegateParams operation parameter */ setDelegate(params: WalletDelegateParams) { @@ -281,11 +259,8 @@ export class Wallet { } /** - * * @description failing_noop operation that is guaranteed to fail. DISCLAIMER: Not all wallets support signing failing_noop operations. - * * @returns Signature for a failing_noop - * * @param params operation parameter */ async signFailingNoop(params: WalletFailingNoopParams) { @@ -315,11 +290,8 @@ export class Wallet { } /** - * * @description Register the current address as delegate. - * * @returns An operation handle with the result from the rpc node - * */ registerDelegate() { return this.walletCommand(async () => { @@ -333,11 +305,8 @@ export class Wallet { } /** - * * @description Transfer tezos tokens from current address to a specific address or call a smart contract. - * * @returns A wallet command from which we can send the operation to the wallet - * * @param params operation parameter */ transfer(params: WalletTransferParams) { @@ -355,11 +324,8 @@ export class Wallet { } /** - * * @description Stake a given amount for the source address - * - * @returns An operation handle with the result from the rpc node - * + * @returns A wallet command from which we can send the operation to the wallet * @param Stake pseudo-operation parameter */ stake(params: WalletStakeParams) { @@ -381,13 +347,10 @@ export class Wallet { } /** - * * @description Unstake the given amount. If "everything" is given as amount, unstakes everything from the staking balance. * Unstaked tez remains frozen for a set amount of cycles (the slashing period) after the operation. Once this period is over, * the operation "finalize unstake" must be called for the funds to appear in the liquid balance. - * - * @returns An operation handle with the result from the rpc node - * + * @returns A wallet command from which we can send the operation to the wallet * @param Unstake pseudo-operation parameter */ unstake(params: WalletUnstakeParams) { @@ -409,10 +372,8 @@ export class Wallet { } /** - * * @description Transfer all the finalizable unstaked funds of the source to their liquid balance - * @returns An operation handle with the result from the rpc node - * + * @returns A wallet command from which we can send the operation to the wallet * @param Finalize_unstake pseudo-operation parameter */ finalizeUnstake(params: WalletFinalizeUnstakeParams) { @@ -442,11 +403,8 @@ export class Wallet { } /** - * * @description Increase the paid storage of a smart contract. - * * @returns A wallet command from which we can send the operation to the wallet - * * @param params operation parameter */ increasePaidStorage(params: WalletIncreasePaidStorageParams) { @@ -464,11 +422,8 @@ export class Wallet { } /** - * * @description Create a batch of operation - * * @returns A batch object from which we can add more operation or send a command to the wallet to execute the batch - * * @param params List of operation to initialize the batch with */ batch(params?: Parameters[0]) { @@ -482,10 +437,8 @@ export class Wallet { } /** - * * @description Create an smart contract abstraction for the address specified. Calling entrypoints with the returned * smart contract abstraction will leverage the wallet provider to make smart contract calls - * * @param address Smart contract address * @throws {@link InvalidContractAddressError} If the contract address is not valid */