From 77b602524cc7bd4d7fcce47d77d0ddf97217787e Mon Sep 17 00:00:00 2001 From: huianyang Date: Thu, 21 Dec 2023 15:17:38 -0800 Subject: [PATCH] feat: supports attesation along side endorsement re #2599 --- integration-tests/data/allTestsCases.ts | 81 ++++++++++++----------- integration-tests/local-forging.spec.ts | 9 +-- packages/taquito/src/subscribe/filters.ts | 2 + 3 files changed, 48 insertions(+), 44 deletions(-) diff --git a/integration-tests/data/allTestsCases.ts b/integration-tests/data/allTestsCases.ts index 7fb8213441..26b2dcb425 100644 --- a/integration-tests/data/allTestsCases.ts +++ b/integration-tests/data/allTestsCases.ts @@ -48,36 +48,18 @@ interface TestCase { expected?: object; } -export const nairobiCases: TestCase[] = [ +export const oxfordCases: TestCase[] = [ { - name: 'Set deposits limit 1000000', + name: 'Attestation', operation: { branch: 'BLzyjjHKEKMULtvkpSHxuZxx6ei6fpntH2BTkYZiLgs8zLVstvX', contents: [ { - kind: OpKind.SET_DEPOSITS_LIMIT, - counter: '1', - source: 'tz1QZ6KY7d3BuZDT1d19dUxoQrtFPN2QJ3hn', - fee: '10000', - gas_limit: '10', - storage_limit: '10', - limit: '1000000', - }, - ], - }, - }, - { - name: 'Unset deposits limit', - operation: { - branch: 'BLzyjjHKEKMULtvkpSHxuZxx6ei6fpntH2BTkYZiLgs8zLVstvX', - contents: [ - { - kind: OpKind.SET_DEPOSITS_LIMIT, - counter: '1', - source: 'tz1QZ6KY7d3BuZDT1d19dUxoQrtFPN2QJ3hn', - fee: '10000', - gas_limit: '10', - storage_limit: '10' + kind: OpKind.ATTESTATION, + slot: 0, + level: 66299, + round: 5, + block_payload_hash: 'vh3FEkypvxUYLwjGYd2Sme7aWyfX8npDsqxcL6imVpBWnAZeNn2n', }, ], }, @@ -134,6 +116,40 @@ export const commonCases: TestCase[] = [ ], }, }, + + { + name: 'Set deposits limit 1000000', + operation: { + branch: 'BLzyjjHKEKMULtvkpSHxuZxx6ei6fpntH2BTkYZiLgs8zLVstvX', + contents: [ + { + kind: OpKind.SET_DEPOSITS_LIMIT, + counter: '1', + source: 'tz1QZ6KY7d3BuZDT1d19dUxoQrtFPN2QJ3hn', + fee: '10000', + gas_limit: '10', + storage_limit: '10', + limit: '1000000', + }, + ], + }, + }, + { + name: 'Unset deposits limit', + operation: { + branch: 'BLzyjjHKEKMULtvkpSHxuZxx6ei6fpntH2BTkYZiLgs8zLVstvX', + contents: [ + { + kind: OpKind.SET_DEPOSITS_LIMIT, + counter: '1', + source: 'tz1QZ6KY7d3BuZDT1d19dUxoQrtFPN2QJ3hn', + fee: '10000', + gas_limit: '10', + storage_limit: '10' + }, + ], + }, + }, { name: 'Seed nonce revelation', operation: { @@ -1171,21 +1187,6 @@ export const commonCases: TestCase[] = [ ], }, }, - { - name: 'Endorsement', - operation: { - branch: 'BLzyjjHKEKMULtvkpSHxuZxx6ei6fpntH2BTkYZiLgs8zLVstvX', - contents: [ - { - kind: OpKind.ENDORSEMENT, - slot: 0, - level: 66299, - round: 5, - block_payload_hash: 'vh3FEkypvxUYLwjGYd2Sme7aWyfX8npDsqxcL6imVpBWnAZeNn2n', - }, - ], - }, - }, { name: `Origination of a contract that contains the instructions SUB_MUTEZ`, operation: { diff --git a/integration-tests/local-forging.spec.ts b/integration-tests/local-forging.spec.ts index 25a9435c4e..1e4028a14a 100644 --- a/integration-tests/local-forging.spec.ts +++ b/integration-tests/local-forging.spec.ts @@ -1,16 +1,17 @@ import { CONFIGS } from "./config"; -import { commonCases, nairobiCases } from './data/allTestsCases'; +import { commonCases, oxfordCases } from './data/allTestsCases'; import { LocalForger, ProtocolsHash } from '@taquito/local-forging' import { Protocols, TezosToolkit } from "@taquito/taquito"; +import { ProtoGreaterOrEqual } from '@taquito/michel-codec' CONFIGS().forEach(({ rpc, protocol }) => { const Tezos = new TezosToolkit(rpc); - const nairobinet = protocol === Protocols.PtNairobi ? it : it.skip; + const oxfordAndAlpha = ProtoGreaterOrEqual(protocol, Protocols.ProxfordY) ? test : test.skip describe(`Test local forger: ${rpc}`, () => { // all protocols - nairobiCases.forEach(({ name, operation, expected }) => { - nairobinet(`Verify that .forge for local forge will return same result as for network forge for rpc: ${name} (${rpc})`, async () => { + oxfordCases.forEach(({ name, operation, expected }) => { + oxfordAndAlpha(`Verify that .forge for local forge will return same result as for network forge for rpc: ${name} (${rpc})`, async () => { const localForger = new LocalForger(protocol as unknown as ProtocolsHash); const result = await localForger.forge(operation); const rpcResult = await Tezos.rpc.forgeOperations(operation); diff --git a/packages/taquito/src/subscribe/filters.ts b/packages/taquito/src/subscribe/filters.ts index eafc9db514..b2c95baa60 100644 --- a/packages/taquito/src/subscribe/filters.ts +++ b/packages/taquito/src/subscribe/filters.ts @@ -17,6 +17,8 @@ const opHashFilter = (op: OperationContent, filter: OpHashFilter) => op.hash === const sourceFilter = (x: OperationContent, filter: SourceFilter) => { switch (x.kind) { + case 'attestation': + return 'metadata' in x && x.metadata.delegate === filter.source; case 'endorsement': return 'metadata' in x && x.metadata.delegate === filter.source; case 'activate_account':