Skip to content

Commit

Permalink
Merge branch 'paris' of https://github.com/ecadlabs/taquito into pari…
Browse files Browse the repository at this point in the history
…sb-primitives
  • Loading branch information
hui-an-yang committed May 1, 2024
2 parents 17f8571 + e5a73d5 commit 9bda7ea
Show file tree
Hide file tree
Showing 52 changed files with 3,154 additions and 665 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ jobs:
include:
- testnet: oxfordnet
testnet_uppercase: OXFORDNET
- testnet: parisnet
testnet_uppercase: PARISNET
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand Down
1 change: 1 addition & 0 deletions apps/taquito-test-dapp/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ export const contractAddress = {
mainnet: "KT1ShtH2zCrKMuWGRejEd6RAcnePwxBQeMAN",
ghostnet: "KT1QKmcNBcfzVTXG2kBcE6XqXtEuYYUzMcT5",
oxfordnet: "KT1GYx1KDhMQt2GJEztRh8EyYxJUPM6fnAMM",
parisnet: "KT1LBQmSDGsRj4LFa2bsCsZLkGCtmRFVVcPh",
};
4 changes: 4 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"entrypoints",
"eztz",
"FAILWITH",
"Finalizable",
"flextesa",
"florencenet",
"forgeable",
Expand Down Expand Up @@ -71,6 +72,7 @@
"oxfordbox",
"oxfordnet",
"oxheadalpha",
"parisnet",
"Pkhfrom",
"preattestation",
"precommit",
Expand Down Expand Up @@ -115,10 +117,12 @@
"typeof",
"tzip",
"Umami",
"unfinalizable",
"unopt",
"UNPAIR",
"Unparsing",
"unstake",
"Unstaked",
"vals",
"walletbeacon",
"weeklynet",
Expand Down
2 changes: 1 addition & 1 deletion docs/quick_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Alternatively, you can use a `WalletProvider` to interact with a wallet. Please

## Examples

### Get the current Tezos balance for an address
### Get the current Tezos spendable balance for an address

```js live noInline
// import { TezosToolkit } from '@taquito/taquito';
Expand Down
198 changes: 105 additions & 93 deletions docs/rpc_nodes_integration_test.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/rpc_package.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const client = new RpcClient(' https://ghostnet.ecadinfra.com/', 'NetXLH1uAxK7CC
The `RpcClient` constructor takes the URL of the node you want to use and the chain ID.

```js
/* Fetching the balance of an account
/* Fetching the spendable balance of an account
* using the client set up above */

const balance = await client.getBalance('tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb');
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ tezosToolkit.tz.getBalance("tz1YvE7Sfo92ueEPEdZceNWd5MWNeMNSt16L").then(balance
});
```

Running `npx ts-node index.ts` should now show the balance of the specified address. This balance is in units of Mutez (micro Tez). Tez is the currency of Tezos, its code is `XTZ`, and the symbol is ``. 1 Tez is 1,000,000 Mutez.
Running `npx ts-node index.ts` should now show the spendable balance of the specified address. This balance is in units of Mutez (micro Tez). Tez is the currency of Tezos, its code is `XTZ`, and the symbol is ``. 1 Tez is 1,000,000 Mutez.

Congratulations! You have just interacted with the Tezos blockchain using Taquito. In the next section, we will establish a high-level understanding of the blockchain, Tezos, dApps, and Taquito. If you are already familiar with these concepts, you can skip to [Sending a Transfer operation to the blockchain using Taquito](#sending-operations).

Expand Down Expand Up @@ -239,7 +239,7 @@ For the purpose of this section, I have created a new address and funded it on t

<details>
<summary>How to create my own public/private key pair?</summary>

Most users can simply use a wallet to create addresses. This is useful for dApps that run inside a browser. If you are running a dApp as a desktop, mobile, or server process, you can create your own key pair. Here is how you can do it:

```bash
Expand Down
2 changes: 1 addition & 1 deletion docs/web3js_taquito.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const balance = await web3.eth.getBalance('account_address');
const balance = await Tezos.tz.getBalance('account_address');
```

Both Web3js and Taquito use the `getBalance` method with the account address to fetch its balance from the network.
Both Web3js and Taquito use the `getBalance` method with the account address to fetch its spendable balance from the network.

## Transfer tokens

Expand Down
2 changes: 1 addition & 1 deletion example/deploy-test-dapp-contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { InMemorySigner } from '@taquito/signer'
import { code, storage } from './data/test-dapp-contract';

// update the targeted rpc url before running
const rpcUrl = 'https://nairobinet.ecadinfra.com/'
const rpcUrl = 'http://parisnet.i.ecadinfra.com:8732'

originate(rpcUrl)

Expand Down
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"example:scan-path-ledger": "node -r ts-node/register --preserve-symlinks scan-path-ledger.ts"
},
"dependencies": {
"@ledgerhq/hw-transport-node-hid": "^6.27.21",
"@ledgerhq/hw-transport-node-hid": "^6.28.5",
"@taquito/ledger-signer": "^19.2.0",
"@taquito/local-forging": "^19.2.0",
"@taquito/michel-codec": "^19.2.0",
Expand Down
56 changes: 56 additions & 0 deletions integration-tests/__tests__/contract/operations/staking.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { CONFIGS } from "../../../config";

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

describe(`Staking pseudo operations: ${rpc}`, () => {

beforeAll(async () => {
await setup(true);

const delegateOp = await Tezos.contract.setDelegate({
delegate: 'tz1PZY3tEWmXGasYeehXYqwXuw2Z3iZ6QDnA',
source: await Tezos.signer.publicKeyHash()
});

await delegateOp.confirmation();
});

it('should throw an error when the destination specified is not the same as source', async () => {
expect(async () => {
const op = await Tezos.contract.stake({
amount: 0.1,
to: 'tz1PZY3tEWmXGasYeehXYqwXuw2Z3iZ6QDnA'
});
}).rejects.toThrow();
});

it('should be able to stake funds to a designated delegate', async () => {
const op = await Tezos.contract.stake({
amount: 0.1
});
await op.confirmation();

expect(op.hash).toBeDefined();
expect(op.status).toEqual('applied');
});

it('should be able to unstake funds from a designated delegate', async () => {
const op = await Tezos.contract.unstake({
amount: 0.1
});
await op.confirmation();

expect(op.hash).toBeDefined();
expect(op.status).toEqual('applied');
});

it('should be able to finalize_unstake funds from a designated delegate', async () => {
const op = await Tezos.contract.finalizeUnstake({});
await op.confirmation();

expect(op.hash).toBeDefined();
expect(op.status).toEqual('applied');
});
});
});
39 changes: 39 additions & 0 deletions integration-tests/__tests__/pseudo-entrypoints-forging.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { CONFIGS } from "../config";
import { DefaultContractType, UnitValue } from "@taquito/taquito";
import { LocalForger, ProtocolsHash } from '@taquito/local-forging'

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

describe(`Test forging pseudo entrypoints: ${rpc}`, () => {
let contract: DefaultContractType
// for every new protocol need to check https://tezos.gitlab.io/shell/p2p_api.html#alpha-entrypoint-determined-from-data-8-bit-tag for the latest entrypoints and corresponding tag
let entrypoint = { 0: 'default', 1: 'root', 2: 'do', 3: 'set_delegate', 4: 'remove_delegate', 5: 'deposit', 6: 'stake', 7: 'unstake', 8: 'finalize_unstake', 9: 'set_delegate_parameters' }

beforeAll(async () => {
await setup();
try {
// for every new entrypoint will need to modify the contract code to have new entrypoint covered
let op = await Tezos.contract.originate({
code: [{ "prim": "parameter", "args": [{ "prim": "or", "args": [{ "prim": "unit", "annots": ["%default"] }, { "prim": "or", "args": [{ "prim": "unit", "annots": ["%root"] }, { "prim": "or", "args": [{ "prim": "unit", "annots": ["%do"] }, { "prim": "or", "args": [{ "prim": "unit", "annots": ["%set_delegate"] }, { "prim": "or", "args": [{ "prim": "unit", "annots": ["%remove_delegate"] }, { "prim": "or", "args": [{ "prim": "unit", "annots": ["%deposit"] }, { "prim": "or", "args": [{ "prim": "unit", "annots": ["%stake"] }, { "prim": "or", "args": [{ "prim": "unit", "annots": ["%unstake"] }, { "prim": "or", "args": [{ "prim": "unit", "annots": ["%finalize_unstake"] }, { "prim": "unit", "annots": ["%set_delegate_parameters"] }] }] }] }] }] }] }] }] }] }] }, { "prim": "storage", "args": [{ "prim": "string" }] }, { "prim": "code", "args": [[{ "prim": "CAR" }, { "prim": "IF_LEFT", "args": [[{ "prim": "DROP" }, { "prim": "PUSH", "args": [{ "prim": "string" }, { "string": "default" }] }], [{ "prim": "IF_LEFT", "args": [[{ "prim": "DROP" }, { "prim": "PUSH", "args": [{ "prim": "string" }, { "string": "root" }] }], [{ "prim": "IF_LEFT", "args": [[{ "prim": "DROP" }, { "prim": "PUSH", "args": [{ "prim": "string" }, { "string": "do" }] }], [{ "prim": "IF_LEFT", "args": [[{ "prim": "DROP" }, { "prim": "PUSH", "args": [{ "prim": "string" }, { "string": "set_delegate" }] }], [{ "prim": "IF_LEFT", "args": [[{ "prim": "DROP" }, { "prim": "PUSH", "args": [{ "prim": "string" }, { "string": "remove_delegate" }] }], [{ "prim": "IF_LEFT", "args": [[{ "prim": "DROP" }, { "prim": "PUSH", "args": [{ "prim": "string" }, { "string": "deposit" }] }], [{ "prim": "IF_LEFT", "args": [[{ "prim": "DROP" }, { "prim": "PUSH", "args": [{ "prim": "string" }, { "string": "stake" }] }], [{ "prim": "IF_LEFT", "args": [[{ "prim": "DROP" }, { "prim": "PUSH", "args": [{ "prim": "string" }, { "string": "unstake" }] }], [{ "prim": "IF_LEFT", "args": [[{ "prim": "DROP" }, { "prim": "PUSH", "args": [{ "prim": "string" }, { "string": "finalize_unstake" }] }], [{ "prim": "DROP" }, { "prim": "PUSH", "args": [{ "prim": "string" }, { "string": "set_delegate_parameters" }] }]] }]] }]] }]] }]] }]] }]] }]] }]] }, { "prim": "NIL", "args": [{ "prim": "operation" }] }, { "prim": "PAIR" }]] }],
storage: 'init'
})
await op.confirmation();
contract = await op.contract();
} catch(e) {console.log(e)}
})

Object.values(entrypoint).forEach(name => {
it(`Verify that local forge will return same result as for rpc forge for entrypoints name ${name}`, async () => {
const localForger = new LocalForger(protocol as unknown as ProtocolsHash);
const methodObject = await contract.methodsObject[name](UnitValue)
const prepared = await Tezos.prepare.contractCall(methodObject)
const operation = Tezos.prepare.toForge(prepared)
const result = await localForger.forge(operation);
const rpcResult = await Tezos.rpc.forgeOperations(operation);
expect(result).toEqual(rpcResult);
});
})

});
});
Loading

0 comments on commit 9bda7ea

Please sign in to comment.