Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ecadlabs/taquito into sandbox-tes…
Browse files Browse the repository at this point in the history
…t-script-with-ballot-test-improvement
  • Loading branch information
hui-an-yang committed Jul 25, 2023
2 parents 049ad8c + bb1efc6 commit 2be0d21
Show file tree
Hide file tree
Showing 278 changed files with 16,408 additions and 7,475 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
- protocol: Nairobi
testnet: nairobinet
testnet_uppercase: NAIROBINET
flextesa_docker_image: oxheadalpha/flextesa:20230607
flextesa_docker_image: oxheadalpha/flextesa:20230502
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand Down
8 changes: 4 additions & 4 deletions apps/taquito-test-dapp/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "taquito-test-dapp-vite",
"private": true,
"version": "17.0.0",
"version": "17.1.0",
"type": "module",
"scripts": {
"dev": "vite",
Expand All @@ -25,9 +25,9 @@
},
"dependencies": {
"@airgap/beacon-sdk": "4.0.2",
"@taquito/beacon-wallet": "^17.0.0",
"@taquito/taquito": "^17.0.0",
"@taquito/utils": "^17.0.0",
"@taquito/beacon-wallet": "^17.1.0",
"@taquito/taquito": "^17.1.0",
"@taquito/utils": "^17.1.0",
"buffer": "^6.0.3",
"svelte-select": "^4.4.7",
"vite-compatible-readable-stream": "^3.6.1"
Expand Down
Binary file modified docs/images/github.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/gitlab.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 3 additions & 8 deletions docs/lambda_view.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ title: Lambda View
---

:::caution note
Lambda View implementation have recently changed due to a recent protocol update. Lambda Views now utilize the `run_view` endpoint. For more information refer to [this document](https://tezos.gitlab.io/CHANGES.html?highlight=run_view#id16)
Lambda View implementation have recently changed due to a recent protocol update. Lambda Views now utilize the `run_view` endpoint. For more information refer to [this document](https://tezos.gitlab.io/CHANGES.html?highlight=run_view#id16)
:::
Lambda View is a way to retrieve data from a smart contract's storage
without incurring fees via a contract's view method.
without incurring fees via a contract's view method.

## Recap: Views & Callbacks

Expand All @@ -20,18 +20,13 @@ specify parameters around what data you'd like to retrieve. They also require
you to supply a callback contract whose storage will update as a result of
executing the view method.

You can read more about views by going through the [FA1.2 Lorentz Tutorial][lorentz-tutorial]
in the TQ Tezos Assets Portal.

[lorentz-tutorial]: https://assets.tqtezos.com/docs/token-contracts/fa12/3-fa12-lorentz/#views

## Limitations to Views & Callbacks

One issue with using views and callbacks is that, just like any operation
executed on Tezos, each read has a small fee attached to it. The amount is
trivial for occasional reads, but it becomes a burden at higher volumes.

Another drawback is speed: since we're invoking a contract method, we have to wait for confirmation to retrieve the requested data. You may not find this
Another drawback is speed: since we're invoking a contract method, we have to wait for confirmation to retrieve the requested data. You may not find this
acceptable if the application you're working on requires consistent, faster
response times.

Expand Down
73 changes: 30 additions & 43 deletions docs/local_forger.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,62 +3,49 @@ title: Local Forging Package
id: local_forger
author: Michael Kernaghan
---
`@taquito/local-forging` allows developers to forge transactions locally without having to interact with a node. This document will outline some use cases and usage examples.

# How to Use the Taquito Local Forging Package

One of the tools offered by Taquito is the local forging package, which allows you to forge transactions locally without interacting with a node. Here is a step-by-step guide on how to use the Taquito local forging package:

## Step 1: Import the Local Forger

You will need to import the LocalForger class from Taquito to use the local forging package. You can do this by adding the following line to your code:

```
## Importing the Local Forger
The `LocalForger` package can be imported to your code like so:
```typescript
import { LocalForger } from '@taquito/local-forging';
```

## Step 2: Create a Transaction
## Forging a transaction
In order to forge the operation you must first prepare an operation.

Next, you must create a transaction you want to forge. You can do this using the Taquito library as you normally would. Here is an example of creating a transaction to transfer 1 XTZ from one address to another:
### Preparing a Transaction Operation
```typescript
import { TezosToolkit } from '@taquito/taquito'

```
import { TezosToolkit } from '@taquito/taquito';
const tezos = new TezosToolkit('<https://rpc.tezrpc.me>');
const from = 'tz1abc...xyz';
const to = 'tz1def...uvw';
const amount = 1;
const Tezos = new TezosToolkit(RPC_URL);

const transferOperation = await tezos.contract.transfer({ to, amount }).send({ from });
// The PrepareProvider returns a 'PreparedOperation' type object
const prepared = await Tezos.prepare.transaction({
source: SOURCE_PKH,
to: DESTINATION_PKH,
amount: 5
});

// The PreparedOperation type object needs to be converted into a forgeable type (ForgeParams)
const forgeable = await Tezos.prepare.toForge(prepared);
```

## Step 3: Forge the Transaction

Once you have created your transaction, you can use the LocalForger class. Here is an example of how to do this:

```
### Forging the Transaction Operation
```typescript
const forger = new LocalForger();
const forgedBytes = await forger.forge(transferOperation);
```

## Step 4: Sign the Transaction

After the transaction has been forged, you can sign it using your private key. Here is an example of how to sign the transaction:

const forgedBytes = await forger.forge(forgeable);
```
const { bytes: signatureBytes } = await tezos.signer.sign(forgedBytes, from);

### Signing the Operation
After the transaction operation has been forged, it can be signed as such:
```typescript
const signed = await Tezos.signer.sign(forgedBytes, new Uint8Array([3]))
```

## Step 5: Broadcast the Transaction

Finally, you can broadcast the signed transaction to the blockchain. Here is an example of how to do this using the Taquito library:

```
const operation = await tezos.rpc.sendOperation({ operation: signatureBytes });
```
### Injecting the Operation
Finally after signing, you can inject your operation to the blockchain.

That's it! You have now successfully used the Taquito local forging package to simulate the forging and signing of a transaction locally. This can be useful for testing and development, as it allows you to experiment with the transaction process without interacting with the blockchain.
```typescript
const op = await Tezos.rpc.injectOperation(signed.sbytes);
```
54 changes: 27 additions & 27 deletions docs/sapling.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Sapling Toolkit
author: Roxane Letourneau
---

Sapling is a protocol allowing private transactions in a decentralized environment.
Sapling is a protocol allowing private transactions in a decentralized environment.
Sapling was introduced in Tezos in the Edo protocol. Refer to the Tezos documentation for more information on Sapling: https://tezos.gitlab.io/active/sapling.html

## Keys
Expand Down Expand Up @@ -33,7 +33,7 @@ Here is an example on how to retrieve addresses: [InMemoryViewingKey](./sapling_

# Sapling toolkit

The `@taquito/sapling` package provides a `SaplingToolkit` class that surfaces all of the Sapling capabilities, allowing it to read from a Sapling state and prepare transactions.
The `@taquito/sapling` package provides a `SaplingToolkit` class that surfaces all of the Sapling capabilities, allowing it to read from a Sapling state and prepare transactions.

The constructor of the `SaplingToolkit` takes the following properties:
- the first parameter is an object containing:
Expand All @@ -55,20 +55,20 @@ import { RpcClient } from '@taquito/rpc';

const tezos = new TezosToolkit('https://ghostnet.ecadinfra.com/');
const readProvider = new RpcReadAdapter(new RpcClient('https://YOUR_PREFERRED_RPC_URL'));
const saplingContract = await tezos.contract.at('KT1UYwMR6Q6LZnwQEi77DSBrAjKT1tEJb245');
const saplingContract = await tezos.contract.at('KT1ToBD7bovonshNrxs3i4KMFuZ8PE2LUmQf');

const inMemorySpendingKey = await InMemorySpendingKey.fromMnemonic('YOUR_MNEMONIC');

const saplingToolkit = new SaplingToolkit(
{ saplingSigner: inMemorySpendingKey },
{ contractAddress: saplingContract.address, memoSize: 8 },
{ saplingSigner: inMemorySpendingKey },
{ contractAddress: saplingContract.address, memoSize: 8 },
readProvider
)
```

## How to retrieve my balance in the Sapling shielded pool?

When calling the `getSaplingTransactionViewer` method of the `SaplingToolkit` class, an instance of the `SaplingTransactionViewer` class is returned. The `SaplingTransactionViewer` class allows retrieving and decrypting Sapling transactions for the specified viewing key and calculating the unspent balance.
When calling the `getSaplingTransactionViewer` method of the `SaplingToolkit` class, an instance of the `SaplingTransactionViewer` class is returned. The `SaplingTransactionViewer` class allows retrieving and decrypting Sapling transactions for the specified viewing key and calculating the unspent balance.

For each entry in the shielded pool, the `SaplingTransactionViewer` class will try to decrypt them using the viewing key as if it were the receiver. If a ciphertext is successfully decrypted, the configured account was the receiver of the output. The `SaplingTransactionViewer` will find which inputs were not spent by computing their nullifier. If an input is spent, its nullifier will be in the Sapling state. If the nullifier is not present, the input has not been spent, and its value will be considered in the calculated balance.

Expand All @@ -89,8 +89,8 @@ const inMemorySpendingKey = new InMemorySpendingKey(aliceSk);
const readProvider = new RpcReadAdapter(new RpcClient('https://ghostnet.ecadinfra.com/'));

const saplingToolkit = new SaplingToolkit(
{ saplingSigner: inMemorySpendingKey },
{ contractAddress: 'KT1JMDxmQ4DAbzXpzAJmL6QeZ9HB7DTVnZYd', memoSize: 8 },
{ saplingSigner: inMemorySpendingKey },
{ contractAddress: 'KT1ToBD7bovonshNrxs3i4KMFuZ8PE2LUmQf', memoSize: 8 },
readProvider
);

Expand Down Expand Up @@ -122,8 +122,8 @@ const inMemorySpendingKey = new InMemorySpendingKey(aliceSk);
const readProvider = new RpcReadAdapter(new RpcClient('https://ghostnet.ecadinfra.com/'));

const saplingToolkit = new SaplingToolkit(
{ saplingSigner: inMemorySpendingKey },
{ contractAddress: 'KT1JMDxmQ4DAbzXpzAJmL6QeZ9HB7DTVnZYd', memoSize: 8 },
{ saplingSigner: inMemorySpendingKey },
{ contractAddress: 'KT1ToBD7bovonshNrxs3i4KMFuZ8PE2LUmQf', memoSize: 8 },
readProvider
);

Expand All @@ -138,7 +138,7 @@ saplingToolkit.getSaplingTransactionViewer()

## How to prepare a shielded transaction?

A shielded transaction allows sending tokens from a Tezos account (tz1, tz2, tz3) to a Sapling address (zet). The `prepareShieldedTransaction` method of the `SaplingToolkit` takes an array of `ParametersSaplingTransaction`, making it possible to send tez to multiple addresses at once if needed.
A shielded transaction allows sending tokens from a Tezos account (tz1, tz2, tz3) to a Sapling address (zet). The `prepareShieldedTransaction` method of the `SaplingToolkit` takes an array of `ParametersSaplingTransaction`, making it possible to send tez to multiple addresses at once if needed.

The `ParametersSaplingTransaction` is an object made of:
- a `to` property, which is the destination address (zet)
Expand All @@ -155,7 +155,7 @@ Here is an example of how to prepare and inject a shielded transaction using Taq
// import { SaplingToolkit, InMemorySpendingKey } from '@taquito/sapling';
// import { RpcClient } from '@taquito/rpc';

const saplingContractAddress = 'KT1JMDxmQ4DAbzXpzAJmL6QeZ9HB7DTVnZYd'
const saplingContractAddress = 'KT1ToBD7bovonshNrxs3i4KMFuZ8PE2LUmQf'
const rpcUrl = 'https://ghostnet.ecadinfra.com/';
const readProvider = new RpcReadAdapter(new RpcClient(rpcUrl));
// const Tezos = new TezosToolkit(rpcUrl);
Expand All @@ -167,8 +167,8 @@ const aliceSk = 'sask27SLmU9herddHz4qFJBLMjWYMbJF8RtS579w9ej9mfCYK7VUdyCJPHK8AzW
const inMemorySpendingKey = new InMemorySpendingKey(aliceSk);

const saplingToolkit = new SaplingToolkit(
{ saplingSigner: inMemorySpendingKey },
{ contractAddress: saplingContractAddress, memoSize: 8 },
{ saplingSigner: inMemorySpendingKey },
{ contractAddress: saplingContractAddress, memoSize: 8 },
readProvider
);

Expand Down Expand Up @@ -206,15 +206,15 @@ inMemorySpendingKey.getSaplingViewingKeyProvider()

## How to prepare a Sapling transaction?

A Sapling transaction allows sending tokens from an address (zet) to an address (zet). The `prepareSaplingTransaction` method of the `SaplingToolkit` takes an array of `ParametersSaplingTransaction`, making it possible to send tez to multiple addresses at once if needed.
A Sapling transaction allows sending tokens from an address (zet) to an address (zet). The `prepareSaplingTransaction` method of the `SaplingToolkit` takes an array of `ParametersSaplingTransaction`, making it possible to send tez to multiple addresses at once if needed.

The `ParametersSaplingTransaction` is an object made of:
- a `to` property, which is the destination address (zet)
- an `amount` property, which is the amount to shield in tez by default
- an optional `memo` that cannot be longer than the specified memo size
- an optional `mutez` property that must be set to true if the specified amount is in mutez rather than tez

The `prepareSaplingTransaction` method returns the crafted Sapling transaction parameter but does not perform any change on the shielded pool. A subsequent step where the Sapling transaction parameter is submitted to the smart contract must be done.
The `prepareSaplingTransaction` method returns the crafted Sapling transaction parameter but does not perform any change on the shielded pool. A subsequent step where the Sapling transaction parameter is submitted to the smart contract must be done.

:::note
A user should not use their own implicit account (tz1, tz2, tz3) to submit a Sapling transaction but rather have a third party inject it.
Expand All @@ -227,7 +227,7 @@ Here is an example of how to prepare and inject a Sapling transaction using Taqu
// import { SaplingToolkit, InMemorySpendingKey } from '@taquito/sapling';
// import { RpcClient } from '@taquito/rpc';

const saplingContractAddress = 'KT1JMDxmQ4DAbzXpzAJmL6QeZ9HB7DTVnZYd'
const saplingContractAddress = 'KT1ToBD7bovonshNrxs3i4KMFuZ8PE2LUmQf'
const rpcUrl = 'https://ghostnet.ecadinfra.com/';
const readProvider = new RpcReadAdapter(new RpcClient(rpcUrl));
// const Tezos = new TezosToolkit(rpcUrl);
Expand All @@ -239,8 +239,8 @@ const aliceSk = 'sask27SLmU9herddHz4qFJBLMjWYMbJF8RtS579w9ej9mfCYK7VUdyCJPHK8AzW
const inMemorySpendingKey = new InMemorySpendingKey(aliceSk);

const saplingToolkit = new SaplingToolkit(
{ saplingSigner: inMemorySpendingKey },
{ contractAddress: saplingContractAddress, memoSize: 8 },
{ saplingSigner: inMemorySpendingKey },
{ contractAddress: saplingContractAddress, memoSize: 8 },
readProvider
);

Expand Down Expand Up @@ -276,7 +276,7 @@ The `ParametersUnshieldedTransaction` is an object made of:
- an `amount` property, which is the amount to shield in tez by default
- an optional `mutez` property that must be set to true if the specified amount is in mutez rather than tez

The `prepareUnshieldedTransaction` method returns the crafted Sapling transaction parameter but does not perform any change on the shielded pool. A subsequent step where the Sapling transaction parameter is submitted to the smart contract must be done to retrieve the tokens from the pool.
The `prepareUnshieldedTransaction` method returns the crafted Sapling transaction parameter but does not perform any change on the shielded pool. A subsequent step where the Sapling transaction parameter is submitted to the smart contract must be done to retrieve the tokens from the pool.

Here is an example of how to prepare and inject an unshielded transaction using Taquito:

Expand All @@ -285,7 +285,7 @@ Here is an example of how to prepare and inject an unshielded transaction using
// import { SaplingToolkit, InMemorySpendingKey } from '@taquito/sapling';
// import { RpcClient } from '@taquito/rpc';

const saplingContractAddress = 'KT1JMDxmQ4DAbzXpzAJmL6QeZ9HB7DTVnZYd'
const saplingContractAddress = 'KT1ToBD7bovonshNrxs3i4KMFuZ8PE2LUmQf'
const rpcUrl = 'https://ghostnet.ecadinfra.com/';
const readProvider = new RpcReadAdapter(new RpcClient(rpcUrl));
// const Tezos = new TezosToolkit(rpcUrl);
Expand All @@ -297,8 +297,8 @@ const aliceSk = 'sask27SLmU9herddHz4qFJBLMjWYMbJF8RtS579w9ej9mfCYK7VUdyCJPHK8AzW
const inMemorySpendingKey = new InMemorySpendingKey(aliceSk);

const saplingToolkit = new SaplingToolkit(
{ saplingSigner: inMemorySpendingKey },
{ contractAddress: saplingContractAddress, memoSize: 8 },
{ saplingSigner: inMemorySpendingKey },
{ contractAddress: saplingContractAddress, memoSize: 8 },
readProvider
);

Expand Down Expand Up @@ -329,7 +329,7 @@ saplingToolkit.prepareUnshieldedTransaction({
We don't require the spending key to retrieve the balance and transaction history. It can be done using the viewing key and the SaplingTransactionViewer class.

The constructor of the `SaplingTransactionViewer` takes the following properties:
- an instance of `InMemoryViewingKey`
- an instance of `InMemoryViewingKey`
- the second parameter is an object containing:
- the address of the Sapling contract or a Sapling id if the contract contains more than one Sapling state.
- an instance of a class implementing the `TzReadProvider` interface, which allows getting data from the blockchain
Expand All @@ -344,15 +344,15 @@ import { RpcClient } from '@taquito/rpc';
const readProvider = new RpcReadAdapter(new RpcClient('https://YOUR_PREFERRED_RPC_URL'));
const tezos = new TezosToolkit('https://ghostnet.ecadinfra.com/');

const saplingContract = await tezos.contract.at('KT1JMDxmQ4DAbzXpzAJmL6QeZ9HB7DTVnZYd');
const saplingContract = await tezos.contract.at('KT1ToBD7bovonshNrxs3i4KMFuZ8PE2LUmQf');

const inMemoryViewingKey = new InMemoryViewingKey(
'000000000000000000977d725fc96387e8ec1e603e7ae60c6e63529fb84e36e126770e9db9899d7f2344259fd700dc80120d3c9ca65d698f6064043b048b079caa4f198aed96271740b1d6fd523d71b15cd0b3d75644afbe9abfedb6883e299165665ab692c14ca5c835c61a0e53de553a751c78fbc42d5e7eca807fd441206651c84bf88de803efba837583145a5f338b1a7af8a5f9bec4783054f9d063d365f2352f72cbced95e0a'
);

const saplingTransactionViewer = new SaplingTransactionViewer(
inMemoryViewingKey,
{ contractAddress: saplingContract.address },
inMemoryViewingKey,
{ contractAddress: saplingContract.address },
readProvider
)
```
Expand Down
21 changes: 21 additions & 0 deletions docs/version.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@
title: Versions
author: Jev Bjorsell
---
# Taquito v17.1.0
**Potential Breaking Changes**
- Updated RxJS version from v6.6.3 to v7.8.1
- Updated TS version into v4.2.4
- Please be wary due to the RxJS version upgrade, we've been seeing intermittent timeouts when testing against a Flextesa sandbox. This behaviour is **not** present when using it against a regular node (Mainnet, Nairobinet, etc). We are still investigating what the cause might be. #2261

## Summary
### New Features
- Exposed the injector to be customizable from the TezosToolkit class #1344

### Improvement
- Simplified generated Lambda for `transferToContract` [PR#2404](https://github.com/ecadlabs/taquito/pull/2404)
- Improved error classes for these following packages:
- `@taquito/taquito` [PR#2559](https://github.com/ecadlabs/taquito/pull/2559)
- `@taquito/michelson-encoder` #1995
- `@taquito/tzip12` [PR#2559](https://github.com/ecadlabs/taquito/pull/2559)
- `@taquito/tzip16` [PR#2559](https://github.com/ecadlabs/taquito/pull/2559)

### Internals
- Updated version dependencies for `Sass` and `Dotenv` in `/website` [PR#2560](https://github.com/ecadlabs/taquito/pull/2560)

# Taquito v17
### Potential Breaking Changes
Protocol Nairobi comes with a couple potential breaking changes for our users:
Expand Down
Loading

0 comments on commit 2be0d21

Please sign in to comment.