Skip to content

Commit

Permalink
Merge branch 'oxford' of github.com:ecadlabs/taquito into 2646-remove…
Browse files Browse the repository at this point in the history
…-set_deposits_limit_op_reference
  • Loading branch information
hui-an-yang committed Sep 18, 2023
2 parents fcf7c74 + 1cdaf6a commit 9811731
Show file tree
Hide file tree
Showing 10 changed files with 146 additions and 325 deletions.
2 changes: 2 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@
"nairobibox",
"nairobinet",
"octez",
"oxfordnet",
"oxheadalpha",
"precommit",
"println",
"Protofire",
"Proxford",
"PtNairobi",
"rollups",
"Roxane",
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ 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({
Expand Down
34 changes: 23 additions & 11 deletions integration-tests/rpc-nodes.spec.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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;

Expand Down Expand Up @@ -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',
Expand Down
22 changes: 5 additions & 17 deletions packages/taquito-contracts-library/src/rpc-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,13 @@ import {
RunViewResult,
SaplingDiffResponse,
ScriptResponse,
TxRollupInboxResponse,
TxRollupStateResponse,
UnparsingMode,
VotesListingsResponse,
VotingPeriodBlockResult,
TicketTokenParams,
AllTicketBalances,
PendingOperations,
PendingOperationsV1,
PendingOperationsV2,
PendingOperationsQueryArguments,
OriginationProofParams,
RPCSimulateOperationParam,
Expand Down Expand Up @@ -293,19 +292,6 @@ export class RpcWrapperContractsLibrary implements RpcClientInterface {
async getProtocols({ block }: RPCOptions = defaultRPCOptions): Promise<ProtocolsResponse> {
return this.rpc.getProtocols({ block });
}
async getTxRollupState(
txRollupId: string,
{ block }: RPCOptions = defaultRPCOptions
): Promise<TxRollupStateResponse> {
return this.rpc.getTxRollupState(txRollupId, { block });
}
async getTxRollupInbox(
txRollupId: string,
blockLevel: string,
{ block }: RPCOptions = defaultRPCOptions
): Promise<TxRollupInboxResponse | null> {
return this.rpc.getTxRollupInbox(txRollupId, blockLevel, { block });
}
async getStorageUsedSpace(
contract: string,
{ block }: RPCOptions = defaultRPCOptions
Expand All @@ -331,7 +317,9 @@ export class RpcWrapperContractsLibrary implements RpcClientInterface {
): Promise<AllTicketBalances> {
return this.rpc.getAllTicketBalances(contract, { block });
}
async getPendingOperations(args: PendingOperationsQueryArguments): Promise<PendingOperations> {
async getPendingOperations(
args: PendingOperationsQueryArguments
): Promise<PendingOperationsV1 | PendingOperationsV2> {
return this.rpc.getPendingOperations(args);
}
async getOriginationProof(
Expand Down
20 changes: 7 additions & 13 deletions packages/taquito-rpc/src/rpc-client-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,26 @@ import {
SaplingDiffResponse,
ScriptResponse,
StorageResponse,
TxRollupInboxResponse,
TxRollupStateResponse,
UnparsingMode,
VotesListingsResponse,
VotingInfoResponse,
VotingPeriodBlockResult,
TicketTokenParams,
AllTicketBalances,
PendingOperations,
PendingOperationsV1,
PendingOperationsV2,
PendingOperationsQueryArguments,
OriginationProofParams,
RPCSimulateOperationParam,
} from './types';

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<string>;
Expand Down Expand Up @@ -118,12 +118,6 @@ export interface RpcClientInterface {
getSaplingDiffById(id: string, options?: RPCOptions): Promise<SaplingDiffResponse>;
getSaplingDiffByContract(contract: string, options?: RPCOptions): Promise<SaplingDiffResponse>;
getProtocols(options?: RPCOptions): Promise<ProtocolsResponse>;
getTxRollupState(txRollupId: string, options?: RPCOptions): Promise<TxRollupStateResponse>;
getTxRollupInbox(
txRollupId: string,
blockLevel: string,
options?: RPCOptions
): Promise<TxRollupInboxResponse | null>;
getStorageUsedSpace(contract: string, options?: RPCOptions): Promise<string>;
getStoragePaidSpace(contract: string, options?: RPCOptions): Promise<string>;
getTicketBalance(
Expand All @@ -132,7 +126,9 @@ export interface RpcClientInterface {
options?: RPCOptions
): Promise<string>;
getAllTicketBalances(contract: string, options?: RPCOptions): Promise<AllTicketBalances>;
getPendingOperations(args: PendingOperationsQueryArguments): Promise<PendingOperations>;
getPendingOperations(
args: PendingOperationsQueryArguments
): Promise<PendingOperationsV1 | PendingOperationsV2>;
getOriginationProof(params: OriginationProofParams, options?: RPCOptions): Promise<string>;
}

Expand Down Expand Up @@ -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',
Expand Down
43 changes: 3 additions & 40 deletions packages/taquito-rpc/src/rpc-client-modules/rpc-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,14 @@ import {
SaplingDiffResponse,
ScriptResponse,
StorageResponse,
TxRollupInboxResponse,
TxRollupStateResponse,
UnparsingMode,
VotesListingsResponse,
VotingPeriodBlockResult,
TicketTokenParams,
AllTicketBalances,
PendingOperationsQueryArguments,
PendingOperations,
PendingOperationsV1,
PendingOperationsV2,
OriginationProofParams,
RPCSimulateOperationParam,
} from '../types';
Expand Down Expand Up @@ -1103,42 +1102,6 @@ export class RpcClientCache implements RpcClientInterface {
}
}

async getTxRollupState(
txRollupId: string,
{ block }: { block: string } = defaultRPCOptions
): Promise<TxRollupStateResponse> {
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<TxRollupInboxResponse | null> {
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
Expand Down Expand Up @@ -1255,7 +1218,7 @@ export class RpcClientCache implements RpcClientInterface {
*/
async getPendingOperations(
args: PendingOperationsQueryArguments = {}
): Promise<PendingOperations> {
): Promise<PendingOperationsV1 | PendingOperationsV2> {
const key = this.formatCacheKey(
this.rpcClient.getRpcUrl(),
RPCMethodName.GET_PENDING_OPERATIONS,
Expand Down
Loading

0 comments on commit 9811731

Please sign in to comment.