Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Beacon 4.2.2" #2967

Merged
merged 1 commit into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 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": "19.2.1",
"version": "19.2.0",
"type": "module",
"scripts": {
"dev": "vite",
Expand All @@ -24,12 +24,12 @@
"vite": "^4.4.11"
},
"dependencies": {
"@airgap/beacon-sdk": "^4.2.2",
"@airgap/beacon-types": "^4.2.2",
"@taquito/beacon-wallet": "^19.2.1",
"@taquito/core": "^19.2.1",
"@taquito/taquito": "^19.2.1",
"@taquito/utils": "^19.2.1",
"@airgap/beacon-sdk": "^4.2.1",
"@airgap/beacon-types": "^4.2.1",
"@taquito/beacon-wallet": "^19.2.0",
"@taquito/core": "^19.1.0",
"@taquito/taquito": "^19.2.0",
"@taquito/utils": "^19.2.0",
"buffer": "^6.0.3",
"svelte-select": "^5.7.0",
"vite-compatible-readable-stream": "^3.6.1"
Expand Down
24 changes: 21 additions & 3 deletions apps/taquito-test-dapp/src/lib/TestContainer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
let loading = false;
let success: boolean | undefined;
let opHash = "";
let input = { text: "", fee: 400, storageLimit: 400, gasLimit: 1320 };
let input = { text: "", fee: 400, storageLimit: 400, gasLimit: 1320, amount: 0, address: "" };
let testResult: { id: string; title: string; body: any };

const run = async () => {
Expand All @@ -28,6 +28,7 @@
test.id === "sign-payload-and-send" ||
test.id === "sign-failingNoop" ||
test.id === "verify-signature" ||
test.id === "send-tez-to-etherlink" ||
test.id === "set-transaction-limits"
) {
result = await test.run(input);
Expand Down Expand Up @@ -188,7 +189,7 @@
/* ----------------------------------------------
* Generated by Animista on 2022-4-21 9:31:8
* Licensed under FreeBSD License.
* See http://animista.net/license for more info.
* See http://animista.net/license for more info.
* w: http://animista.net, t: @cssanimista
* ---------------------------------------------- */

Expand Down Expand Up @@ -302,6 +303,19 @@
bind:value={input.text}
/>
</div>
{:else if test.inputRequired && test.inputType === "etherlink"}
<div class="test-input test-send-tez-to-etherlink">
<label for="etherlink-address">
<span>Etherlink address</span>
<input type="string" id="etherlink-address" bind:value={input.address} />
</label>
<br />
<br />
<label for="send-amount">
<span>amount</span>
<input type="number" id="send-amount" bind:value={input.amount} />
</label>
</div>
{:else if test.inputRequired && test.inputType === "set-limits"}
<div class="test-input test-limits">
<label for="set-limit-fee">
Expand Down Expand Up @@ -338,7 +352,11 @@
{#if $store.networkType === NetworkType.CUSTOM}
{shortenHash(opHash)}
{:else}
<a href={`${getTzKtUrl($store.networkType)}/${opHash}`} target="_blank" rel="noopener noreferrer">
<a
href={`${getTzKtUrl($store.networkType)}/${opHash}`}
target="_blank"
rel="noopener noreferrer"
>
{shortenHash(opHash)}
</a>
{/if}
Expand Down
13 changes: 5 additions & 8 deletions apps/taquito-test-dapp/src/lib/Wallet.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,15 @@
import { BeaconEvent, type DAppClientOptions } from "@airgap/beacon-sdk";
import store from "../store";
import { formatTokenAmount, shortenHash } from "../utils";
import {
defaultMatrixNode,
getRpcUrl,
defaultNetworkType,
type SupportedNetworks,
} from "../config";
import { defaultMatrixNode, getRpcUrl, defaultNetworkType, type SupportedNetworks } from "../config";
import type { TezosAccountAddress } from "../types";

let showDialog = false;
let connectedWallet = "";

const createNewWallet = (config: { networkType: SupportedNetworks }) => {
const createNewWallet = (config: {
networkType: SupportedNetworks,
}) => {
const options: DAppClientOptions = {
name: "Taquito Test Dapp",
matrixNodes: [defaultMatrixNode] as any,
Expand All @@ -26,7 +23,7 @@
rpcUrl: getRpcUrl(config.networkType),
},
walletConnectOptions: {
projectId: "ba97fd7d1e89eae02f7c330e14ce1f36",
projectId: 'ba97fd7d1e89eae02f7c330e14ce1f36',
},
enableMetrics: $store.enableMetrics,
};
Expand Down
42 changes: 40 additions & 2 deletions apps/taquito-test-dapp/src/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,25 @@ const preparePayloadToSign = (
};
};

const sendTezToEtherlink = async (
amount: number,
address: string,
tezos: TezosToolkit,
): Promise<TestResult> => {
let opHash = "";
try {
const contract = await tezos.wallet.at('KT1VEjeQfDBSfpDH5WeBM5LukHPGM2htYEh3')
let op = await contract.methodsObject.deposit({ evm_address: 'sr18wx6ezkeRjt1SZSeZ2UQzQN3Uc3YLMLqg', l2_address: address }).send({ amount });
await op.confirmation()
opHash = op.hasOwnProperty("opHash") ? op["opHash"] : op["hash"];
console.log("Operation successful with op hash:", opHash);
return { success: true, opHash };
} catch (error) {
console.log(error);
return { success: false, opHash: "" };
}
};

const sendTez = async (Tezos: TezosToolkit): Promise<TestResult> => {
let opHash = "";
try {
Expand Down Expand Up @@ -302,7 +321,7 @@ const signPayloadAndSend = async (
const publicKey = activeAccount.publicKey;
// sends transaction to contract
const op = await contract.methodsObject
.check_signature({0: publicKey, 1: signedPayload.signature, 2: payload.payload})
.check_signature({ 0: publicKey, 1: signedPayload.signature, 2: payload.payload })
.send();
await op.confirmation();
return {
Expand Down Expand Up @@ -455,7 +474,7 @@ const permit = async (Tezos: TezosToolkit, wallet: BeaconWallet) => {
const contract = await Tezos.wallet.at(contractAddress);
// hashes the parameter for the contract call
const mintParam: any = contract.methodsObject
.mint({0: store.userAddress, 1: 100})
.mint({ 0: store.userAddress, 1: 100 })
.toTransferParams().parameter?.value;
const mintParamType = contract.entrypoints.entrypoints["mint"];
// packs the entrypoint call
Expand Down Expand Up @@ -548,6 +567,7 @@ const saplingShielded = async (

export const list = [
"Send tez",
"Send tez from Ghostnet to Etherlink",
"Contract call with int",
"Contract call with (pair nat string)",
"Contract call that fails",
Expand Down Expand Up @@ -582,6 +602,24 @@ export const init = (
inputRequired: false,
lastResult: { option: "none", val: false }
},
{
id: "send-tez-to-etherlink",
name: "Send tez from Ghostnet to Etherlink",
description:
"This test allows you send your ghostnet tez to etherlink address",
documentation: '',
keyword: 'etherlink',
run: input =>
sendTezToEtherlink(
input.amount,
input.address,
Tezos
),
showExecutionTime: false,
inputRequired: true,
inputType: "etherlink",
lastResult: { option: "none", val: false }
},
{
id: "contract-call-simple-type",
name: "Contract call with int",
Expand Down
2 changes: 1 addition & 1 deletion apps/taquito-test-dapp/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface TestSettings {
run: (input?: any) => Promise<TestResult>;
showExecutionTime: boolean;
inputRequired: boolean;
inputType?: "string" | "set-limits" | "sapling";
inputType?: "string" | "set-limits" | "sapling" | "etherlink";
lastResult: { option: "none" | "some"; val: boolean };
}

Expand Down
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"edsk",
"Ejara",
"entrypoints",
"etherlink",
"eztz",
"FAILWITH",
"flextesa",
Expand Down
2 changes: 1 addition & 1 deletion docs/dapp_prelaunch.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ author: Claude Barde
- Did you enable `Local Pack` in your dapp? Local Pack reduces the search time in bigmaps by 50%, and you can easily add it to your dapp by providing a new instance of the `MichelCodecPacker` class to the `setPackerProvider` method of the `TezosToolkit`.
- Are you creating a single instance of the `BeaconWallet` that you can reuse throughout the different components of your dapp? The JavaScript frameworks generally offer a solution to easily share data between components (the Context API in React, Provide/Inject in Vue, or a Svelte store). The instance of the `BeaconWallet` must be saved there in order to use the same one in every component. Creating multiple instances of the `BeaconWallet` may create errors when forging new transactions.
- Is your dapp making HTTP requests on update only when necessary? The JavaScript frameworks provide different solutions to rerender the DOM when internal data is updated (React `useEffect`, Vue `beforeUpdate` and Svelte `afterUpdate`). These data may be based on call responses to Tezos nodes or indexers, which is why it is crucial to optimize them. Unnecessary HTTP requests increase the traffic to Tezos nodes and indexer servers and slow down your dapp.
- Does your application wait for a confirmation of an operation, and does it check if the operation was successfull or failed when receiving the transaction receipt? This piece of information is crucial to your users in order to know if the transaction went through or not.
- Does your application wait for a confirmation of an operation, and does it check if the operation was successful or failed when receiving the transaction receipt? This piece of information is crucial to your users in order to know if the transaction went through or not.
- Do you display user-friendly error messages, for example, when a transaction fails? A lack of visual feedback when transactions don't go through as expected can be confusing for users. Users must be informed about skipped, backtracked, and failed transactions.
- Are you handling big numbers? Because numbers in Michelson are arbitrary-precision, they can become quite long, and JavaScript switches to the scientific notation to represent them, which can be confusing for users. You can use the `bignumber.js` library to handle potentially long numbers coming from the blockchain.
- Do you have error reporting enabled on your dapp? An error reporting tool like [BugSnag](https://www.bugsnag.com/platforms/javascript) allows you to understand the issues your users face when using your dapp.
3 changes: 3 additions & 0 deletions docs/rpc_nodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ values={[
| SmartPy | Mainnet | https://mainnet.smartpy.io | [Check](https://mainnet.smartpy.io/chains/main/blocks/head/header) |
| SmartPy | Ghostnet | https://ghostnet.smartpy.io | [Check](https://ghostnet.smartpy.io/chains/main/blocks/head/header) |
| Tezos Foundation | Mainnet | https://rpc.tzbeta.net/ | [Check](https://rpc.tzbeta.net/chains/main/blocks/head/header) |
| Tezos Foundation | Ghostnet | https://rpc.ghostnet.teztnets.com/ | [Check](https://rpc.ghostnet.teztnets.com/chains/main/blocks/head/header) |
| Tezos Foundation | Oxfordnet | https://rpc.oxfordnet.teztnets.com/ | [Check](https://rpc.oxfordnet.teztnets.com/chains/main/blocks/head/header) |
| Tezos Foundation | Parisnet | https://rpc.parisnet.teztnets.com/ | [Check](https://rpc.parisnet.teztnets.com/chains/main/blocks/head/header) |
| Marigold | Mainnet | https://mainnet.tezos.marigold.dev/ | [Check](https://mainnet.tezos.marigold.dev/chains/main/blocks/head/header) |
| Marigold | Ghostnet | https://ghostnet.tezos.marigold.dev/ | [Check](https://ghostnet.tezos.marigold.dev/chains/main/blocks/head/header) |
| Marigold | Oxfordnet | https://oxfordnet.tezos.marigold.dev/ | [Check](https://oxfordnet.tezos.marigold.dev/chains/main/blocks/head/header) |
Expand Down
2 changes: 1 addition & 1 deletion docs/signing.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ const isVerified = verifySignature(

## Signing Michelson data

Taquito also offers the possibility to sign Michelson code. This feature can be useful, for example, if you need to send a lambda to a contract to be executed but want to restrict the number of users who can submit a lambda by verifiying the signer's address. The signing of Michelson code requires the use of the `michel-codec` package:
Taquito also offers the possibility to sign Michelson code. This feature can be useful, for example, if you need to send a lambda to a contract to be executed but want to restrict the number of users who can submit a lambda by verifying the signer's address. The signing of Michelson code requires the use of the `michel-codec` package:

```js live noInline
// import { TezosToolkit } from '@taquito/taquito';
Expand Down
24 changes: 12 additions & 12 deletions example/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@taquito/example",
"private": true,
"version": "19.2.1",
"version": "19.2.0",
"scripts": {
"example": "node -r ts-node/register --preserve-symlinks example-node.ts",
"example:activation": "node -r ts-node/register --preserve-symlinks example-activate.ts",
Expand Down Expand Up @@ -41,17 +41,17 @@
"example:scan-path-ledger": "node -r ts-node/register --preserve-symlinks scan-path-ledger.ts"
},
"dependencies": {
"@ledgerhq/hw-transport-node-hid": "^6.27.21",
"@taquito/ledger-signer": "^19.2.1",
"@taquito/local-forging": "^19.2.1",
"@taquito/michel-codec": "^19.2.1",
"@taquito/michelson-encoder": "^19.2.1",
"@taquito/rpc": "^19.2.1",
"@taquito/sapling": "^19.2.1",
"@taquito/signer": "^19.2.1",
"@taquito/taquito": "^19.2.1",
"@taquito/tzip16": "^19.2.1",
"@taquito/utils": "^19.2.1",
"@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",
"@taquito/michelson-encoder": "^19.2.0",
"@taquito/rpc": "^19.2.0",
"@taquito/sapling": "^19.2.0",
"@taquito/signer": "^19.2.0",
"@taquito/taquito": "^19.2.0",
"@taquito/tzip16": "^19.2.0",
"@taquito/utils": "^19.2.0",
"bignumber.js": "^9.1.2"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { FieldNumberingStrategy } from "@taquito/michelson-encoder";
import { CONFIGS } from "../../config";
import { noAnnotCode, noAnnotInit } from "../../data/token_without_annotation";

Expand All @@ -10,59 +11,70 @@ CONFIGS().forEach(({ lib, rpc, setup }) => {
beforeEach(async () => {
await setup()
})
it('Verify contract.originate for a contract with no annotations for methods using methodObjects', async () => {
// Constants to replace annotations
const ACCOUNTS = '0';
const BALANCE = '0';
const ALLOWANCES = '1';
const TRANSFER = '0';
const APPROVE = '2';

// Actual tests
// Constants to replace annotations
const ACCOUNTS = '0';
const BALANCE = '0';
const ALLOWANCES = '1';
const TRANSFER = '0';
const APPROVE = '2';

const ACCOUNT1_ADDRESS = await Tezos.signer.publicKeyHash()
const ACCOUNT2_ADDRESS = 'tz1ZfrERcALBwmAqwonRXYVQBDT9BjNjBHJu'
// Actual tests

// Originate a contract with a known state
const op = await Tezos.contract.originate({
balance: "1",
code: noAnnotCode,
init: noAnnotInit(await Tezos.signer.publicKeyHash())
})
await op.confirmation()
const contract = await op.contract()
const ACCOUNT2_ADDRESS = 'tz1ZfrERcALBwmAqwonRXYVQBDT9BjNjBHJu'

// Runs the entire tests for a given fieldNumberingStrategy
const testContract = (strategy: FieldNumberingStrategy, innerObjectStartingIndex: number) => {
it(`Verify contract.originate for a contract with no annotations for methods using methodObjects with fieldNumberingStrategy: ${strategy}`, async () => {
Tezos.setFieldNumberingStrategy(strategy);
const ACCOUNT1_ADDRESS = await Tezos.signer.publicKeyHash()
// Originate a contract with a known state
const op = await Tezos.contract.originate({
balance: "1",
code: noAnnotCode,
init: noAnnotInit(await Tezos.signer.publicKeyHash())
})
await op.confirmation()
const contract = await op.contract()

// Make a transfer
// Make a transfer

const operation = await contract.methodsObject[TRANSFER]({
0: ACCOUNT1_ADDRESS,
1: ACCOUNT2_ADDRESS,
2: "1"
}).send();
const operation = await contract.methodsObject[TRANSFER]({
0: ACCOUNT1_ADDRESS,
1: ACCOUNT2_ADDRESS,
2: "1"
}).send();

await operation.confirmation();
expect(operation.status).toEqual('applied')
await operation.confirmation();
expect(operation.status).toEqual('applied')

// Verify that the transfer was done as expected
const storage = await contract.storage<any>()
let account1 = await storage[ACCOUNTS].get(ACCOUNT1_ADDRESS)
expect(account1[BALANCE].toString()).toEqual('16')
// Verify that the transfer was done as expected
const storage = await contract.storage<any>()
let account1 = await storage[ACCOUNTS].get(ACCOUNT1_ADDRESS)
expect(account1[BALANCE].toString()).toEqual('16')

const account2 = await storage[ACCOUNTS].get(ACCOUNT2_ADDRESS)
expect(account2[BALANCE].toString()).toEqual('1')
const account2 = await storage[ACCOUNTS].get(ACCOUNT2_ADDRESS)
expect(account2[BALANCE].toString()).toEqual('1')

// Approve
const operation2 = await contract.methodsObject[APPROVE]({
2: ACCOUNT2_ADDRESS,
3: "1"
}).send();
// Approve
const operation2 = await contract.methodsObject[APPROVE]({
[innerObjectStartingIndex]: ACCOUNT2_ADDRESS,
[innerObjectStartingIndex + 1]: "1"
}).send();

await operation2.confirmation();
expect(operation2.status).toEqual('applied')
await operation2.confirmation();
expect(operation2.status).toEqual('applied')

// Verify that the allowance was done as expected
account1 = await storage[ACCOUNTS].get(ACCOUNT1_ADDRESS)
expect(account1[ALLOWANCES].get(ACCOUNT2_ADDRESS).toString()).toEqual('1')
});
};

// Run the tests for all fieldNumberingStrategies
testContract('Legacy', 2);
testContract('ResetFieldNumbersInNestedObjects', 0);
testContract('Latest', 0);

// Verify that the allowance was done as expected
account1 = await storage[ACCOUNTS].get(ACCOUNT1_ADDRESS)
expect(account1[ALLOWANCES].get(ACCOUNT2_ADDRESS).toString()).toEqual('1')
})
});
})
});
Loading
Loading