From bc1072a6a7dd541a242b7609a3f5df3bdcb0843c Mon Sep 17 00:00:00 2001 From: Alireza Haghshenas Date: Wed, 13 Sep 2023 13:08:14 -0700 Subject: [PATCH] test: add an integration test --- integration-tests/contract-staking.spec.ts | 27 +++++++++++++++ packages/taquito/src/contract/interface.ts | 33 +++++++++++++++++++ .../src/contract/rpc-contract-provider.ts | 2 +- 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 integration-tests/contract-staking.spec.ts diff --git a/integration-tests/contract-staking.spec.ts b/integration-tests/contract-staking.spec.ts new file mode 100644 index 0000000000..321365d0d7 --- /dev/null +++ b/integration-tests/contract-staking.spec.ts @@ -0,0 +1,27 @@ +import { CONFIGS } from "./config"; + +CONFIGS().forEach(({ lib, rpc, setup, knownBaker }) => { + const Tezos = lib; + describe(`Test staking through contract API using: ${rpc}`, () => { + beforeEach(async (done) => { + await setup(true) + done() + }); + it('Should be able to stake', async (done) => { + const delegate = knownBaker + const pkh = await Tezos.signer.publicKeyHash(); + const op = await Tezos.contract.stake({ + baker: delegate, + amount: 0.1, + parameter: { + entrypoint: "stake", + value: { "prim": "Unit" } + } + }); + await op.confirmation() + expect(op.hash).toBeDefined(); + console.log(op); + done(); + }); + }); +}); \ No newline at end of file diff --git a/packages/taquito/src/contract/interface.ts b/packages/taquito/src/contract/interface.ts index c6fc72e036..8c35fc8dd2 100644 --- a/packages/taquito/src/contract/interface.ts +++ b/packages/taquito/src/contract/interface.ts @@ -24,6 +24,9 @@ import { SmartRollupAddMessagesParams, SmartRollupOriginateParams, FailingNoopParams, + StakeParams, + UnstakeParams, + FinalizeUnstakeParams, } from '../operations/types'; import { ContractAbstraction, ContractStorageType, DefaultContractType } from './contract'; import { IncreasePaidStorageOperation } from '../operations/increase-paid-storage-operation'; @@ -283,4 +286,34 @@ export interface ContractProvider extends StorageProvider { * @param params FailingNoop operation parameter */ failingNoop(params: FailingNoopParams): Promise; + + /** + * + * @description Stake founds. Will sign and inject an operation using the current context + * + * @returns An operation handle with the result from the rpc node + * + * @param stake operation parameter + */ + stake(params: StakeParams): Promise; + + /** + * + * @description Unstake founds. Will sign and inject an operation using the current context + * + * @returns An operation handle with the result from the rpc node + * + * @param unstake operation parameter + */ + unstake(params: UnstakeParams): Promise; + + /** + * + * @description Finalize unstake founds. Will sign and inject an operation using the current context + * + * @returns An operation handle with the result from the rpc node + * + * @param finalizeUnstake operation parameter + */ + unstake(params: FinalizeUnstakeParams): Promise; } diff --git a/packages/taquito/src/contract/rpc-contract-provider.ts b/packages/taquito/src/contract/rpc-contract-provider.ts index e0c091a23a..cfb57a4915 100644 --- a/packages/taquito/src/contract/rpc-contract-provider.ts +++ b/packages/taquito/src/contract/rpc-contract-provider.ts @@ -813,7 +813,7 @@ export class RpcContractProvider extends Provider implements ContractProvider, S /** * - * @description Unstake founds. Will sign and inject an operation using the current context + * @description Finalize unstake founds. Will sign and inject an operation using the current context * * @returns An operation handle with the result from the rpc node *