Skip to content

Commit

Permalink
2066 support types for new operations in lima (#2097)
Browse files Browse the repository at this point in the history
* feat: support new types for new operations UpdateConsensusKey and DrainDelegate in Lima

re #2066

* test: update_consensus_key unit test added for limanet

re #2066

* test: added drain_deleagte unit test for limanet

re #2066

* test: minor fix rpc-response data and updateConsensusKey unit test

re #2066

* test: addressed comments to update correct test title

re #2066
  • Loading branch information
hui-an-yang authored Nov 17, 2022
1 parent cefe87c commit ecade81
Show file tree
Hide file tree
Showing 4 changed files with 354 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/taquito-rpc/src/opkind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export enum OpKind {
TX_ROLLUP_DISPATCH_TICKETS = 'tx_rollup_dispatch_tickets',
TRANSFER_TICKET = 'transfer_ticket',
INCREASE_PAID_STORAGE = 'increase_paid_storage',
UPDATE_CONSENSUS_KEY = 'update_consensus_key',
DRAIN_DELEGATE = 'drain_delegate',
VDF_REVELATION = 'vdf_revelation',
EVENT = 'event',
}
58 changes: 58 additions & 0 deletions packages/taquito-rpc/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,23 @@ export interface OperationContentsTransferTicket {
entrypoint: string;
}

export interface OperationContentsUpdateConsensusKey {
kind: OpKind.UPDATE_CONSENSUS_KEY;
source: string;
fee: string;
counter: string;
gas_limit: string;
storage_limit: string;
pk: string;
}

export interface OperationContentsDrainDelegate {
kind: OpKind.DRAIN_DELEGATE;
consensus_key: string;
delegate: string;
destination: string;
}

export interface OperationContentsIncreasePaidStorage {
kind: OpKind.INCREASE_PAID_STORAGE;
source: string;
Expand Down Expand Up @@ -483,6 +500,8 @@ export type OperationContents =
| OperationContentsTxRollupRemoveCommitment
| OperationContentsTxRollupRejection
| OperationContentsTransferTicket
| OperationContentsUpdateConsensusKey
| OperationContentsDrainDelegate
| OperationContentsIncreasePaidStorage;

export interface OperationContentsAndResultMetadataExtended {
Expand Down Expand Up @@ -592,6 +611,17 @@ export interface OperationContentsAndResultMetadataIncreasePaidStorage {
internal_operation_results?: InternalOperationResult[];
}

export interface OperationContentsAndResultMetadataUpdateConsensusKey {
balance_updates?: OperationMetadataBalanceUpdates[];
operation_result: OperationResultUpdateConsensusKey;
internal_operation_results?: InternalOperationResult[];
}

export interface OperationContentsAndResultMetadataDrainDelegate {
balance_updates?: OperationMetadataBalanceUpdates[];
allocated_destination_contract?: boolean;
}

export interface OperationContentsAndResultEndorsement {
kind: OpKind.ENDORSEMENT;
block_payload_hash?: string;
Expand Down Expand Up @@ -845,6 +875,25 @@ export interface OperationContentsAndResultTxRollupDispatchTickets {
metadata: OperationContentsAndResultMetadataTxRollupDispatchTickets;
}

export interface OperationContentsAndResultUpdateConsensusKey {
kind: OpKind.UPDATE_CONSENSUS_KEY;
source: string;
fee: string;
counter: string;
gas_limit: string;
storage_limit: string;
pk: string;
metadata: OperationContentsAndResultMetadataUpdateConsensusKey;
}

export interface OperationContentsAndResultDrainDelegate {
kind: OpKind.DRAIN_DELEGATE;
consensus_key: string;
delegate: string;
destination: string;
metadata: OperationContentsAndResultMetadataDrainDelegate;
}

export interface OperationContentsAndResultIncreasePaidStorage {
kind: OpKind.INCREASE_PAID_STORAGE;
source: string;
Expand Down Expand Up @@ -890,6 +939,8 @@ export type OperationContentsAndResult =
| OperationContentsAndResultTxRollupRejection
| OperationContentsAndResultTransferTicket
| OperationContentsAndResultIncreasePaidStorage
| OperationContentsAndResultUpdateConsensusKey
| OperationContentsAndResultDrainDelegate
| OperationContentsAndResultVdfRevelation;

export enum OPERATION_METADATA {
Expand Down Expand Up @@ -1230,6 +1281,13 @@ export interface OperationResultIncreasePaidStorage {
errors?: TezosGenericOperationError[];
}

export interface OperationResultUpdateConsensusKey {
status: OperationResultStatusEnum;
consumed_gas?: string;
consumed_milligas?: string;
errors?: TezosGenericOperationError[];
}

export interface OperationResultDelegation {
status: OperationResultStatusEnum;
consumed_gas?: string;
Expand Down
211 changes: 211 additions & 0 deletions packages/taquito-rpc/test/data/rpc-responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4833,6 +4833,217 @@ export const blockKathmandunetSample = {
],
};

export const blockLimanetSample = {
protocol: 'PtLimaPtLMwfNinJi9rCfDPWea8dFgTZ1MeJ9f1m2SRic6ayiwW',
chain_id: 'NetXizpkH94bocH',
hash: 'BM5sGpbt1rEiNmfbbo8jcQHJaUZQYwKUXe4MK6B8hcxHDeEfuJx',
header: {
level: 104428,
proto: 2,
predecessor: 'BLoSHvgQ6i64fxa2cWV2PW77FB2apjFpuMgGT9CN9YTCkLHYUEu',
timestamp: '2022-11-02T02:02:55Z',
validation_pass: 4,
operations_hash: 'LLob51uyaK2Kn61U7LPTwPDGe7bEsAifAGjHaAXb5QvfwWv1nBwCC',
fitness: ['02', '000197ec', '', 'ffffffff', '00000000'],
context: 'CoVH2RtM1HHzLZmdbM86EkfwLEg42hmcdr4UGVmUezUDjyUEqYyj',
payload_hash: 'vh2keAERJ5aCT7EagCysfCYcxshQiDKmX1nVPw5mMxB1C6QVZ4eP',
payload_round: 0,
proof_of_work_nonce: 'e45ea3f000000000',
liquidity_baking_toggle_vote: 'off',
signature:
'sigPXDyg4aUDxaCQKFvsX1Bttek8M9LxSinKCfNnoFEKYBKRL2V7of9vRJUPVckdaA8GYaTcW5W3MXpvASNQX4PeHEkMSrM3',
},
metadata: {
protocol: 'PtLimaPtLMwfNinJi9rCfDPWea8dFgTZ1MeJ9f1m2SRic6ayiwW',
next_protocol: 'PtLimaPtLMwfNinJi9rCfDPWea8dFgTZ1MeJ9f1m2SRic6ayiwW',
test_chain_status: { status: 'not_running' },
max_operations_ttl: 120,
max_operation_data_length: 32768,
max_block_header_length: 289,
max_operation_list_length: [
{ max_size: 4194304, max_op: 2048 },
{ max_size: 32768 },
{ max_size: 135168, max_op: 132 },
{ max_size: 524288 },
],
proposer: 'tz1PirbogVqfmBT9XCuYJ1KnDx4bnMSYfGru',
baker: 'tz1PirbogVqfmBT9XCuYJ1KnDx4bnMSYfGru',
level_info: {
level: 104428,
level_position: 104427,
cycle: 25,
cycle_position: 2027,
expected_commitment: false,
},
voting_period_info: { voting_period: { index: 5, kind: 'proposal', start_position: 102400 }, position: 2027, remaining: 2068 },
nonce_hash: null,
deactivated: [],
balance_updates: [
{
kind: 'minted',
category: 'baking rewards',
change: '-5000000',
origin: 'block',
},
{
kind: 'contract',
contract: 'tz1MeT8NACB8Q4uV9dPQ3YxXBmYgapbxQxQ5',
change: '5000000',
origin: 'block',
},
{
kind: 'minted',
category: 'baking bonuses',
change: '-4073843',
origin: 'block',
},
{
kind: 'contract',
contract: 'tz1MeT8NACB8Q4uV9dPQ3YxXBmYgapbxQxQ5',
change: '4073843',
origin: 'block',
},
],
liquidity_baking_toggle_ema: 583905253,
implicit_operations_results: [
{
kind: 'transaction',
storage: [
{ int: '1' },
{ int: '261067500100' },
{ int: '100' },
{ bytes: '01e927f00ef734dfc85919635e9afc9166c83ef9fc00' },
{ bytes: '0115eb0104481a6d7921160bc982c5e0a561cd8a3a00' },
],
balance_updates: [
{
kind: 'minted',
category: 'subsidy',
change: '-2500000',
origin: 'subsidy',
},
{
kind: 'contract',
contract: 'KT1TxqZ8QtKvLu3V3JH7Gx58n7Co8pgtpQU5',
change: '2500000',
origin: 'subsidy',
},
],
consumed_gas: '225',
consumed_milligas: '224023',
storage_size: '4632',
},
],
proposer_consensus_key: 'tz1PirbogVqfmBT9XCuYJ1KnDx4bnMSYfGru',
baker_consensus_key: 'tz1PirbogVqfmBT9XCuYJ1KnDx4bnMSYfGru',
consumed_milligas: '1100000',
},
operations: [
[
{
protocol: 'PtLimaPtLMwfNinJi9rCfDPWea8dFgTZ1MeJ9f1m2SRic6ayiwW',
chain_id: 'NetXizpkH94bocH',
hash: 'opT8tdDhEafJu7qrzsdtwSqP1LcD9rKCNG7DoVT59vQV1JdxUu3',
branch: 'BKtKnh7dkSaZyRbAhRL8vF4ZT1SDKRvXptBQ4pKEh6pbmKE7yf4',
contents: [
{
kind: 'endorsement',
slot: 0,
level: 104427,
round: 0,
block_payload_hash: 'vh2zfP3jrzMXxabzESqDmMvSf6iStm9gW6TwsQHscCa423YbrULT',
metadata: {
delegate: 'tz3Q67aMz7gSMiQRcW729sXSfuMtkyAHYfqc',
endorsement_power: 316,
consensus_key: 'tz3Q67aMz7gSMiQRcW729sXSfuMtkyAHYfqc',
},
},
],
signature:
'sigRk4JF7pC3BcfqqPYqdPvv3yAuxJBfUkTMqnx6oDDm6WZZggH7DLkyJMFennY1AaXtprhHBgFtnVptfxPYGRLYLYutqggG',
},
],
[],
[],
[
{
protocol: 'PtLimaPtLMwfNinJi9rCfDPWea8dFgTZ1MeJ9f1m2SRic6ayiwW',
chain_id: 'NetXizpkH94bocH',
hash: 'opNzjyNGHBAgvsVMyezUAPSZKbFcXZmTh6GTjcTjAGtGMpVG3Eh',
branch: 'BM6qkBbRP17B4UeQAFJBzWyPuy2bxEbKHGbUiP97xihMeeRywzW',
contents: [
{
kind: 'update_consensus_key',
source: 'tz1MY8g5UqVmQtpAp7qs1cUwEof1GjZCHgVv',
fee: '369',
counter: '19043',
gas_limit: '1100',
storage_limit: '0',
pk: 'edpkti5K5JbdLpp2dCqiTLoLQqs5wqzeVhfHVnNhsSCuoU8zdHYoY7',
metadata: {
balance_updates: [
{
kind: 'contract',
contract: 'tz1MY8g5UqVmQtpAp7qs1cUwEof1GjZCHgVv',
change: '-369',
origin: 'block',
},
{
kind: 'accumulator',
category: 'block fees',
change: '369',
origin: 'block',
},
],
operation_result: {
status: 'applied',
consumed_gas: '1000',
consumed_milligas: '1000000',
},
},
},
{
kind: 'drain_delegate',
consensus_key: 'tz1KvJCU5cNdz5RAS3diEtdRvS9wfhRC7Cwj',
delegate: 'tz1MY8g5UqVmQtpAp7qs1cUwEof1GjZCHgVv',
destination: 'tz1KvJCU5cNdz5RAS3diEtdRvS9wfhRC7Cwj',
metadata: {
balance_updates: [
{
kind: 'contract',
contract: 'tz1MY8g5UqVmQtpAp7qs1cUwEof1GjZCHgVv',
change: '-15525772494',
origin: 'block',
},
{
kind: 'contract',
contract: 'tz1KvJCU5cNdz5RAS3diEtdRvS9wfhRC7Cwj',
change: '15525772494',
origin: 'block',
},
{
kind: 'contract',
contract: 'tz1MY8g5UqVmQtpAp7qs1cUwEof1GjZCHgVv',
change: '-156825984',
origin: 'block',
},
{
kind: 'contract',
contract: 'tz1hoyMUiJYYr4FRPMU8Z7WJzYkqgjygjaTy',
change: '156825984',
origin: 'block',
},
],
},
},
],
signature:
'sigrsWF7LpFpUBrTdvLnKm8DMuijk1LcZovZdKZDgsaafTPZhKsvLzPFHDzZYKCy4kobkgxVL7YPGnU5qzJJBcP2cAu5HW1C',
},
],
],
};

export const blockMondaynetSample = {
protocol: 'ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK',
chain_id: 'NetXrxsLyu6hTHx',
Expand Down
Loading

0 comments on commit ecade81

Please sign in to comment.