From 1cdaf6a57df34a2ab723c4b3aa5b953f082fab7f Mon Sep 17 00:00:00 2001 From: hui-an-yang <106410553+hui-an-yang@users.noreply.github.com> Date: Mon, 18 Sep 2023 13:23:59 -0700 Subject: [PATCH 1/3] 2596 oxfrod rpc returned type update (#2652) * feat: updated supported rpc call to be oxford compliant re #2596 * test: correct getPendingOperations unit test * test: fix flextesa oxfordnet knowncontract ref bug * test: revert oxfordnet known-contracts * test: split oxfordnet feature getPendingOperation with version2 * ci: attemp to fix flextesa timeout bug * revert: split estimate assertion change to another pr --- .github/workflows/main.yml | 2 +- cspell.json | 2 + integration-tests/config.ts | 14 +- integration-tests/known-contracts-Proxford.ts | 8 - .../known-contracts-ProxfordS.ts | 8 + .../known-contracts-PtMumbai2.ts | 8 - integration-tests/rpc-nodes.spec.ts | 34 ++-- .../src/rpc-wrapper.ts | 22 +-- .../taquito-rpc/src/rpc-client-interface.ts | 20 +-- .../src/rpc-client-modules/rpc-cache.ts | 43 +---- packages/taquito-rpc/src/taquito-rpc.ts | 170 +++++++----------- packages/taquito-rpc/src/types.ts | 69 +++---- packages/taquito-rpc/test/rpc-cache.spec.ts | 27 --- packages/taquito-rpc/test/taquito-rpc.spec.ts | 82 ++------- 14 files changed, 161 insertions(+), 348 deletions(-) delete mode 100644 integration-tests/known-contracts-Proxford.ts create mode 100644 integration-tests/known-contracts-ProxfordS.ts delete mode 100644 integration-tests/known-contracts-PtMumbai2.ts diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 82f6c9844d..9aa764b480 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -74,7 +74,7 @@ jobs: - protocol: Nairobi testnet: nairobinet testnet_uppercase: NAIROBINET - flextesa_docker_image: oxheadalpha/flextesa:20230502 + flextesa_docker_image: oxheadalpha/flextesa:20230607 - protocol: Oxford testnet: oxfordnet testnet_uppercase: OXFORDNET diff --git a/cspell.json b/cspell.json index 1ed410f95f..08c719d950 100644 --- a/cspell.json +++ b/cspell.json @@ -51,10 +51,12 @@ "nairobibox", "nairobinet", "octez", + "oxfordnet", "oxheadalpha", "precommit", "println", "Protofire", + "Proxford", "PtNairobi", "rollups", "Roxane", diff --git a/integration-tests/config.ts b/integration-tests/config.ts index b71fe8bf6e..f438a15beb 100644 --- a/integration-tests/config.ts +++ b/integration-tests/config.ts @@ -8,7 +8,7 @@ import { KnownContracts } from './known-contracts'; import { knownContractsProtoALph } from './known-contracts-ProtoALph'; import { knownContractsPtGhostnet } from './known-contracts-PtGhostnet'; import { knownContractsPtNairobi } from './known-contracts-PtNairobi'; -import { knownContractsProxford } from './known-contracts-Proxford'; +import { knownContractsProxfordS } from './known-contracts-ProxfordS'; const nodeCrypto = require('crypto'); @@ -24,7 +24,7 @@ enum ForgerType { COMPOSITE = 'composite', } -export const isSandbox = (config: {rpc: string}) => { +export const isSandbox = (config: { rpc: string }) => { return config.rpc.includes('localhost') || config.rpc.includes('0.0.0.0') || config.rpc.includes('127.0.0.1'); } @@ -144,14 +144,14 @@ const nairobinetEphemeral: Config = }); const nairobinetSecretKey: Config = - { ...nairobinetEphemeral, ...{ signerConfig: defaultSecretKey }, ...{ defaultRpc: 'http://ecad-nairobinet-full:8732' } }; + { ...nairobinetEphemeral, ...{ signerConfig: defaultSecretKey }, ...{ defaultRpc: 'http://ecad-nairobinet-full:8732' } }; const oxfordnetEphemeral: Config = defaultConfig({ networkName: 'OXFORDNET', protocol: Protocols.Proxford, defaultRpc: 'http://ecad-oxfordnet-full.i.tez.ie:8732', - knownContracts: knownContractsProxford, + knownContracts: knownContractsProxfordS, signerConfig: defaultEphemeralConfig('https://keygen.ecadinfra.com/oxfordnet') }); @@ -161,7 +161,7 @@ const oxfordnetSecretKey: Config = const ghostnetEphemeral: Config = defaultConfig({ networkName: 'GHOSTNET', - protocol: Protocols.PtMumbai2, + protocol: Protocols.Proxford, defaultRpc: 'ecad-ghostnet-rolling:8732', knownContracts: knownContractsPtGhostnet, signerConfig: defaultEphemeralConfig('https://keygen.ecadinfra.com/ghostnet') @@ -265,13 +265,13 @@ const setupWithSecretKey = async (Tezos: TezosToolkit, signerConfig: SecretKeyCo }; const configurePollingInterval = (Tezos: TezosToolkit, pollingIntervalMilliseconds: string | undefined) => { - if(pollingIntervalMilliseconds) { + if (pollingIntervalMilliseconds) { Tezos.setStreamProvider(Tezos.getFactory(PollingSubscribeProvider)({ pollingIntervalMilliseconds: Number(pollingIntervalMilliseconds) })); } } const configureRpcCache = (rpc: string, rpcCacheMilliseconds: string) => { - if(rpcCacheMilliseconds === '0') { + if (rpcCacheMilliseconds === '0') { return new TezosToolkit(rpc); } else { return new TezosToolkit(new RpcClientCache(new RpcClient(rpc), Number(rpcCacheMilliseconds))); diff --git a/integration-tests/known-contracts-Proxford.ts b/integration-tests/known-contracts-Proxford.ts deleted file mode 100644 index d201838544..0000000000 --- a/integration-tests/known-contracts-Proxford.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { KnownContracts } from './known-contracts'; -export const knownContractsProxford: KnownContracts = { - contract: "KT1TU9LydXWri8CBTQmzwnwjCm3dK8jt1LQA", - bigMapContract: "KT1MYLamQavaVMYqgn9f4gMgHzEZfQD73qYs", - tzip12BigMapOffChainContract: "KT1XX1JK4C7aPL2joE7nfeWRwPdrJYwroAUa", - saplingContract: "KT1MfFxdU3kpXMSmHZN4tYBbYkGRAbLt5Q1Y", - onChainViewContractAddress: "KT1TYMtN2yFQDmk82VFymQeZapp6BF1NsZ7B" -}; diff --git a/integration-tests/known-contracts-ProxfordS.ts b/integration-tests/known-contracts-ProxfordS.ts new file mode 100644 index 0000000000..7e44171986 --- /dev/null +++ b/integration-tests/known-contracts-ProxfordS.ts @@ -0,0 +1,8 @@ +import { KnownContracts } from './known-contracts'; +export const knownContractsProxfordS: KnownContracts = { + contract: "KT1TU9LydXWri8CBTQmzwnwjCm3dK8jt1LQA", + bigMapContract: "KT1MYLamQavaVMYqgn9f4gMgHzEZfQD73qYs", + tzip12BigMapOffChainContract: "KT1XX1JK4C7aPL2joE7nfeWRwPdrJYwroAUa", + saplingContract: "KT1MfFxdU3kpXMSmHZN4tYBbYkGRAbLt5Q1Y", + onChainViewContractAddress: "KT1TYMtN2yFQDmk82VFymQeZapp6BF1NsZ7B" +}; \ No newline at end of file diff --git a/integration-tests/known-contracts-PtMumbai2.ts b/integration-tests/known-contracts-PtMumbai2.ts deleted file mode 100644 index 70b3d80206..0000000000 --- a/integration-tests/known-contracts-PtMumbai2.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { KnownContracts } from './known-contracts'; -export const knownContractsPtMumbai2: KnownContracts = { - contract: "KT1XFiUYC36XSeLTanGJwZxqLzsxz9zquLFB", - bigMapContract: "KT1KbbvszHoWVSS8Nzh9yLgvRBDkzVjKmCtj", - tzip12BigMapOffChainContract: "KT1KKU19PxFbQUT9sBJS8KwYCVaXAzYsTkUK", - saplingContract: "KT1UHkJDY1CWAgYZJR1NkxXv27gsuu7hC77R", - onChainViewContractAddress: "KT1JxWH1vtMiTcvg4AdhTaGmyHt2oBb71tzW" -}; diff --git a/integration-tests/rpc-nodes.spec.ts b/integration-tests/rpc-nodes.spec.ts index a90cb9042d..df5ef68a38 100644 --- a/integration-tests/rpc-nodes.spec.ts +++ b/integration-tests/rpc-nodes.spec.ts @@ -1,6 +1,6 @@ -import { CONFIGS } from './config'; -import { DefaultContractType } from "@taquito/taquito"; -import { RpcClientCache, RpcClient, RPCRunViewParam, RPCRunScriptViewParam, PendingOperations, PvmKind } from '@taquito/rpc'; +import { CONFIGS, NetworkType } from './config'; +import { DefaultContractType, Protocols } from "@taquito/taquito"; +import { RpcClientCache, RpcClient, RPCRunViewParam, RPCRunScriptViewParam, PendingOperationsV1, PendingOperationsV2, PvmKind } from '@taquito/rpc'; import { encodeExpr } from '@taquito/utils'; import { Schema } from '@taquito/michelson-encoder'; import { tokenBigmapCode, tokenBigmapStorage } from './data/token_bigmap'; @@ -20,6 +20,7 @@ CONFIGS().forEach( }) => { const Tezos = lib; const unrestrictedRPCNode = rpc.endsWith("ecadinfra.com") ? test.skip : test; + const oxfordnetAndAlpha = protocol === Protocols.Proxford || protocol === Protocols.ProtoALpha ? test : test.skip; let ticketContract: DefaultContractType; @@ -488,17 +489,28 @@ CONFIGS().forEach( done(); }); - it('Verify that rpcClient.getPendingOperations will retrieve the pending operations in mempool', async (done) => { - const pendingOperations: PendingOperations = await rpcClient.getPendingOperations(); - expect(pendingOperations).toBeDefined(); - expect(pendingOperations.applied).toBeInstanceOf(Array); - expect(pendingOperations.refused).toBeInstanceOf(Array); - expect(pendingOperations.outdated).toBeInstanceOf(Array); - expect(pendingOperations.branch_delayed).toBeInstanceOf(Array); - expect(pendingOperations.branch_refused).toBeInstanceOf(Array); + it('Verify that rpcClient.getPendingOperations version1 will retrieve the pending operations in mempool with property applied', async (done) => { + const pendingOperations1 = await rpcClient.getPendingOperations() as PendingOperationsV1; + expect(pendingOperations1).toBeDefined(); + expect(pendingOperations1.applied).toBeInstanceOf(Array); + expect(pendingOperations1.refused).toBeInstanceOf(Array); + expect(pendingOperations1.outdated).toBeInstanceOf(Array); + expect(pendingOperations1.branch_delayed).toBeInstanceOf(Array); + expect(pendingOperations1.branch_refused).toBeInstanceOf(Array); done(); }); + oxfordnetAndAlpha('Verify that rpcClient.getPendingOperations version2 will retrieve the pending operations in mempool with property validated', async (done) => { + const pendingOperations2 = await rpcClient.getPendingOperations({ version: '2' }) as PendingOperationsV2; + expect(pendingOperations2).toBeDefined(); + expect(pendingOperations2.validated).toBeInstanceOf(Array); + expect(pendingOperations2.refused).toBeInstanceOf(Array); + expect(pendingOperations2.outdated).toBeInstanceOf(Array); + expect(pendingOperations2.branch_delayed).toBeInstanceOf(Array); + expect(pendingOperations2.branch_refused).toBeInstanceOf(Array); + done(); + }) + it('Verify that rpcClient.getOriginationProof will retrieve the proof needed for smart rollup originate', async (done) => { const proof = await rpcClient.getOriginationProof({ kernel: '23212f7573722f62696e2f656e762073680a6578706f7274204b45524e454c3d22303036313733366430313030303030303031323830373630303337663766376630313766363030323766376630313766363030353766376637663766376630313766363030313766303036303031376630313766363030323766376630303630303030303032363130333131373336643631373237343566373236663663366337353730356636333666373236353061373236353631363435663639366537303735373430303030313137333664363137323734356637323666366336633735373035663633366637323635306337373732363937343635356636663735373437303735373430303031313137333664363137323734356637323666366336633735373035663633366637323635306237333734366637323635356637373732363937343635303030323033303530343033303430353036303530333031303030313037313430323033366436353664303230303061366236353732366536353663356637323735366530303036306161343031303432613031303237663431666130303266303130303231303132303030326630313030323130323230303132303032343730343430343165343030343131323431303034316534303034313030313030323161306230623038303032303030343163343030366230623530303130353766343166653030326430303030323130333431666330303266303130303231303232303030326430303030323130343230303032663031303032313035323030313130303432313036323030343230303334363034343032303030343130313661323030313431303136623130303131613035323030353230303234363034343032303030343130373661323030363130303131613062306230623164303130313766343164633031343138343032343139303163313030303231303034313834303232303030313030353431383430323130303330623062333830353030343165343030306231323266366236353732366536353663326636353665373632663732363536323666366637343030343166383030306230323030303130303431666130303062303230303032303034316663303030623032303030303030343166653030306230313031220a', diff --git a/packages/taquito-contracts-library/src/rpc-wrapper.ts b/packages/taquito-contracts-library/src/rpc-wrapper.ts index 7fb5335d13..eacbf95073 100644 --- a/packages/taquito-contracts-library/src/rpc-wrapper.ts +++ b/packages/taquito-contracts-library/src/rpc-wrapper.ts @@ -39,14 +39,13 @@ import { RunViewResult, SaplingDiffResponse, ScriptResponse, - TxRollupInboxResponse, - TxRollupStateResponse, UnparsingMode, VotesListingsResponse, VotingPeriodBlockResult, TicketTokenParams, AllTicketBalances, - PendingOperations, + PendingOperationsV1, + PendingOperationsV2, PendingOperationsQueryArguments, OriginationProofParams, RPCSimulateOperationParam, @@ -293,19 +292,6 @@ export class RpcWrapperContractsLibrary implements RpcClientInterface { async getProtocols({ block }: RPCOptions = defaultRPCOptions): Promise { return this.rpc.getProtocols({ block }); } - async getTxRollupState( - txRollupId: string, - { block }: RPCOptions = defaultRPCOptions - ): Promise { - return this.rpc.getTxRollupState(txRollupId, { block }); - } - async getTxRollupInbox( - txRollupId: string, - blockLevel: string, - { block }: RPCOptions = defaultRPCOptions - ): Promise { - return this.rpc.getTxRollupInbox(txRollupId, blockLevel, { block }); - } async getStorageUsedSpace( contract: string, { block }: RPCOptions = defaultRPCOptions @@ -331,7 +317,9 @@ export class RpcWrapperContractsLibrary implements RpcClientInterface { ): Promise { return this.rpc.getAllTicketBalances(contract, { block }); } - async getPendingOperations(args: PendingOperationsQueryArguments): Promise { + async getPendingOperations( + args: PendingOperationsQueryArguments + ): Promise { return this.rpc.getPendingOperations(args); } async getOriginationProof( diff --git a/packages/taquito-rpc/src/rpc-client-interface.ts b/packages/taquito-rpc/src/rpc-client-interface.ts index f8e910a99c..f19a7df211 100644 --- a/packages/taquito-rpc/src/rpc-client-interface.ts +++ b/packages/taquito-rpc/src/rpc-client-interface.ts @@ -38,15 +38,14 @@ import { SaplingDiffResponse, ScriptResponse, StorageResponse, - TxRollupInboxResponse, - TxRollupStateResponse, UnparsingMode, VotesListingsResponse, VotingInfoResponse, VotingPeriodBlockResult, TicketTokenParams, AllTicketBalances, - PendingOperations, + PendingOperationsV1, + PendingOperationsV2, PendingOperationsQueryArguments, OriginationProofParams, RPCSimulateOperationParam, @@ -54,10 +53,11 @@ import { export interface RPCOptions { block: string; + version?: '0' | '1'; } export const defaultChain = 'main'; -export const defaultRPCOptions: RPCOptions = { block: 'head' }; +export const defaultRPCOptions: RPCOptions = { block: 'head', version: '0' }; export interface RpcClientInterface { getBlockHash(options?: RPCOptions): Promise; @@ -118,12 +118,6 @@ export interface RpcClientInterface { getSaplingDiffById(id: string, options?: RPCOptions): Promise; getSaplingDiffByContract(contract: string, options?: RPCOptions): Promise; getProtocols(options?: RPCOptions): Promise; - getTxRollupState(txRollupId: string, options?: RPCOptions): Promise; - getTxRollupInbox( - txRollupId: string, - blockLevel: string, - options?: RPCOptions - ): Promise; getStorageUsedSpace(contract: string, options?: RPCOptions): Promise; getStoragePaidSpace(contract: string, options?: RPCOptions): Promise; getTicketBalance( @@ -132,7 +126,9 @@ export interface RpcClientInterface { options?: RPCOptions ): Promise; getAllTicketBalances(contract: string, options?: RPCOptions): Promise; - getPendingOperations(args: PendingOperationsQueryArguments): Promise; + getPendingOperations( + args: PendingOperationsQueryArguments + ): Promise; getOriginationProof(params: OriginationProofParams, options?: RPCOptions): Promise; } @@ -168,8 +164,6 @@ export enum RPCMethodName { GET_SCRIPT = 'getScript', GET_STORAGE = 'getStorage', GET_SUCCESSOR_PERIOD = 'getSuccessorPeriod', - GET_TX_ROLLUP_INBOX = 'getTxRollupInbox', - GET_TX_ROLLUP_STATE = 'getTxRollupState', GET_VOTES_LISTINGS = 'getVotesListings', PACK_DATA = 'packData', GET_STORAGE_USED_SPACE = 'getStorageUsedSpace', diff --git a/packages/taquito-rpc/src/rpc-client-modules/rpc-cache.ts b/packages/taquito-rpc/src/rpc-client-modules/rpc-cache.ts index f39ff7e2fe..8f2bf12474 100644 --- a/packages/taquito-rpc/src/rpc-client-modules/rpc-cache.ts +++ b/packages/taquito-rpc/src/rpc-client-modules/rpc-cache.ts @@ -41,15 +41,14 @@ import { SaplingDiffResponse, ScriptResponse, StorageResponse, - TxRollupInboxResponse, - TxRollupStateResponse, UnparsingMode, VotesListingsResponse, VotingPeriodBlockResult, TicketTokenParams, AllTicketBalances, PendingOperationsQueryArguments, - PendingOperations, + PendingOperationsV1, + PendingOperationsV2, OriginationProofParams, RPCSimulateOperationParam, } from '../types'; @@ -1103,42 +1102,6 @@ export class RpcClientCache implements RpcClientInterface { } } - async getTxRollupState( - txRollupId: string, - { block }: { block: string } = defaultRPCOptions - ): Promise { - const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_TX_ROLLUP_STATE, [ - block, - txRollupId, - ]); - if (this.has(key)) { - return this.get(key); - } else { - const response = this.rpcClient.getTxRollupState(txRollupId, { block }); - this.put(key, response); - return response; - } - } - - async getTxRollupInbox( - txRollupId: string, - blockLevel: string, - { block }: { block: string } = defaultRPCOptions - ): Promise { - const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_TX_ROLLUP_INBOX, [ - block, - txRollupId, - blockLevel, - ]); - if (this.has(key)) { - return this.get(key); - } else { - const response = this.rpcClient.getTxRollupInbox(txRollupId, blockLevel, { block }); - this.put(key, response); - return response; - } - } - /** * * @param contract address of the contract we want to retrieve storage information of @@ -1255,7 +1218,7 @@ export class RpcClientCache implements RpcClientInterface { */ async getPendingOperations( args: PendingOperationsQueryArguments = {} - ): Promise { + ): Promise { const key = this.formatCacheKey( this.rpcClient.getRpcUrl(), RPCMethodName.GET_PENDING_OPERATIONS, diff --git a/packages/taquito-rpc/src/taquito-rpc.ts b/packages/taquito-rpc/src/taquito-rpc.ts index 58e7d9514f..b659e56f3e 100644 --- a/packages/taquito-rpc/src/taquito-rpc.ts +++ b/packages/taquito-rpc/src/taquito-rpc.ts @@ -55,12 +55,11 @@ import { UnparsingMode, VotesListingsResponse, VotingPeriodBlockResult, - TxRollupStateResponse, - TxRollupInboxResponse, TicketTokenParams, AllTicketBalances, PendingOperationsQueryArguments, - PendingOperations, + PendingOperationsV1, + PendingOperationsV2, OriginationProofParams, RPCSimulateOperationParam, } from './types'; @@ -130,7 +129,7 @@ export class RpcClient implements RpcClientInterface { /** * - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block * * @description Get the block's hash, its unique identifier. * @@ -146,7 +145,7 @@ export class RpcClient implements RpcClientInterface { /** * - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block * * @description List the ancestors of the given block which, if referred to as the branch in an operation header, are recent enough for that operation to be included in the current block. * @@ -163,7 +162,7 @@ export class RpcClient implements RpcClientInterface { /** * * @param address address from which we want to retrieve the balance - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block * * @description Access the balance of a contract. * @@ -186,7 +185,7 @@ export class RpcClient implements RpcClientInterface { /** * * @param address contract address from which we want to retrieve the storage - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block * * @description Access the data of the contract. * @@ -231,7 +230,7 @@ export class RpcClient implements RpcClientInterface { * * @param address contract address from which we want to retrieve the script * @param unparsingMode default is { unparsing_mode: "Readable" } - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block * * @description Access the script of the contract and normalize it using the requested unparsing mode. * @@ -256,7 +255,7 @@ export class RpcClient implements RpcClientInterface { /** * * @param address contract address from which we want to retrieve - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block * * @description Access the complete status of a contract. * @@ -280,7 +279,7 @@ export class RpcClient implements RpcClientInterface { /** * * @param address contract address from which we want to retrieve the manager - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block * * @description Access the manager key of a contract. * @@ -302,7 +301,7 @@ export class RpcClient implements RpcClientInterface { /** * * @param address contract address from which we want to retrieve the delegate (baker) - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block * * @description Access the delegate of a contract, if any. * @@ -334,7 +333,7 @@ export class RpcClient implements RpcClientInterface { /** * * @param address contract address from which we want to retrieve the big map key - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block * * @description Access the value associated with a key in the big map storage of the contract. * @@ -363,7 +362,7 @@ export class RpcClient implements RpcClientInterface { * * @param id Big Map ID * @param expr Expression hash to query (A b58check encoded Blake2b hash of the expression (The expression can be packed using the pack_data method)) - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block * * @description Access the value associated with a key in a big map. * @@ -383,7 +382,7 @@ export class RpcClient implements RpcClientInterface { /** * * @param address delegate address which we want to retrieve - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block * * @description Fetches information about a delegate from RPC. * @@ -400,15 +399,15 @@ export class RpcClient implements RpcClientInterface { }); const castedResponse: any = castToBigNumber(response, [ - 'balance', 'full_balance', 'current_frozen_deposits', 'frozen_deposits', - 'frozen_balance', - 'frozen_deposits_limit', 'staking_balance', 'delegated_balance', 'voting_power', + 'balance', + 'frozen_balance', + 'frozen_deposits_limit', ]); return { @@ -437,7 +436,7 @@ export class RpcClient implements RpcClientInterface { /** * * @param address delegate address which we want to retrieve - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block * * @description Returns the delegate info (e.g. voting power) found in the listings of the current voting period. * @@ -459,7 +458,7 @@ export class RpcClient implements RpcClientInterface { /** * - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block * * @description All constants * @@ -509,19 +508,20 @@ export class RpcClient implements RpcClientInterface { /** * - * @param options contains generic configuration for rpc calls. See examples for various available sytaxes. + * @param options contains generic configuration for rpc calls to specify block and version. * * @description All the information about a block * * @see https://tezos.gitlab.io/api/rpc.html#get-block-id - * @example getBlock() will default to /main/chains/block/head. - * @example getBlock({ block: head~2 }) will return an offset of 2 blocks. - * @example getBlock({ block: BL8fTiWcSxWCjiMVnDkbh6EuhqVPZzgWheJ2dqwrxYRm9AephXh~2 }) will return an offset of 2 blocks from given block hash.. + * @example getBlock() will default to /main/chains/block/head?version=0. version=0 shows { kind: endorsement } + * @example getBlock({ version: 1 }) will return /main/chains/block/head?version=1. version=1 shows { kind: attestation } + * @example getBlock({ block: head~2 }) will return an offset of 2 blocks and default version 0. */ - async getBlock({ block }: RPCOptions = defaultRPCOptions): Promise { + async getBlock({ block, version }: RPCOptions = defaultRPCOptions): Promise { const response = await this.httpBackend.createRequest({ url: this.createURL(`/chains/${this.chain}/blocks/${block}`), method: 'GET', + query: { version }, }); return response; @@ -529,7 +529,7 @@ export class RpcClient implements RpcClientInterface { /** * - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block * * @description The whole block header * @@ -546,16 +546,20 @@ export class RpcClient implements RpcClientInterface { /** * - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block and version. * * @description All the metadata associated to the block * * @see https://tezos.gitlab.io/api/rpc.html#get-block-id-metadata */ - async getBlockMetadata({ block }: RPCOptions = defaultRPCOptions): Promise { + async getBlockMetadata({ + block, + version, + }: RPCOptions = defaultRPCOptions): Promise { const response = await this.httpBackend.createRequest({ url: this.createURL(`/chains/${this.chain}/blocks/${block}/metadata`), method: 'GET', + query: { version }, }); return response; @@ -564,7 +568,7 @@ export class RpcClient implements RpcClientInterface { /** * * @param args contains optional query arguments - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block * * @description Retrieves the list of delegates allowed to bake a block. * @@ -586,7 +590,7 @@ export class RpcClient implements RpcClientInterface { /** * * @param args contains optional query arguments - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block * * @description Retrieves the list of delegates allowed to bake a block. * @@ -606,7 +610,7 @@ export class RpcClient implements RpcClientInterface { } /** - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block * * @description Ballots casted so far during a voting period * @@ -623,7 +627,7 @@ export class RpcClient implements RpcClientInterface { /** * - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block * * @description Sum of ballots casted so far during a voting period. * @@ -641,7 +645,7 @@ export class RpcClient implements RpcClientInterface { /** * - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block * * @description Current proposal under evaluation. * @@ -660,7 +664,7 @@ export class RpcClient implements RpcClientInterface { /** * - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block * * @description Current expected quorum. * @@ -679,7 +683,7 @@ export class RpcClient implements RpcClientInterface { /** * - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block * * @description List of delegates with their voting weight, in number of rolls. * @@ -705,7 +709,7 @@ export class RpcClient implements RpcClientInterface { /** * - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block * * @description List of proposals with number of supporters. * @@ -727,7 +731,7 @@ export class RpcClient implements RpcClientInterface { /** * * @param data operation contents to forge - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block * * @description Forge an operation returning the unsigned bytes * @@ -767,7 +771,7 @@ export class RpcClient implements RpcClientInterface { /** * * @param ops Operations to apply - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block and version * * @description Simulate the validation of an operation * @@ -775,12 +779,13 @@ export class RpcClient implements RpcClientInterface { */ async preapplyOperations( ops: PreapplyParams, - { block }: RPCOptions = defaultRPCOptions + { block, version }: RPCOptions = defaultRPCOptions ): Promise { const response = await this.httpBackend.createRequest( { url: this.createURL(`/chains/${this.chain}/blocks/${block}/helpers/preapply/operations`), method: 'POST', + query: { version }, }, ops ); @@ -791,9 +796,8 @@ export class RpcClient implements RpcClientInterface { /** * * @param contract address of the contract we want to get the entrypoints of - * + * @param options contains generic configuration for rpc calls to specify block * @description Return the list of entrypoints of the contract - * * @see https://tezos.gitlab.io/api/rpc.html#get-block-id-context-contracts-contract-id-entrypoints * * @version 005_PsBABY5H @@ -817,7 +821,7 @@ export class RpcClient implements RpcClientInterface { /** * @param op Operation to run - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block and version * * @description Run an operation without signature checks * @@ -825,12 +829,13 @@ export class RpcClient implements RpcClientInterface { */ async runOperation( op: RPCRunOperationParam, - { block }: RPCOptions = defaultRPCOptions + { block, version }: RPCOptions = defaultRPCOptions ): Promise { const response = await this.httpBackend.createRequest( { url: this.createURL(`/chains/${this.chain}/blocks/${block}/helpers/scripts/run_operation`), method: 'POST', + query: { version }, }, op ); @@ -840,7 +845,7 @@ export class RpcClient implements RpcClientInterface { /** * @param op Operation to simulate - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block and version * * @description Simulate an operation on the blockchain * @@ -848,7 +853,7 @@ export class RpcClient implements RpcClientInterface { */ async simulateOperation( op: RPCSimulateOperationParam, - { block }: RPCOptions = defaultRPCOptions + { block, version }: RPCOptions = defaultRPCOptions ): Promise { const response = await this.httpBackend.createRequest( { @@ -856,6 +861,7 @@ export class RpcClient implements RpcClientInterface { `/chains/${this.chain}/blocks/${block}/helpers/scripts/simulate_operation` ), method: 'POST', + query: { version }, }, op ); @@ -865,7 +871,7 @@ export class RpcClient implements RpcClientInterface { /** * @param code Code to run - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block * * @description Run a piece of code in the current context * @@ -888,7 +894,7 @@ export class RpcClient implements RpcClientInterface { /** * @param viewScriptParams Parameters of the script view to run - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block * * @description Simulate a call to a michelson view * @@ -913,7 +919,7 @@ export class RpcClient implements RpcClientInterface { /** * @param viewParams Parameters of the view to run - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block * * @description Simulate a call to a view following the TZIP-4 standard. See https://gitlab.com/tzip/tzip/-/blob/master/proposals/tzip-4/tzip-4.md#view-entrypoints. * @@ -944,7 +950,7 @@ export class RpcClient implements RpcClientInterface { /** * * @param data Data to pack - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block * * @description Computes the serialized version of a data expression using the same algorithm as script instruction PACK * Note: You should always verify the packed bytes before signing or requesting that they be signed when using the the RPC to pack. @@ -986,7 +992,7 @@ export class RpcClient implements RpcClientInterface { /** * - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block * * @description Voting period of current block. * @@ -1007,7 +1013,7 @@ export class RpcClient implements RpcClientInterface { /** * - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block * * @description Voting period of next block. * @@ -1029,7 +1035,7 @@ export class RpcClient implements RpcClientInterface { /** * * @param id Sapling state ID - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block * * @description Access the value associated with a sapling state ID. * @@ -1048,7 +1054,7 @@ export class RpcClient implements RpcClientInterface { /** * * @param contract address of the contract we want to get the sapling diff - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block * * @description Access the value associated with a sapling state. * @@ -1073,56 +1079,10 @@ export class RpcClient implements RpcClientInterface { }); } - /** - * - * @param tx_rollup_id the transaction rollup ID - * @param options contains generic configuration for rpc calls - * - * @description Access the state of a rollup - * - * @see https://tezos.gitlab.io/jakarta/rpc.html#get-block-id-context-tx-rollup-tx-rollup-id-state - */ - - async getTxRollupState( - txRollupId: string, - { block }: { block: string } = defaultRPCOptions - ): Promise { - return this.httpBackend.createRequest({ - url: this.createURL( - `/chains/${this.chain}/blocks/${block}/context/tx_rollup/${txRollupId}/state` - ), - method: 'GET', - }); - } - - /** - * - * @param tx_rollup_id the transaction rollup ID - * @param block_level the block level - * @param options contains generic configuration for rpc calls - * - * @description Access the inbox of a transaction rollup - * - * @see https://tezos.gitlab.io/jakarta/rpc.html#get-block-id-context-tx-rollup-tx-rollup-id-inbox-block-level - */ - - async getTxRollupInbox( - txRollupId: string, - blockLevel: string, - { block }: { block: string } = defaultRPCOptions - ): Promise { - return this.httpBackend.createRequest({ - url: this.createURL( - `/chains/${this.chain}/blocks/${block}/context/tx_rollup/${txRollupId}/inbox/${blockLevel}` - ), - method: 'GET', - }); - } - /** * * @param contract address of the contract we want to retrieve storage information of - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block * * @description Access the amount of used space in a contract's storage * @@ -1143,7 +1103,7 @@ export class RpcClient implements RpcClientInterface { /** * * @param contract address of the contract we want to retrieve storage information of - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block * * @description Access the amount of paid space in a contract's storage * @@ -1165,7 +1125,7 @@ export class RpcClient implements RpcClientInterface { * * @param contract implicit or originated address we want to retrieve ticket balance of * @param ticket object to specify a ticket by ticketer, content type and content - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block * @description Access the contract's balance of ticket with specified ticketer, content type, and content. * @example ticket { ticketer: 'address', content_type: { prim: "string" }, content: { string: 'ticket1' } } * @see https://tezos.gitlab.io/protocols/016_mumbai.html#rpc-changes @@ -1189,7 +1149,7 @@ export class RpcClient implements RpcClientInterface { /** * * @param contract originated address we want to retrieve ticket balances of - * @param options contains generic configuration for rpc calls + * @param options contains generic configuration for rpc calls to specify block * @description Access the complete list of tickets owned by the given contract by scanning the contract's storage. * @see https://tezos.gitlab.io/protocols/016_mumbai.html#rpc-changes */ @@ -1207,14 +1167,14 @@ export class RpcClient implements RpcClientInterface { /** * @description List the prevalidated operations in mempool (accessibility of mempool depends on each rpc endpoint) - * @param args has 5 optional properties. We support version 1 with new encoding as version 0 will be deprecated soon. The rest of the properties is to filter pending operations response + * @param args has 5 optional properties. We support version 1 as default will output { applied: { kind: endorsement} } version 2 will output { validated: { kind: attestation} }. The rest of the properties is to filter pending operations response * @default args { version: '1', applied: true, refused: true, outdated, true, branchRefused: true, branchDelayed: true, validationPass: undefined } * @see https://tezos.gitlab.io/CHANGES.html?highlight=pending_operations#id4 */ async getPendingOperations( args: PendingOperationsQueryArguments = {} - ): Promise { - return this.httpBackend.createRequest({ + ): Promise { + return this.httpBackend.createRequest({ url: this.createURL(`/chains/${this.chain}/mempool/pending_operations`), method: 'GET', query: args, diff --git a/packages/taquito-rpc/src/types.ts b/packages/taquito-rpc/src/types.ts index 078e9681af..c8e614882f 100644 --- a/packages/taquito-rpc/src/types.ts +++ b/packages/taquito-rpc/src/types.ts @@ -93,13 +93,9 @@ export interface TxRollupTicketsInfo { claimer: string; } export interface DelegatesResponse { - balance?: BigNumber; full_balance?: BigNumber; current_frozen_deposits?: BigNumber; frozen_deposits?: BigNumber; - frozen_balance?: BigNumber; - frozen_balance_by_cycle?: Frozenbalancebycycle[]; - frozen_deposits_limit?: BigNumber; staking_balance: BigNumber; delegated_contracts: string[]; delegated_balance: BigNumber; @@ -107,10 +103,14 @@ export interface DelegatesResponse { grace_period: number; voting_power?: BigNumber; current_ballot?: BallotVote; - current_proposals?: string[]; remaining_proposals?: number; active_consensus_key?: string; pending_consensus_keys?: PendingConsensusKey[]; + balance?: BigNumber; + frozen_balance?: BigNumber; + frozen_balance_by_cycle?: Frozenbalancebycycle[]; + frozen_deposits_limit?: BigNumber; + current_proposals?: string[]; } export type PendingConsensusKey = { @@ -1303,7 +1303,15 @@ export interface BallotsResponse { pass: BigNumber; } -export type PeriodKindResponse = 'proposal' | 'exploration' | 'cooldown' | 'promotion' | 'adoption'; +export type PeriodKindResponse = + | 'proposal' + | 'exploration' + | 'cooldown' + | 'promotion' + | 'adoption' + | 'testing_vote' + | 'testing' + | 'promotion_vote'; export type CurrentProposalResponse = string | null; @@ -2394,47 +2402,15 @@ export type ProtocolsResponse = { next_protocol: string; }; -export type Next = - | { - next: number; - } - | { - newest: number; - oldest: number; - }; - -export type LastRemovedCommitmentHashes = { - last_message_hash: string; - commitment_hash: string; -}; -export interface TxRollupStateResponse { - last_removed_commitment_hashes?: LastRemovedCommitmentHashes; - finalized_commitments: Next; - unfinalized_commitments: Next; - uncommitted_inboxes: Next; - commitment_newest_hash?: string; - tezos_head_level?: number; - burn_per_byte: string; - allocated_storage: string; - occupied_storage: string; - inbox_ema: number; - commitments_watermark?: number; -} - -export interface TxRollupInboxResponse { - inbox_length: number; - cumulated_size: number; - merkle_root: string; -} - export interface PendingOperationsQueryArguments { - version?: '1'; - applied?: boolean; + version?: '1' | '2'; + validated?: boolean; refused?: boolean; outdated?: boolean; branchRefused?: boolean; branchDelayed?: boolean; validationPass?: '0' | '1' | '2' | '3'; + applied?: boolean; } type FailedProcessedOperation = Pick< @@ -2444,7 +2420,7 @@ type FailedProcessedOperation = Pick< error: TezosGenericOperationError[]; }; -export interface PendingOperations { +export interface PendingOperationsV1 { applied: Pick[]; refused: FailedProcessedOperation[]; outdated: FailedProcessedOperation[]; @@ -2453,6 +2429,15 @@ export interface PendingOperations { unprocessed: Pick[]; } +export interface PendingOperationsV2 { + validated: Pick[]; + refused: FailedProcessedOperation[]; + outdated: FailedProcessedOperation[]; + branch_refused: FailedProcessedOperation[]; + branch_delayed: FailedProcessedOperation[]; + unprocessed: Pick[]; +} + export enum PvmKind { WASM2 = 'wasm_2_0_0', ARITH = 'arith', diff --git a/packages/taquito-rpc/test/rpc-cache.spec.ts b/packages/taquito-rpc/test/rpc-cache.spec.ts index 17c41c21d1..0bc823316a 100644 --- a/packages/taquito-rpc/test/rpc-cache.spec.ts +++ b/packages/taquito-rpc/test/rpc-cache.spec.ts @@ -30,8 +30,6 @@ import { blockResponse, protocols, constants, - txRollupInbox, - txRollupState, ticketBalancesResponse, pendingOperationsResponse, } from './data/rpc-responses'; @@ -45,8 +43,6 @@ describe('RpcClientCache test', () => { const address = 'tz1QZ6KY7d3BuZDT1d19dUxoQrtFPN2QJ3hn'; const contractAddress = 'KT1Fe71jyjrxFg9ZrYqtvaX7uQjcLo7svE4D'; - const txRollupId = 'txr1YTdi9BktRmybwhgkhRK7WPrutEWVGJT7w'; - const blockLevel = '0'; const ticketToken = { ticketer: contractAddress, content_type: { prim: 'string' }, @@ -89,8 +85,6 @@ describe('RpcClientCache test', () => { getCurrentPeriod: jest.fn(), getSuccessorPeriod: jest.fn(), getProtocols: jest.fn(), - getTxRollupInbox: jest.fn(), - getTxRollupState: jest.fn(), getTicketBalance: jest.fn(), getAllTicketBalances: jest.fn(), getPendingOperations: jest.fn(), @@ -129,8 +123,6 @@ describe('RpcClientCache test', () => { mockRpcClient.getCurrentPeriod.mockReturnValue(currentPeriod); mockRpcClient.getSuccessorPeriod.mockReturnValue(successorPeriod); mockRpcClient.getProtocols.mockReturnValue(protocols); - mockRpcClient.getTxRollupInbox.mockReturnValue(txRollupInbox); - mockRpcClient.getTxRollupState.mockReturnValue(txRollupState); mockRpcClient.getTicketBalance.mockReturnValue('3'); mockRpcClient.getAllTicketBalances.mockReturnValue(ticketBalancesResponse); mockRpcClient.getPendingOperations.mockReturnValue(pendingOperationsResponse); @@ -178,8 +170,6 @@ describe('RpcClientCache test', () => { await rpcCache.getCurrentPeriod(); await rpcCache.getSuccessorPeriod(); await rpcCache.getProtocols(); - await rpcCache.getTxRollupInbox(txRollupId, blockLevel); - await rpcCache.getTxRollupState(txRollupId); await rpcCache.getTicketBalance(contractAddress, { ticketer: contractAddress, content_type: { prim: 'string' }, @@ -268,13 +258,6 @@ describe('RpcClientCache test', () => { successorPeriod ); expect(rpcCache.getAllCachedData()['rpcTest/getProtocols/head/'].response).toEqual(protocols); - expect( - rpcCache.getAllCachedData()[`rpcTest/getTxRollupInbox/head/${txRollupId}/${blockLevel}/`] - .response - ).toEqual(txRollupInbox); - expect( - rpcCache.getAllCachedData()[`rpcTest/getTxRollupState/head/${txRollupId}/`].response - ).toEqual(txRollupState); expect( rpcCache.getAllCachedData()[ `rpcTest/getTicketBalance/head/${contractAddress}/${JSON.stringify(ticketToken)}/` @@ -332,8 +315,6 @@ describe('RpcClientCache test', () => { await rpcCache.getCurrentPeriod(block); await rpcCache.getSuccessorPeriod(block); await rpcCache.getProtocols(block); - await rpcCache.getTxRollupInbox(txRollupId, blockLevel, block); - await rpcCache.getTxRollupState(txRollupId, block); await rpcCache.getTicketBalance( contractAddress, { @@ -444,14 +425,6 @@ describe('RpcClientCache test', () => { expect(rpcCache.getAllCachedData()[`rpcTest/getProtocols/${block.block}/`].response).toEqual( protocols ); - expect( - rpcCache.getAllCachedData()[ - `rpcTest/getTxRollupInbox/${block.block}/${txRollupId}/${blockLevel}/` - ].response - ).toEqual(txRollupInbox); - expect( - rpcCache.getAllCachedData()[`rpcTest/getTxRollupState/${block.block}/${txRollupId}/`].response - ).toEqual(txRollupState); expect( rpcCache.getAllCachedData()[ `rpcTest/getTicketBalance/${block.block}/${contractAddress}/${JSON.stringify(ticketToken)}/` diff --git a/packages/taquito-rpc/test/taquito-rpc.spec.ts b/packages/taquito-rpc/test/taquito-rpc.spec.ts index 811257ae6b..caba30d1aa 100644 --- a/packages/taquito-rpc/test/taquito-rpc.spec.ts +++ b/packages/taquito-rpc/test/taquito-rpc.spec.ts @@ -39,7 +39,8 @@ import { OperationContentsAndResultSmartRollupExecuteOutboxMessage, RPCRunOperationParam, OperationMetadataBalanceUpdates, - PendingOperations, + PendingOperationsV1, + PendingOperationsV2, OperationContentsAndResultSmartRollupCement, OperationContentsAndResultSmartRollupPublish, OperationContentsAndResultSmartRollupRefute, @@ -489,6 +490,7 @@ describe('RpcClient test', () => { expect(httpBackend.createRequest.mock.calls[0][0]).toEqual({ method: 'POST', url: 'root/chains/test/blocks/head/helpers/preapply/operations', + query: { version: '0' }, }); expect(httpBackend.createRequest.mock.calls[0][1]).toEqual({}); @@ -611,6 +613,7 @@ describe('RpcClient test', () => { expect(httpBackend.createRequest.mock.calls[0][0]).toEqual({ method: 'GET', url: 'root/chains/test/blocks/head/metadata', + query: { version: '0' }, }); expect(result).toEqual({ @@ -1505,6 +1508,7 @@ describe('RpcClient test', () => { expect(httpBackend.createRequest.mock.calls[0][0]).toEqual({ method: 'GET', url: 'root/chains/test/blocks/head', + query: { version: '0' }, }); const endorsement = response.operations[0][0] .contents[0] as OperationContentsAndResultEndorsement; @@ -1748,6 +1752,7 @@ describe('RpcClient test', () => { expect(httpBackend.createRequest.mock.calls[0][0]).toEqual({ method: 'GET', url: 'root/chains/test/blocks/head', + query: { version: '0' }, }); const transaction = response.operations[0][0] .contents[0] as OperationContentsAndResultTransaction; @@ -1837,6 +1842,7 @@ describe('RpcClient test', () => { expect(httpBackend.createRequest.mock.calls[0][0]).toEqual({ method: 'GET', url: 'root/chains/test/blocks/head', + query: { version: '0' }, }); const endorsementWithSlot = response.operations[0][0] .contents[0] as OperationContentsAndResultEndorsementWithSlot; @@ -2395,6 +2401,7 @@ describe('RpcClient test', () => { expect(httpBackend.createRequest.mock.calls[0][0]).toEqual({ method: 'GET', url: 'root/chains/test/blocks/head', + query: { version: '0' }, }); const transaction = response.operations[0][0] @@ -2541,6 +2548,7 @@ describe('RpcClient test', () => { expect(httpBackend.createRequest.mock.calls[0][0]).toEqual({ method: 'GET', url: 'root/chains/test/blocks/head', + query: { version: '0' }, }); const origination = response.operations[3][0] @@ -3902,6 +3910,7 @@ describe('RpcClient test', () => { expect(httpBackend.createRequest.mock.calls[0][0]).toEqual({ method: 'POST', url: 'root/chains/test/blocks/head/helpers/scripts/run_operation', + query: { version: '0' }, }); expect(httpBackend.createRequest.mock.calls[0][1]).toEqual(testData); @@ -3964,6 +3973,7 @@ describe('RpcClient test', () => { expect(httpBackend.createRequest.mock.calls[0][0]).toEqual({ method: 'POST', url: 'root/chains/test/blocks/head/helpers/scripts/simulate_operation', + query: { version: '0' }, }); expect(httpBackend.createRequest.mock.calls[0][1]).toEqual(testData); @@ -4296,73 +4306,6 @@ describe('RpcClient test', () => { }); }); - describe('getTxRollupState', () => { - it('should query the correct url and return a rollup state response', async (done) => { - const mockResponse = { - last_removed_commitment_hashes: null, - finalized_commitments: { - next: 0, - }, - unfinalized_commitments: { - next: 0, - }, - uncommitted_inboxes: { - newest: 0, - oldest: 0, - }, - commitment_newest_hash: null, - tezos_head_level: 63691, - burn_per_byte: '0', - allocated_storage: '4000', - occupied_storage: '40', - inbox_ema: 0, - commitments_watermark: null, - }; - - httpBackend.createRequest.mockReturnValue(Promise.resolve(mockResponse)); - - const txRollupState = await client.getTxRollupState('txrID'); - - expect(httpBackend.createRequest.mock.calls[0][0]).toEqual({ - method: 'GET', - url: `root/chains/test/blocks/head/context/tx_rollup/txrID/state`, - }); - - expect(txRollupState).toBeDefined(); - expect(txRollupState).toEqual(mockResponse); - - done(); - }); - }); - - describe('getTxRollupInbox', () => { - it('should query the correct url and return a rollup inbox response', async (done) => { - httpBackend.createRequest.mockReturnValue( - Promise.resolve({ - inbox_length: 1, - cumulated_size: 4, - merkle_root: 'txi3Ef5CSsBWRaqQhWj2zg51J3tUqHFD47na6ex7zcboTG5oXEFrm', - }) - ); - - const txRollupInbox = await client.getTxRollupInbox('txrID', '0'); - - expect(httpBackend.createRequest.mock.calls[0][0]).toEqual({ - method: 'GET', - url: `root/chains/test/blocks/head/context/tx_rollup/txrID/inbox/0`, - }); - - expect(txRollupInbox).toBeDefined(); - expect(txRollupInbox!.inbox_length).toEqual(1); - expect(txRollupInbox!.cumulated_size).toEqual(4); - expect(txRollupInbox!.merkle_root).toEqual( - 'txi3Ef5CSsBWRaqQhWj2zg51J3tUqHFD47na6ex7zcboTG5oXEFrm' - ); - - done(); - }); - }); - describe('smartRollupOriginate', () => { it('should have correct types to access smart_rollup_originate results', async (done) => { httpBackend.createRequest.mockReturnValue(Promise.resolve(smartRollupOriginateResponse)); @@ -4717,7 +4660,8 @@ describe('RpcClient test', () => { describe('getPendingOperations', () => { it('should query the correct url and retrun pending operations in mempool', async (done) => { httpBackend.createRequest.mockReturnValue(Promise.resolve(pendingOperationsResponse)); - const response: PendingOperations = await client.getPendingOperations(); + const response: PendingOperationsV1 | PendingOperationsV2 = + await client.getPendingOperations(); expect(httpBackend.createRequest.mock.calls[0][0]).toEqual({ method: 'GET', From 36a4394143ec4a07d59d4d4dc196d25f052e64c2 Mon Sep 17 00:00:00 2001 From: hui-an-yang <106410553+hui-an-yang@users.noreply.github.com> Date: Mon, 18 Sep 2023 14:00:24 -0700 Subject: [PATCH 2/3] 2648 oxford estimation update (#2659) * test: updated estimation assertion be compatible with oxford gas improvement * fix: fix known contract bug in integration test * test: updated assertion values --- integration-tests/config.ts | 4 ++-- .../contract-estimation-tests.spec.ts | 14 +++++++------- integration-tests/known-contracts-ProxfordS.ts | 12 ++++++------ 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/integration-tests/config.ts b/integration-tests/config.ts index f438a15beb..5b7fee7ec3 100644 --- a/integration-tests/config.ts +++ b/integration-tests/config.ts @@ -161,8 +161,8 @@ const oxfordnetSecretKey: Config = const ghostnetEphemeral: Config = defaultConfig({ networkName: 'GHOSTNET', - protocol: Protocols.Proxford, - defaultRpc: 'ecad-ghostnet-rolling:8732', + protocol: Protocols.PtNairobi, + defaultRpc: 'http://ecad-ghostnet-rolling:8732', knownContracts: knownContractsPtGhostnet, signerConfig: defaultEphemeralConfig('https://keygen.ecadinfra.com/ghostnet') }); diff --git a/integration-tests/contract-estimation-tests.spec.ts b/integration-tests/contract-estimation-tests.spec.ts index f3bf345030..26a9ef57d7 100644 --- a/integration-tests/contract-estimation-tests.spec.ts +++ b/integration-tests/contract-estimation-tests.spec.ts @@ -106,7 +106,7 @@ CONFIGS().forEach(({ lib, setup, knownBaker, createAddress, rpc }) => { expect(estimate.minimalFeeMutez).toEqual(472); expect(estimate.totalCost).toEqual(472); expect(estimate.usingBaseFeeMutez).toEqual(472); - expect(estimate.consumedMilligas).toEqual(1356735); + expect(estimate.consumedMilligas).toEqual(1356379); done(); }); @@ -117,14 +117,14 @@ CONFIGS().forEach(({ lib, setup, knownBaker, createAddress, rpc }) => { 50) ).toTransferParams(); const estimate = await LowAmountTez.estimate.transfer(tx); - expect(estimate.gasLimit).toEqual(1572); + expect(estimate.gasLimit).toEqual(1571); expect(estimate.storageLimit).toEqual(514); expect(estimate.suggestedFeeMutez).toEqual(643); expect(estimate.burnFeeMutez).toEqual(128500); expect(estimate.minimalFeeMutez).toEqual(543); expect(estimate.totalCost).toEqual(129043); expect(estimate.usingBaseFeeMutez).toEqual(543); - expect(estimate.consumedMilligas).toEqual(1471270); + expect(estimate.consumedMilligas).toEqual(1470914); done(); }); @@ -138,7 +138,7 @@ CONFIGS().forEach(({ lib, setup, knownBaker, createAddress, rpc }) => { expect(estimate.minimalFeeMutez).toEqual(519); expect(estimate.totalCost).toEqual(79769); expect(estimate.usingBaseFeeMutez).toEqual(519); - expect(estimate.consumedMilligas).toEqual(1767848); + expect(estimate.consumedMilligas).toEqual(1767492); done(); }); @@ -152,7 +152,7 @@ CONFIGS().forEach(({ lib, setup, knownBaker, createAddress, rpc }) => { expect(estimate.minimalFeeMutez).toEqual(637); expect(estimate.totalCost).toEqual(159137); expect(estimate.usingBaseFeeMutez).toEqual(637); - expect(estimate.consumedMilligas).toEqual(2293496); + expect(estimate.consumedMilligas).toEqual(2293140); // Do the actual operation const op2 = await contract.methods.do(originate2()).send(); await op2.confirmation(); @@ -199,7 +199,7 @@ CONFIGS().forEach(({ lib, setup, knownBaker, createAddress, rpc }) => { const params = { fee: 2000, to: await Tezos.signer.publicKeyHash(), mutez: true, amount: amt - (1382 + DEFAULT_FEE.REVEAL) }; await expect(LowAmountTez.estimate.transfer(params)).rejects.toMatchObject({ - id: 'proto.017-PtNairob.implicit.empty_implicit_contract', + id: expect.stringContaining('implicit_contract'), }); done(); }); @@ -208,7 +208,7 @@ CONFIGS().forEach(({ lib, setup, knownBaker, createAddress, rpc }) => { await expect( LowAmountTez.estimate.transfer({ to: await Tezos.signer.publicKeyHash(), mutez: true, amount: amt }) ).rejects.toMatchObject({ - id: 'proto.017-PtNairob.tez.subtraction_underflow', + id: expect.stringContaining('subtraction_underflow'), }); done(); }); diff --git a/integration-tests/known-contracts-ProxfordS.ts b/integration-tests/known-contracts-ProxfordS.ts index 7e44171986..ca2f4719ae 100644 --- a/integration-tests/known-contracts-ProxfordS.ts +++ b/integration-tests/known-contracts-ProxfordS.ts @@ -1,8 +1,8 @@ import { KnownContracts } from './known-contracts'; export const knownContractsProxfordS: KnownContracts = { - contract: "KT1TU9LydXWri8CBTQmzwnwjCm3dK8jt1LQA", - bigMapContract: "KT1MYLamQavaVMYqgn9f4gMgHzEZfQD73qYs", - tzip12BigMapOffChainContract: "KT1XX1JK4C7aPL2joE7nfeWRwPdrJYwroAUa", - saplingContract: "KT1MfFxdU3kpXMSmHZN4tYBbYkGRAbLt5Q1Y", - onChainViewContractAddress: "KT1TYMtN2yFQDmk82VFymQeZapp6BF1NsZ7B" -}; \ No newline at end of file + contract: "KT1TU9LydXWri8CBTQmzwnwjCm3dK8jt1LQA", + bigMapContract: "KT1MYLamQavaVMYqgn9f4gMgHzEZfQD73qYs", + tzip12BigMapOffChainContract: "KT1XX1JK4C7aPL2joE7nfeWRwPdrJYwroAUa", + saplingContract: "KT1MfFxdU3kpXMSmHZN4tYBbYkGRAbLt5Q1Y", + onChainViewContractAddress: "KT1TYMtN2yFQDmk82VFymQeZapp6BF1NsZ7B" +}; From 59def8f78c0423b93552b8d8cea35ebfefd6c2d1 Mon Sep 17 00:00:00 2001 From: hui-an-yang <106410553+hui-an-yang@users.noreply.github.com> Date: Mon, 18 Sep 2023 16:19:18 -0700 Subject: [PATCH 3/3] 2646 remove set deposits limit op reference (#2655) * refactor: removed set_deposit_limit in local-forger.forge() for oxford re #2646 * test: updated local-forging test to be compatible both nairobi and oxford * chore: syncing the fix of known-contract oxfordnet bug --- integration-tests/data/allTestsCases.ts | 48 ++++++++++--------- integration-tests/local-forging.spec.ts | 16 ++++++- packages/taquito-local-forging/src/codec.ts | 4 -- packages/taquito-local-forging/src/encoder.ts | 5 -- .../src/taquito-local-forging.ts | 2 - 5 files changed, 40 insertions(+), 35 deletions(-) diff --git a/integration-tests/data/allTestsCases.ts b/integration-tests/data/allTestsCases.ts index 077697fedd..94e31fdede 100644 --- a/integration-tests/data/allTestsCases.ts +++ b/integration-tests/data/allTestsCases.ts @@ -48,85 +48,89 @@ interface TestCase { expected?: object; } -export const commonCases: TestCase[] = [ +export const nairobiCases: TestCase[] = [ + { - name: 'Delegation', + name: 'Set deposits limit 1000000', operation: { branch: 'BLzyjjHKEKMULtvkpSHxuZxx6ei6fpntH2BTkYZiLgs8zLVstvX', contents: [ { - kind: OpKind.DELEGATION, - delegate: 'tz1QZ6KY7d3BuZDT1d19dUxoQrtFPN2QJ3hn', + kind: OpKind.SET_DEPOSITS_LIMIT, counter: '1', source: 'tz1QZ6KY7d3BuZDT1d19dUxoQrtFPN2QJ3hn', fee: '10000', gas_limit: '10', storage_limit: '10', + limit: '1000000', }, ], }, }, { - name: 'Reveal', + name: 'Unset deposits limit', operation: { branch: 'BLzyjjHKEKMULtvkpSHxuZxx6ei6fpntH2BTkYZiLgs8zLVstvX', contents: [ { - kind: OpKind.REVEAL, + kind: OpKind.SET_DEPOSITS_LIMIT, counter: '1', source: 'tz1QZ6KY7d3BuZDT1d19dUxoQrtFPN2QJ3hn', - public_key: 'edpkvS5QFv7KRGfa3b87gg9DBpxSm3NpSwnjhUjNBQrRUUR66F7C9g', fee: '10000', gas_limit: '10', - storage_limit: '10', + storage_limit: '10' }, ], }, }, +] + +export const commonCases: TestCase[] = [ { - name: 'Ballot', + name: 'Delegation', operation: { branch: 'BLzyjjHKEKMULtvkpSHxuZxx6ei6fpntH2BTkYZiLgs8zLVstvX', contents: [ { - kind: OpKind.BALLOT, + kind: OpKind.DELEGATION, + delegate: 'tz1QZ6KY7d3BuZDT1d19dUxoQrtFPN2QJ3hn', + counter: '1', source: 'tz1QZ6KY7d3BuZDT1d19dUxoQrtFPN2QJ3hn', - period: -300, - ballot: 'yay', - proposal: 'PsCARTHAGazKbHtnKfLzQg3kms52kSRpgnDY982a9oYsSXRLQEb', + fee: '10000', + gas_limit: '10', + storage_limit: '10', }, ], }, }, { - name: 'Set deposits limit 1000000', + name: 'Reveal', operation: { branch: 'BLzyjjHKEKMULtvkpSHxuZxx6ei6fpntH2BTkYZiLgs8zLVstvX', contents: [ { - kind: OpKind.SET_DEPOSITS_LIMIT, + kind: OpKind.REVEAL, counter: '1', source: 'tz1QZ6KY7d3BuZDT1d19dUxoQrtFPN2QJ3hn', + public_key: 'edpkvS5QFv7KRGfa3b87gg9DBpxSm3NpSwnjhUjNBQrRUUR66F7C9g', fee: '10000', gas_limit: '10', storage_limit: '10', - limit: '1000000', }, ], }, }, { - name: 'Unset deposits limit', + name: 'Ballot', operation: { branch: 'BLzyjjHKEKMULtvkpSHxuZxx6ei6fpntH2BTkYZiLgs8zLVstvX', contents: [ { - kind: OpKind.SET_DEPOSITS_LIMIT, - counter: '1', + kind: OpKind.BALLOT, source: 'tz1QZ6KY7d3BuZDT1d19dUxoQrtFPN2QJ3hn', - fee: '10000', - gas_limit: '10', - storage_limit: '10' + period: -300, + ballot: 'yay', + proposal: 'PsCARTHAGazKbHtnKfLzQg3kms52kSRpgnDY982a9oYsSXRLQEb', }, ], }, diff --git a/integration-tests/local-forging.spec.ts b/integration-tests/local-forging.spec.ts index 228bac63b7..aa487c73e3 100644 --- a/integration-tests/local-forging.spec.ts +++ b/integration-tests/local-forging.spec.ts @@ -1,12 +1,24 @@ import { CONFIGS } from "./config"; -import { commonCases } from './data/allTestsCases'; +import { commonCases, nairobiCases } from './data/allTestsCases'; import { LocalForger, ProtocolsHash } from '@taquito/local-forging' -import { TezosToolkit } from "@taquito/taquito"; +import { Protocols, TezosToolkit } from "@taquito/taquito"; CONFIGS().forEach(({ rpc, protocol }) => { const Tezos = new TezosToolkit(rpc); + const nairobinet = protocol === Protocols.PtNairobi ? it : it.skip; describe(`Test local forger: ${rpc}`, () => { + nairobiCases.forEach(({ name, operation, expected }) => { + // Oxford has removed to forge set and unset deposit limit ops in rpcForger. + // We removed them in localForger .forge, but keep the .parse logic for now. + nairobinet(`Verify that .parse for local forge will return same operation that rpc forge for rpc: ${name} (${rpc})`, async done => { + const localForger = new LocalForger(protocol as unknown as ProtocolsHash); + const rpcResult = await Tezos.rpc.forgeOperations(operation); + expect(await localForger.parse(rpcResult)).toEqual(expected || operation); + + done(); + }); + }); // all protocols commonCases.forEach(({ name, operation, expected }) => { it(`Verify that .forge for local forge will return same result as for network forge for rpc: ${name} (${rpc})`, async done => { diff --git a/packages/taquito-local-forging/src/codec.ts b/packages/taquito-local-forging/src/codec.ts index 175f4d05e6..af5b9eb001 100644 --- a/packages/taquito-local-forging/src/codec.ts +++ b/packages/taquito-local-forging/src/codec.ts @@ -501,10 +501,6 @@ export const burnLimitDecoder = (value: Uint8ArrayConsumer) => { } }; -export const depositsLimitEncoder = (val: string) => { - return !val ? '00' : `ff${zarithEncoder(val)}`; -}; - export const depositsLimitDecoder = (value: Uint8ArrayConsumer) => { const prefix = value.consume(1); if (Buffer.from(prefix).toString('hex') !== '00') { diff --git a/packages/taquito-local-forging/src/encoder.ts b/packages/taquito-local-forging/src/encoder.ts index 3e23e11686..917f2ee26b 100644 --- a/packages/taquito-local-forging/src/encoder.ts +++ b/packages/taquito-local-forging/src/encoder.ts @@ -15,7 +15,6 @@ import { proposalEncoder, proposalsEncoder, publicKeyEncoder, - depositsLimitEncoder, pvmKindEncoder, smartContractAddressEncoder, smartRollupAddressEncoder, @@ -49,7 +48,6 @@ import { TransferTicketSchema, TxRollupOriginationSchema, TxRollupSubmitBatchSchema, - SetDepositsLimitSchema, SmartRollupOriginateSchema, SmartRollupExecuteOutboxMessageSchema, SmartRollupAddMessagesSchema, @@ -85,7 +83,6 @@ export const encoders: { [key: string]: Encoder } = { [CODEC.TX_ROLLUP_ID]: txRollupIdEncoder, [CODEC.TX_ROLLUP_BATCH_CONTENT]: txRollupBatchContentEncoder, [CODEC.BURN_LIMIT]: burnLimitEncoder, - [CODEC.DEPOSITS_LIMIT]: depositsLimitEncoder, [CODEC.PVM_KIND]: pvmKindEncoder, [CODEC.PADDED_BYTES]: paddedBytesEncoder, [CODEC.SMART_ROLLUP_MESSAGE]: smartRollupMessageEncoder, @@ -122,6 +119,4 @@ encoders[CODEC.OP_SMART_ROLLUP_ADD_MESSAGES] = (val: any) => encoders[CODEC.OP_SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE] = (val: any) => schemaEncoder(encoders)(SmartRollupExecuteOutboxMessageSchema)(val); encoders[CODEC.MANAGER] = schemaEncoder(encoders)(ManagerOperationSchema); -encoders[CODEC.OP_SET_DEPOSITS_LIMIT] = (val) => - schemaEncoder(encoders)(SetDepositsLimitSchema)(val); encoders[CODEC.OP_FAILING_NOOP] = (val: any) => schemaEncoder(encoders)(FailingNoopSchema)(val); diff --git a/packages/taquito-local-forging/src/taquito-local-forging.ts b/packages/taquito-local-forging/src/taquito-local-forging.ts index 49b51422b3..da0cf13e03 100644 --- a/packages/taquito-local-forging/src/taquito-local-forging.ts +++ b/packages/taquito-local-forging/src/taquito-local-forging.ts @@ -58,8 +58,6 @@ export class LocalForger implements Forger { continue; } else if (content.kind === 'transaction' && diff[0] === 'parameters') { continue; - } else if (content.kind === 'set_deposits_limit' && diff[0] === 'limit') { - continue; } else if ( content.kind === ('tx_rollup_submit_batch' as unknown) && diff[0] === 'burn_limit'