Skip to content

Commit

Permalink
2073 support type ticket deprecated in michelson encoder (#2094)
Browse files Browse the repository at this point in the history
* feat: exposed setParserProvider configuration through TezosToolkit

re #660

* test: added integration tests using setParserProvider with TezosToolkit

re #660

* docs: updated starting production server commands with taquito-test-dapp readme.md

* test: removed unnecessory console.log

re #660

* chore: update vite to latest version

* docs: fixed some typos in doc to address comments

re #660

* 1630 ballot operation support in contract API (#2050)

* added estimate and contract ballot operation support

* added rpc contract provider for ballot op

* updated implementation and added docs

* added property in OperationContentsAndResultBallot and added unit test

* remove metadata property from ballot

* addressed PR comments

* updated yarn and package-lock

* cleaned up comments and switched out async for promise in op emitter

* removed unnecessary line break

* 660 support customize parser options (#2061)

* feat: exposed setParserProvider configuration through TezosToolkit

re #660

* test: added integration tests using setParserProvider with TezosToolkit

re #660

* docs: updated starting production server commands with taquito-test-dapp readme.md

* test: removed unnecessory console.log

re #660

* chore: update vite to latest version

* docs: fixed some typos in doc to address comments

re #660

* feat(n): support type ticket_deprecated in michelson encoder

re #2073

* contract-security-non-existent-KT-address: use rpc (#2091)

* fix: address comment with TicketDeprecatedEncodeError and fix unit tests

fix #2073

Co-authored-by: Davis Sawali <[email protected]>
Co-authored-by: Arvid Jakobsson <[email protected]>
Co-authored-by: Roxane Létourneau <[email protected]>
  • Loading branch information
4 people authored Nov 4, 2022
1 parent 55e652f commit ec2e3b1
Show file tree
Hide file tree
Showing 34 changed files with 36,424 additions and 1,674 deletions.
5 changes: 4 additions & 1 deletion apps/taquito-test-dapp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ A minimal end-to-end testing setup for developing Tezos DApps with Taquito and B
`npm install`
4. Start development server:
`npm run dev`
5. Open http://localhost:3030 in your browser to see a sample application.
5. Open http://localhost:3030 in your browser to see a sample application.
6. Start production server:
`npm run build && npm run preview`
7. Open http://localhost:4173 in your browser to see a preview application.
2 changes: 1 addition & 1 deletion apps/taquito-test-dapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"svelte-preprocess": "^4.9.8",
"tslib": "^2.3.1",
"typescript": "^4.5.4",
"vite": "^2.9.7",
"vite": "^3.2.0",
"vite-compatible-readable-stream": "^3.6.1"
},
"dependencies": {
Expand Down
23 changes: 23 additions & 0 deletions docs/ballot.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
title: Ballot Operation
id: ballot
author: Davis Sawali
---

The `Ballot` operation allows delegates to cast one `Yay`, `Nay`, or `Pass` ballot on a selected proposal. Delegates are only able to cast their votes during the **Exploration period** and the **Promotion period**

## Examples
The `Ballot` operation is currently available in the Contract API, and can be used as such:
```typescript
const op = await Tezos.contract.ballot({
proposal: 'PROPOSAL_HASH',
ballot: 'BALLOT_VOTE_STRING'
});

await op.confirmation();
```
- `proposal` is the proposal hash string that you (a delegate) would like to point your ballot towards. Information on the current proposal can be obtained by calling [this RPC endpoint](https://tezos.gitlab.io/alpha/rpc.html#get-block-id-votes-current-proposal). Alternatively, you could also get the proposal hash by using Taquito's RPC Client method `RpcClient.getCurrentProposal`. For more information on the `RpcClient` refer to [this document](https://tezostaquito.io/docs/rpc_package/)
- `ballot` is your ballot vote (`yay`, `nay`, or `pass`)


For more information in regards to the Amendment (and Voting) Process refer to [this document](https://tezos.gitlab.io/alpha/voting.html)
54 changes: 53 additions & 1 deletion integration-tests/contract-michelson-origination.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,61 @@
import { IntegerError } from "@taquito/taquito";
import { IntegerError, MichelCodecParser, NoopParser, Context, InvalidCodeParameter } from '@taquito/taquito';
import { CONFIGS } from "./config";
import { idMichelsonCode, idInitData } from "./data/id-contract"

CONFIGS().forEach(({ lib, rpc, setup }) => {
const Tezos = lib;

describe(`Test contract origination to configure parserProvider to parse plain Michelson`, () => {

beforeEach(async (done) => {
await setup()
done()
})
it('uses noopParser to originate Michelson code and fails', async (done) => {
// Configure the Tezostoolkit to use the NoopParser (the Michelson won't be parsed)
Tezos.setParserProvider(new NoopParser());

try {
const op = await Tezos.contract.originate({
balance: "0",
code: idMichelsonCode,
init: idInitData
});
await op.confirmation()
} catch (error: any) {
expect(error).toBeInstanceOf(InvalidCodeParameter);
expect(error.message).toEqual('Wrong code parameter type, expected an array');
}
done();
});

it('uses MichelCodecParser to originate Michelson code and succeeds', async (done) => {
// Configure the Tezostoolkit to use the MichelCodecParser (the Michelson will be parsed to JSONMichelson)
Tezos.setParserProvider(new MichelCodecParser(new Context(rpc)));

const op = await Tezos.contract.originate({
balance: "0",
code: idMichelsonCode,
init: idInitData
});
await op.confirmation()
expect(op.status).toEqual('applied')
done();
});

it('no parser configured will use MichelCodecParser by default to originate Michelson code and succeeds', async (done) => {
// No parserProvider configured will use MichelCodecParser by default (the Michelson will be parsed to JSONMichelson)
const op = await Tezos.contract.originate({
balance: "0",
code: idMichelsonCode,
init: idInitData
});
await op.confirmation()
expect(op.status).toEqual('applied')
done();
});
});

describe(`Test contract origination in a plain Michelson through contract api using: ${rpc}`, () => {

beforeEach(async (done) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { Protocols, TezosToolkit } from '@taquito/taquito';

// KT1PWx2mnDueood7fEmfbBDKx1D9BAnnXitn is the tzBTC contract on mainnet

const Tezos = new TezosToolkit(new RpcClient('http://mondaynet.ecadinfra.com:8732'));
const testContractAddress = 'KT1PWx2mnDueood7fEmfbBDKx1D9BAnnXitn';

CONFIGS().forEach(({ rpc, setup, protocol }) => {
const mondaynet = protocol === Protocols.ProtoALpha ? test: test.skip;
const mondaynet = protocol === Protocols.ProtoALpha ? test : test.skip;
const Tezos = new TezosToolkit(new RpcClient(rpc));

describe(`Test contracts using: ${rpc}`, () => {
beforeEach(async (done) => {
Expand Down
59 changes: 58 additions & 1 deletion integration-tests/wallet-michelson-origination.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { CONFIGS } from "./config";
import { idMichelsonCode, idInitData } from "./data/id-contract"
import { idMichelsonCode, idInitData } from "./data/id-contract";
import { MichelCodecParser, NoopParser, Context, InvalidCodeParameter } from '@taquito/taquito';


CONFIGS().forEach(({ lib, rpc, setup }) => {
const Tezos = lib;
Expand All @@ -21,4 +23,59 @@ CONFIGS().forEach(({ lib, rpc, setup }) => {
done();
});
});

describe(`Test contract origination to configure parserProvider to parse plain Michelson`, () => {

beforeEach(async (done) => {
await setup()
done()
})
it('uses noopParser to originate Michelson code and fails', async (done) => {
// Configure the Tezostoolkit to use the NoopParser (the Michelson won't be parsed)
Tezos.setParserProvider(new NoopParser());

try {
const op = await Tezos.wallet.originate({
balance: "0",
code: idMichelsonCode,
init: idInitData
}).send();
await op.confirmation()
} catch (error: any) {
expect(error).toBeInstanceOf(InvalidCodeParameter);
expect(error.message).toEqual('Wrong code parameter type, expected an array');
}
done();
});

it('uses MichelCodecParser to originate Michelson code and succeeds', async (done) => {
// Configure the Tezostoolkit to use the MichelCodecParser (the Michelson will be parsed to JSONMichelson)
Tezos.setParserProvider(new MichelCodecParser(new Context(rpc)));

const op = await Tezos.wallet.originate({
balance: "0",
code: idMichelsonCode,
init: idInitData
}).send();
await op.confirmation()
expect(op.opHash).toBeDefined();
expect(op.status).toBeDefined();
done();
});

it('no parser configured will use MichelCodecParser by default to originate Michelson code and succeeds', async (done) => {
// No parserProvider configured will use MichelCodecParser by default (the Michelson will be parsed to JSONMichelson)
const op = await Tezos.wallet.originate({
balance: "0",
code: idMichelsonCode,
init: idInitData
}).send();
await op.confirmation()
expect(op.opHash).toBeDefined();
expect(op.status).toBeDefined();
done();
});
});


})
Loading

0 comments on commit ec2e3b1

Please sign in to comment.