diff --git a/integration-tests/contract-deploy-having-ticket.spec.ts b/integration-tests/contract-deploy-having-ticket.spec.ts new file mode 100644 index 0000000000..23ed42b0c3 --- /dev/null +++ b/integration-tests/contract-deploy-having-ticket.spec.ts @@ -0,0 +1,110 @@ +import { CONFIGS } from "./config"; +import { ticketCode } from './data/code_with_ticket'; +import { ticketCodeProto14 } from './data/code_with_ticket_proto14'; +import { Protocols } from "@taquito/taquito"; + +CONFIGS().forEach(({ lib, rpc, setup, protocol }) => { + const Tezos = lib; + const kathmandunet = protocol === Protocols.PtKathman ? test: test.skip; + const limanetAndAlpha = protocol === Protocols.PtLimaPtL || protocol === Protocols.ProtoALpha ? test: test.skip; + + describe(`Test origination of a token contract using: ${rpc}`, () => { + + beforeEach(async (done) => { + await setup(); + done(); + }); + + kathmandunet('Originates a contract having ticket with init and the contract api', async (done) => { + const op = await Tezos.contract.originate({ + code: ticketCodeProto14, + init: `(Pair None None)` + }); + + await op.confirmation(); + expect(op.hash).toBeDefined(); + expect(op.includedInBlock).toBeLessThan(Number.POSITIVE_INFINITY); + + done(); + }); + + kathmandunet('Originates a contract having ticket with init in JSON and the contract api', async (done) => { + const op = await Tezos.contract.originate({ + code: ticketCodeProto14, + init: { prim: 'Pair', args: [ { prim: 'None' }, { prim: 'None' } ] } + }); + + await op.confirmation(); + expect(op.hash).toBeDefined(); + expect(op.includedInBlock).toBeLessThan(Number.POSITIVE_INFINITY); + + done(); + }); + + kathmandunet('Originates a contract having ticket with storage and the contract api', async (done) => { + const op = await Tezos.contract.originate({ + code: ticketCodeProto14, + storage: { + '%x': null, + '%y': null + } + }); + + await op.confirmation(); + expect(op.hash).toBeDefined(); + expect(op.includedInBlock).toBeLessThan(Number.POSITIVE_INFINITY); + + done(); + }); + }); + + describe(`Test origination of a token contract using: ${rpc}`, () => { + + beforeEach(async (done) => { + await setup(); + done(); + }); + + limanetAndAlpha('Originates a contract having ticket with init and the contract api', async (done) => { + const op = await Tezos.contract.originate({ + code: ticketCode, + init: `(Pair None None)` + }); + + await op.confirmation(); + expect(op.hash).toBeDefined(); + expect(op.includedInBlock).toBeLessThan(Number.POSITIVE_INFINITY); + + done(); + }); + + limanetAndAlpha('Originates a contract having ticket with init in JSON and the contract api', async (done) => { + const op = await Tezos.contract.originate({ + code: ticketCode, + init: { prim: 'Pair', args: [ { prim: 'None' }, { prim: 'None' } ] } + }); + + await op.confirmation(); + expect(op.hash).toBeDefined(); + expect(op.includedInBlock).toBeLessThan(Number.POSITIVE_INFINITY); + + done(); + }); + + limanetAndAlpha('Originates a contract having ticket with storage and the contract api', async (done) => { + const op = await Tezos.contract.originate({ + code: ticketCode, + storage: { + '%x': null, + '%y': null + } + }); + + await op.confirmation(); + expect(op.hash).toBeDefined(); + expect(op.includedInBlock).toBeLessThan(Number.POSITIVE_INFINITY); + + done(); + }); + }); +}) diff --git a/integration-tests/contract-edo-deploy-having-ticket.spec.ts b/integration-tests/contract-edo-deploy-having-ticket.spec.ts deleted file mode 100644 index d02d74f399..0000000000 --- a/integration-tests/contract-edo-deploy-having-ticket.spec.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { CONFIGS } from "./config"; -import { ticketCode, ticketStorage } from './data/code_with_ticket'; - -CONFIGS().forEach(({ lib, rpc, setup }) => { - const Tezos = lib; - - describe(`Test origination of a token contract using: ${rpc}`, () => { - - beforeEach(async (done) => { - await setup(); - done() - }) - test('Originates a contract having ticket with init and the wallet api', async (done) => { - const op = await Tezos.wallet.originate({ - code: ticketCode, - init: ticketStorage - }).send(); - - await op.confirmation(); - expect(op.opHash).toBeDefined(); - - done(); - }); - - test('Originates a contract having ticket with init and the contract api', async (done) => { - const op = await Tezos.contract.originate({ - code: ticketCode, - init: `(Pair None None)` - }); - - await op.confirmation(); - expect(op.hash).toBeDefined(); - expect(op.includedInBlock).toBeLessThan(Number.POSITIVE_INFINITY); - - done(); - }); - - test('Originates a contract having ticket with init in JSON and the contract api', async (done) => { - const op = await Tezos.contract.originate({ - code: ticketCode, - init: { prim: 'Pair', args: [ { prim: 'None' }, { prim: 'None' } ] } - }); - - await op.confirmation(); - expect(op.hash).toBeDefined(); - expect(op.includedInBlock).toBeLessThan(Number.POSITIVE_INFINITY); - - done(); - }); - - test('Originates a contract having ticket with storage and the contract api', async (done) => { - const op = await Tezos.contract.originate({ - code: ticketCode, - storage: { - '%x': null, - '%y': null - } - }); - - await op.confirmation(); - expect(op.hash).toBeDefined(); - expect(op.includedInBlock).toBeLessThan(Number.POSITIVE_INFINITY); - - done(); - }); - }); -}) diff --git a/integration-tests/data/allTestsCases.ts b/integration-tests/data/allTestsCases.ts index ef6db392f6..f343f0d75f 100644 --- a/integration-tests/data/allTestsCases.ts +++ b/integration-tests/data/allTestsCases.ts @@ -8,16 +8,17 @@ import { example9, example10, } from './code_with_sapling'; +import { ticketCode, ticketStorage } from './code_with_ticket'; import { - ticketCode, - ticketCode2, - ticketCode3, - ticketCode4, - ticketStorage, - ticketStorage2, - ticketStorage3, - ticketStorage4, -} from './code_with_ticket'; + ticketCodeProto14, + ticketCode2Proto14, + ticketCode3Proto14, + ticketCode4Proto14, + ticketStorageProto14, + ticketStorage2Proto14, + ticketStorage3Proto14, + ticketStorage4Proto14, +} from './code_with_ticket_proto14'; import { genericCode, genericStorage } from './generic_contract'; import { tokenBigmapCode, tokenBigmapStorage } from './token_bigmap'; import { noAnnotCode, noAnnotInit } from './token_without_annotation'; @@ -30,6 +31,7 @@ import { import { codeViewsTopLevel, storageViewsTopLevel } from './contract_views_top_level'; import { MichelsonV1Expression, OpKind } from '@taquito/rpc'; import { emitCode } from './code_with_emit'; +import { opMappingProto14 } from '../../packages/taquito-local-forging/src/proto14-kathmandu/constants-proto14' function extractOp( startIndex: number, @@ -804,7 +806,7 @@ export const commonCases: TestCase[] = [ ], }, }, - ...extractOp(0, 150, opMapping).map((op): TestCase => { + ...extractOp(0, 151, opMappingProto14).map((op): TestCase => { return { name: `Origination operation (${op})`, operation: { @@ -941,8 +943,8 @@ export const commonCases: TestCase[] = [ storage_limit: '10', balance: '0', script: { - code: ticketCode, - storage: ticketStorage, + code: ticketCodeProto14, + storage: ticketStorageProto14, }, }, ], @@ -962,8 +964,8 @@ export const commonCases: TestCase[] = [ storage_limit: '10', balance: '0', script: { - code: ticketCode2, - storage: ticketStorage2, + code: ticketCode2Proto14, + storage: ticketStorage2Proto14, }, }, ], @@ -983,8 +985,8 @@ export const commonCases: TestCase[] = [ storage_limit: '10', balance: '0', script: { - code: ticketCode3, - storage: ticketStorage3, + code: ticketCode3Proto14, + storage: ticketStorage3Proto14, }, }, ], @@ -1004,8 +1006,8 @@ export const commonCases: TestCase[] = [ storage_limit: '10', balance: '0', script: { - code: ticketCode4, - storage: ticketStorage4, + code: ticketCode4Proto14, + storage: ticketStorage4Proto14, }, }, ], @@ -1342,10 +1344,52 @@ export const commonCases: TestCase[] = [ ], }, }, + { + name: `Origination of a contract that contains the instructions EMIT`, + operation: { + branch: 'BMV9bffK5yjWCJgUJBsoTRifb4SsAYbkCVwVkKbJHffJYn7ePBL', + contents: [ + { + kind: OpKind.ORIGINATION, + counter: '94141', + source: 'tz2WH1zahKo2KiS1gcHBhNFTURPfW1Vk7qpE', + fee: '603', + gas_limit: '1526', + storage_limit: '377', + balance: '0', + script: { + code: emitCode, + storage: { + prim: 'Unit', + }, + }, + }, + ], + }, + }, + { + name: `Increase Paid Storage operation`, + operation: { + branch: 'BMV9bffK5yjWCJgUJBsoTRifb4SsAYbkCVwVkKbJHffJYn7ePBL', + contents: [ + { + kind: OpKind.INCREASE_PAID_STORAGE, + counter: '1', + source: 'tz2WH1zahKo2KiS1gcHBhNFTURPfW1Vk7qpE', + fee: '100', + gas_limit: '10000', + storage_limit: '10', + amount: '2', + destination: 'KT1JHqHQdHSgWBKo6H4UfG8dw3JnZSyjGkHA', + }, + ], + }, + }, ]; -export const kathmanduCases: TestCase[] = [ - ...extractOp(150, 151, opMapping).map((op): TestCase => { +export const limaCases: TestCase[] = [ + // In `opMapping` from the file `constants.ts`, the operations and types starting at `ticket` were added in the lima protocol + ...extractOp(154, 154, opMapping).map((op): TestCase => { return { name: `Origination operation (${op})`, operation: { @@ -1369,7 +1413,7 @@ export const kathmanduCases: TestCase[] = [ }; }), { - name: `Origination of a contract that contains the instructions EMIT`, + name: `Origination of a contract that contains the instructions TICKET`, operation: { branch: 'BMV9bffK5yjWCJgUJBsoTRifb4SsAYbkCVwVkKbJHffJYn7ePBL', contents: [ @@ -1382,29 +1426,40 @@ export const kathmanduCases: TestCase[] = [ storage_limit: '377', balance: '0', script: { - code: emitCode, - storage: { - prim: 'Unit', - }, + code: ticketCode, + storage: ticketStorage, }, }, ], }, }, { - name: `Increase Paid Storage operation`, + name: `Update Consensus Key operation`, operation: { branch: 'BMV9bffK5yjWCJgUJBsoTRifb4SsAYbkCVwVkKbJHffJYn7ePBL', contents: [ { - kind: OpKind.INCREASE_PAID_STORAGE, + kind: OpKind.UPDATE_CONSENSUS_KEY, counter: '1', - source: 'tz2WH1zahKo2KiS1gcHBhNFTURPfW1Vk7qpE', + source: 'tz1KvJCU5cNdz5RAS3diEtdRvS9wfhRC7Cwj', fee: '100', gas_limit: '10000', storage_limit: '10', - amount: '2', - destination: 'KT1JHqHQdHSgWBKo6H4UfG8dw3JnZSyjGkHA', + pk: 'edpkti5K5JbdLpp2dCqiTLoLQqs5wqzeVhfHVnNhsSCuoU8zdHYoY7' + }, + ], + }, + }, + { + name: `Drain Delegate operation`, + operation: { + branch: 'BMV9bffK5yjWCJgUJBsoTRifb4SsAYbkCVwVkKbJHffJYn7ePBL', + contents: [ + { + kind: OpKind.DRAIN_DELEGATE, + consensus_key: 'tz1MY8g5UqVmQtpAp7qs1cUwEof1GjZCHgVv', + delegate: 'tz1MY8g5UqVmQtpAp7qs1cUwEof1GjZCHgVv', + destination: 'tz1KvJCU5cNdz5RAS3diEtdRvS9wfhRC7Cwj', }, ], }, diff --git a/integration-tests/data/code_with_ticket.ts b/integration-tests/data/code_with_ticket.ts index 1f70613fb1..92f2ded546 100644 --- a/integration-tests/data/code_with_ticket.ts +++ b/integration-tests/data/code_with_ticket.ts @@ -38,6 +38,24 @@ export const ticketCode = [ { prim: 'PUSH', args: [{ prim: 'nat' }, { int: '43' }] }, { prim: 'PUSH', args: [{ prim: 'int' }, { int: '1' }] }, { prim: 'TICKET' }, + [ + { + "prim": "IF_NONE", + "args": [ + [ + [ + { + "prim": "UNIT" + }, + { + "prim": "FAILWITH" + } + ] + ], + [] + ] + } + ], { prim: 'NIL', args: [{ prim: 'operation' }] }, { prim: 'SELF', annots: ['%run'] }, { prim: 'PUSH', args: [{ prim: 'mutez' }, { int: '0' }] }, @@ -50,6 +68,24 @@ export const ticketCode = [ { prim: 'PUSH', args: [{ prim: 'nat' }, { int: '42' }] }, { prim: 'PUSH', args: [{ prim: 'string' }, { string: 'abc' }] }, { prim: 'TICKET' }, + [ + { + "prim": "IF_NONE", + "args": [ + [ + [ + { + "prim": "UNIT" + }, + { + "prim": "FAILWITH" + } + ] + ], + [] + ] + } + ], { prim: 'DIG', args: [{ int: '3' }] }, { prim: 'SWAP' }, { prim: 'SOME' }, @@ -121,159 +157,7 @@ export const ticketCode = [ { prim: 'CDR' }, { prim: 'SWAP' }, { prim: 'PAIR' }, - { prim: 'NIL', args: [{ prim: 'operation' }] } - ] - ] - }, - { prim: 'PAIR' } - ] - ] - } -]; - -export const ticketStorage2 = { - prim: 'Pair', - args: [{ bytes: '00006dba164f4293b862a5e2c5ab84888ea8d7f8cbe6' }, { int: '39' }] -}; - -export const ticketCode2 = [ - { - prim: 'parameter', - args: [ - { - prim: 'or', - args: [ - { prim: 'ticket', args: [{ prim: 'unit' }], annots: ['%receive'] }, - { - prim: 'pair', - args: [ - { - prim: 'contract', - args: [{ prim: 'ticket', args: [{ prim: 'unit' }] }], - annots: ['%destination'] - }, - { prim: 'nat', annots: ['%amount'] }, - { prim: 'address', annots: ['%ticketer'] } - ], - annots: ['%send'] - } - ] - } - ] - }, - { - prim: 'storage', - args: [ - { - prim: 'pair', - args: [ - { prim: 'address', annots: ['%manager'] }, - { - prim: 'big_map', - args: [{ prim: 'address' }, { prim: 'ticket', args: [{ prim: 'unit' }] }], - annots: ['%tickets'] - } - ] - } - ] - }, - { - prim: 'code', - args: [ - [ - { prim: 'AMOUNT' }, - { prim: 'PUSH', args: [{ prim: 'mutez' }, { int: '0' }] }, - [ - [{ prim: 'COMPARE' }, { prim: 'EQ' }], - { prim: 'IF', args: [[], [[{ prim: 'UNIT' }, { prim: 'FAILWITH' }]]] } - ], - { prim: 'UNPAIR', args: [{ int: '3' }] }, - { - prim: 'IF_LEFT', - args: [ - [ - { prim: 'READ_TICKET' }, - { prim: 'CAR', annots: ['@ticketer'] }, - { prim: 'DUP' }, - { prim: 'DIG', args: [{ int: '4' }] }, - { prim: 'NONE', args: [{ prim: 'ticket', args: [{ prim: 'unit' }] }] }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'GET_AND_UPDATE' }, - [ - { - prim: 'IF_NONE', - args: [ - [{ prim: 'DIG', args: [{ int: '2' }] }], - [ - { prim: 'DIG', args: [{ int: '3' }] }, - { prim: 'PAIR' }, - { prim: 'JOIN_TICKETS' }, - [ - { - prim: 'IF_NONE', - args: [[[{ prim: 'UNIT' }, { prim: 'FAILWITH' }]], []] - } - ] - ] - ] - } - ], - { prim: 'SOME' }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'GET_AND_UPDATE' }, - [{ prim: 'IF_NONE', args: [[], [[{ prim: 'UNIT' }, { prim: 'FAILWITH' }]]] }], - { prim: 'SWAP' }, - { prim: 'PAIR' }, - { prim: 'NIL', args: [{ prim: 'operation' }] } - ], - [ - { prim: 'DUP', args: [{ int: '2' }], annots: ['@manager'] }, - { prim: 'SENDER' }, - [ - [{ prim: 'COMPARE' }, { prim: 'EQ' }], - { prim: 'IF', args: [[], [[{ prim: 'UNIT' }, { prim: 'FAILWITH' }]]] } - ], - { prim: 'UNPAIR', args: [{ int: '3' }] }, - { prim: 'DIG', args: [{ int: '4' }] }, - { prim: 'NONE', args: [{ prim: 'ticket', args: [{ prim: 'unit' }] }] }, - { prim: 'DUP', args: [{ int: '5' }], annots: ['@ticketer'] }, - { prim: 'GET_AND_UPDATE' }, - [{ prim: 'IF_NONE', args: [[[{ prim: 'UNIT' }, { prim: 'FAILWITH' }]], []] }], - { prim: 'READ_TICKET' }, - { prim: 'GET', args: [{ int: '4' }], annots: ['@total_amount'] }, - { prim: 'DUP', args: [{ int: '5' }], annots: ['@amount'] }, - { prim: 'SWAP' }, - { prim: 'SUB' }, - { prim: 'ISNAT' }, - [ - { - prim: 'IF_NONE', - args: [ - [[{ prim: 'UNIT' }, { prim: 'FAILWITH' }]], - [{ prim: 'RENAME', annots: ['@remaining_amount'] }] - ] - } - ], - { prim: 'DIG', args: [{ int: '4' }] }, - { prim: 'PAIR' }, - { prim: 'SWAP' }, - { prim: 'SPLIT_TICKET' }, - [{ prim: 'IF_NONE', args: [[[{ prim: 'UNIT' }, { prim: 'FAILWITH' }]], []] }], - { prim: 'UNPAIR', annots: ['@to_send', '@to_keep'] }, - { prim: 'DUG', args: [{ int: '5' }] }, - { prim: 'SOME' }, - { prim: 'DIG', args: [{ int: '3' }] }, - { prim: 'GET_AND_UPDATE' }, - [{ prim: 'IF_NONE', args: [[], [[{ prim: 'UNIT' }, { prim: 'FAILWITH' }]]] }], - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'PAIR' }, - { prim: 'SWAP' }, - { prim: 'PUSH', args: [{ prim: 'mutez' }, { int: '0' }] }, - { prim: 'DIG', args: [{ int: '3' }] }, - { prim: 'TRANSFER_TOKENS' }, { prim: 'NIL', args: [{ prim: 'operation' }] }, - { prim: 'SWAP' }, - { prim: 'CONS' } ] ] }, @@ -282,1412 +166,3 @@ export const ticketCode2 = [ ] } ]; - -export const ticketStorage3 = { - prim: 'Pair', - args: [ - [ - { bytes: '00000d4f0cf2fae2437f924120ef030f53abd4d4e520' }, - { int: '90' }, - { int: '10' }, - { prim: 'False' }, - { int: '1609898008' }, - { int: '600' } - ], - { int: '139' } - ] -}; - -export const ticketCode3 = [ - { - prim: 'parameter', - args: [ - { - prim: 'or', - args: [ - { - prim: 'or', - args: [ - { - prim: 'or', - args: [ - { - prim: 'contract', - args: [{ prim: 'ticket', args: [{ prim: 'nat' }] }], - annots: ['%buy'] - }, - { - prim: 'contract', - args: [{ prim: 'ticket', args: [{ prim: 'nat' }] }], - annots: ['%cancel'] - } - ] - }, - { - prim: 'or', - args: [ - { - prim: 'pair', - args: [ - { prim: 'nat', annots: ['%opening_price'] }, - { - prim: 'pair', - args: [ - { prim: 'nat', annots: ['%set_reserve_price'] }, - { - prim: 'pair', - args: [ - { prim: 'timestamp', annots: ['%set_start_time'] }, - { - prim: 'pair', - args: [ - { prim: 'int', annots: ['%set_round_time'] }, - { - prim: 'ticket', - args: [{ prim: 'nat' }], - annots: ['%ticket'] - } - ] - } - ] - } - ] - } - ], - annots: ['%configure'] - }, - { prim: 'nat', annots: ['%drop_price'] } - ] - } - ] - }, - { prim: 'unit', annots: ['%start'] } - ] - } - ] - }, - { - prim: 'storage', - args: [ - { - prim: 'pair', - args: [ - { - prim: 'pair', - args: [ - { prim: 'address', annots: ['%admin'] }, - { - prim: 'pair', - args: [ - { prim: 'nat', annots: ['%current_price'] }, - { - prim: 'pair', - args: [ - { prim: 'nat', annots: ['%reserve_price'] }, - { - prim: 'pair', - args: [ - { prim: 'bool', annots: ['%in_progress'] }, - { - prim: 'pair', - args: [ - { prim: 'timestamp', annots: ['%start_time'] }, - { prim: 'int', annots: ['%round_time'] } - ] - } - ] - } - ] - } - ] - } - ], - annots: ['%data'] - }, - { - prim: 'big_map', - args: [{ prim: 'nat' }, { prim: 'ticket', args: [{ prim: 'nat' }] }], - annots: ['%tickets'] - } - ] - } - ] - }, - { - prim: 'code', - args: [ - [ - { prim: 'UNPAIR' }, - { prim: 'SWAP' }, - { prim: 'UNPAIR' }, - { prim: 'DIG', args: [{ int: '2' }] }, - { - prim: 'IF_LEFT', - args: [ - [ - { - prim: 'IF_LEFT', - args: [ - [ - { - prim: 'IF_LEFT', - args: [ - [ - { prim: 'NOW' }, - { prim: 'AMOUNT' }, - { prim: 'DIG', args: [{ int: '3' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '4' }] }, - { prim: 'CAR' }, - { prim: 'SENDER' }, - { prim: 'COMPARE' }, - { prim: 'NEQ' }, - { - prim: 'IF', - args: [ - [], - [ - { - prim: 'PUSH', - args: [ - { prim: 'string' }, - { string: 'failed assertion' } - ] - }, - { prim: 'FAILWITH' } - ] - ] - }, - { prim: 'DIG', args: [{ int: '3' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '4' }] }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CAR' }, - { - prim: 'IF', - args: [ - [], - [ - { - prim: 'PUSH', - args: [ - { prim: 'string' }, - { string: 'failed assertion' } - ] - }, - { prim: 'FAILWITH' } - ] - ] - }, - { prim: 'PUSH', args: [{ prim: 'mutez' }, { int: '1' }] }, - { prim: 'DIG', args: [{ int: '4' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '5' }] }, - { prim: 'CDR' }, - { prim: 'CAR' }, - { prim: 'MUL' }, - { prim: 'SWAP' }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '2' }] }, - { prim: 'COMPARE' }, - { prim: 'EQ' }, - { - prim: 'IF', - args: [ - [], - [ - { - prim: 'PUSH', - args: [ - { prim: 'string' }, - { string: 'failed assertion' } - ] - }, - { prim: 'FAILWITH' } - ] - ] - }, - { prim: 'DIG', args: [{ int: '3' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '4' }] }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'DIG', args: [{ int: '4' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '5' }] }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CAR' }, - { prim: 'ADD' }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'COMPARE' }, - { prim: 'LE' }, - { - prim: 'IF', - args: [ - [], - [ - { - prim: 'PUSH', - args: [ - { prim: 'string' }, - { string: 'failed assertion' } - ] - }, - { prim: 'FAILWITH' } - ] - ] - }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '3' }] }, - { prim: 'CAR' }, - { prim: 'CONTRACT', args: [{ prim: 'unit' }] }, - { - prim: 'IF_NONE', - args: [ - [ - { prim: 'DROP', args: [{ int: '4' }] }, - { - prim: 'PUSH', - args: [ - { prim: 'string' }, - { string: 'contract does not match' } - ] - }, - { prim: 'FAILWITH' } - ], - [ - { prim: 'SWAP' }, - { - prim: 'PUSH', - args: [{ prim: 'unit' }, { prim: 'Unit' }] - }, - { prim: 'TRANSFER_TOKENS' }, - { prim: 'DIG', args: [{ int: '3' }] }, - { - prim: 'NONE', - args: [ - { prim: 'ticket', args: [{ prim: 'nat' }] } - ] - }, - { - prim: 'PUSH', - args: [{ prim: 'nat' }, { int: '0' }] - }, - { prim: 'GET_AND_UPDATE' }, - { - prim: 'IF_NONE', - args: [ - [ - { prim: 'DROP', args: [{ int: '4' }] }, - { - prim: 'PUSH', - args: [ - { prim: 'string' }, - { string: 'ticket does not exist' } - ] - }, - { prim: 'FAILWITH' } - ], - [ - { prim: 'DIG', args: [{ int: '3' }] }, - { - prim: 'PUSH', - args: [ - { prim: 'mutez' }, - { int: '0' } - ] - }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'TRANSFER_TOKENS' }, - { prim: 'SWAP' }, - { prim: 'DIG', args: [{ int: '3' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '4' }] }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { - prim: 'PUSH', - args: [ - { prim: 'bool' }, - { prim: 'False' } - ] - }, - { prim: 'PAIR' }, - { prim: 'DIG', args: [{ int: '4' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '5' }] }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CAR' }, - { prim: 'PAIR' }, - { prim: 'DIG', args: [{ int: '4' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '5' }] }, - { prim: 'CDR' }, - { prim: 'CAR' }, - { prim: 'PAIR' }, - { prim: 'DIG', args: [{ int: '4' }] }, - { prim: 'CAR' }, - { prim: 'PAIR' }, - { prim: 'PAIR' }, - { - prim: 'NIL', - args: [{ prim: 'operation' }] - }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'CONS' }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'CONS' }, - { prim: 'PAIR' } - ] - ] - } - ] - ] - } - ], - [ - { prim: 'SWAP' }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '2' }] }, - { prim: 'CAR' }, - { prim: 'SENDER' }, - { prim: 'COMPARE' }, - { prim: 'EQ' }, - { - prim: 'IF', - args: [ - [], - [ - { - prim: 'PUSH', - args: [ - { prim: 'string' }, - { string: 'failed assertion' } - ] - }, - { prim: 'FAILWITH' } - ] - ] - }, - { prim: 'SWAP' }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '2' }] }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CAR' }, - { - prim: 'IF', - args: [ - [], - [ - { - prim: 'PUSH', - args: [ - { prim: 'string' }, - { string: 'failed assertion' } - ] - }, - { prim: 'FAILWITH' } - ] - ] - }, - { prim: 'DIG', args: [{ int: '2' }] }, - { - prim: 'NONE', - args: [{ prim: 'ticket', args: [{ prim: 'nat' }] }] - }, - { prim: 'PUSH', args: [{ prim: 'nat' }, { int: '0' }] }, - { prim: 'GET_AND_UPDATE' }, - { - prim: 'IF_NONE', - args: [ - [ - { prim: 'DROP', args: [{ int: '3' }] }, - { - prim: 'PUSH', - args: [ - { prim: 'string' }, - { string: 'ticket does not exist' } - ] - }, - { prim: 'FAILWITH' } - ], - [ - { prim: 'DIG', args: [{ int: '2' }] }, - { - prim: 'PUSH', - args: [{ prim: 'mutez' }, { int: '0' }] - }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'TRANSFER_TOKENS' }, - { prim: 'SWAP' }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '3' }] }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { - prim: 'PUSH', - args: [{ prim: 'bool' }, { prim: 'False' }] - }, - { prim: 'PAIR' }, - { prim: 'DIG', args: [{ int: '3' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '4' }] }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CAR' }, - { prim: 'PAIR' }, - { prim: 'DIG', args: [{ int: '3' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '4' }] }, - { prim: 'CDR' }, - { prim: 'CAR' }, - { prim: 'PAIR' }, - { prim: 'DIG', args: [{ int: '3' }] }, - { prim: 'CAR' }, - { prim: 'PAIR' }, - { prim: 'PAIR' }, - { prim: 'NIL', args: [{ prim: 'operation' }] }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'CONS' }, - { prim: 'PAIR' } - ] - ] - } - ] - ] - } - ], - [ - { - prim: 'IF_LEFT', - args: [ - [ - { prim: 'SWAP' }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '2' }] }, - { prim: 'CAR' }, - { prim: 'SOURCE' }, - { prim: 'COMPARE' }, - { prim: 'EQ' }, - { - prim: 'IF', - args: [ - [], - [ - { - prim: 'PUSH', - args: [ - { prim: 'string' }, - { string: 'failed assertion' } - ] - }, - { prim: 'FAILWITH' } - ] - ] - }, - { prim: 'SWAP' }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '2' }] }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CAR' }, - { prim: 'NOT' }, - { - prim: 'IF', - args: [ - [], - [ - { - prim: 'PUSH', - args: [ - { prim: 'string' }, - { string: 'failed assertion' } - ] - }, - { prim: 'FAILWITH' } - ] - ] - }, - { prim: 'UNPAIR' }, - { prim: 'SWAP' }, - { prim: 'UNPAIR' }, - { prim: 'SWAP' }, - { prim: 'UNPAIR' }, - { prim: 'SWAP' }, - { prim: 'UNPAIR' }, - { prim: 'DIG', args: [{ int: '6' }] }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'SOME' }, - { prim: 'PUSH', args: [{ prim: 'nat' }, { int: '0' }] }, - { prim: 'UPDATE' }, - { prim: 'SWAP' }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'PAIR' }, - { prim: 'PUSH', args: [{ prim: 'bool' }, { prim: 'False' }] }, - { prim: 'PAIR' }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'PAIR' }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'PAIR' }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'CAR' }, - { prim: 'PAIR' }, - { prim: 'PAIR' }, - { prim: 'NIL', args: [{ prim: 'operation' }] }, - { prim: 'PAIR' } - ], - [ - { prim: 'NOW' }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '3' }] }, - { prim: 'CAR' }, - { prim: 'SENDER' }, - { prim: 'COMPARE' }, - { prim: 'EQ' }, - { - prim: 'IF', - args: [ - [], - [ - { - prim: 'PUSH', - args: [ - { prim: 'string' }, - { string: 'failed assertion' } - ] - }, - { prim: 'FAILWITH' } - ] - ] - }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '3' }] }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CAR' }, - { - prim: 'IF', - args: [ - [], - [ - { - prim: 'PUSH', - args: [ - { prim: 'string' }, - { string: 'failed assertion' } - ] - }, - { prim: 'FAILWITH' } - ] - ] - }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '3' }] }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CAR' }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '3' }] }, - { prim: 'COMPARE' }, - { prim: 'GE' }, - { - prim: 'IF', - args: [ - [], - [ - { - prim: 'PUSH', - args: [ - { prim: 'string' }, - { string: 'failed assertion' } - ] - }, - { prim: 'FAILWITH' } - ] - ] - }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '3' }] }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'DIG', args: [{ int: '3' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '4' }] }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CAR' }, - { prim: 'ADD' }, - { prim: 'SWAP' }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '2' }] }, - { prim: 'COMPARE' }, - { prim: 'GT' }, - { - prim: 'IF', - args: [ - [], - [ - { - prim: 'PUSH', - args: [ - { prim: 'string' }, - { string: 'failed assertion' } - ] - }, - { prim: 'FAILWITH' } - ] - ] - }, - { prim: 'DIG', args: [{ int: '3' }] }, - { prim: 'DIG', args: [{ int: '3' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '4' }] }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'DIG', args: [{ int: '3' }] }, - { prim: 'PAIR' }, - { prim: 'DIG', args: [{ int: '3' }] }, - { prim: 'CAR' }, - { prim: 'PAIR' }, - { prim: 'DUP' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'DIG', args: [{ int: '3' }] }, - { prim: 'PAIR' }, - { prim: 'SWAP' }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '2' }] }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CAR' }, - { prim: 'PAIR' }, - { prim: 'SWAP' }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '2' }] }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CAR' }, - { prim: 'PAIR' }, - { prim: 'SWAP' }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '2' }] }, - { prim: 'CDR' }, - { prim: 'CAR' }, - { prim: 'PAIR' }, - { prim: 'SWAP' }, - { prim: 'CAR' }, - { prim: 'PAIR' }, - { prim: 'PAIR' }, - { prim: 'NIL', args: [{ prim: 'operation' }] }, - { prim: 'PAIR' } - ] - ] - } - ] - ] - } - ], - [ - { prim: 'DROP' }, - { prim: 'NOW' }, - { prim: 'SWAP' }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '2' }] }, - { prim: 'CAR' }, - { prim: 'SOURCE' }, - { prim: 'COMPARE' }, - { prim: 'EQ' }, - { - prim: 'IF', - args: [ - [], - [ - { prim: 'PUSH', args: [{ prim: 'string' }, { string: 'failed assertion' }] }, - { prim: 'FAILWITH' } - ] - ] - }, - { prim: 'SWAP' }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '2' }] }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CAR' }, - { prim: 'NOT' }, - { - prim: 'IF', - args: [ - [], - [ - { prim: 'PUSH', args: [{ prim: 'string' }, { string: 'failed assertion' }] }, - { prim: 'FAILWITH' } - ] - ] - }, - { prim: 'SWAP' }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '2' }] }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CAR' }, - { prim: 'SWAP' }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '2' }] }, - { prim: 'COMPARE' }, - { prim: 'GE' }, - { - prim: 'IF', - args: [ - [], - [ - { prim: 'PUSH', args: [{ prim: 'string' }, { string: 'failed assertion' }] }, - { prim: 'FAILWITH' } - ] - ] - }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'NONE', args: [{ prim: 'ticket', args: [{ prim: 'nat' }] }] }, - { prim: 'PUSH', args: [{ prim: 'nat' }, { int: '0' }] }, - { prim: 'GET_AND_UPDATE' }, - { - prim: 'IF_NONE', - args: [ - [ - { prim: 'DROP', args: [{ int: '3' }] }, - { prim: 'PUSH', args: [{ prim: 'string' }, { string: 'no ticket' }] }, - { prim: 'FAILWITH' } - ], - [ - { prim: 'SOME' }, - { prim: 'PUSH', args: [{ prim: 'nat' }, { int: '0' }] }, - { prim: 'UPDATE' }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '3' }] }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'PUSH', args: [{ prim: 'bool' }, { prim: 'True' }] }, - { prim: 'PAIR' }, - { prim: 'DIG', args: [{ int: '3' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '4' }] }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CAR' }, - { prim: 'PAIR' }, - { prim: 'DIG', args: [{ int: '3' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '4' }] }, - { prim: 'CDR' }, - { prim: 'CAR' }, - { prim: 'PAIR' }, - { prim: 'DIG', args: [{ int: '3' }] }, - { prim: 'CAR' }, - { prim: 'PAIR' }, - { prim: 'DUP' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'DIG', args: [{ int: '3' }] }, - { prim: 'PAIR' }, - { prim: 'SWAP' }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '2' }] }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CAR' }, - { prim: 'PAIR' }, - { prim: 'SWAP' }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '2' }] }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CAR' }, - { prim: 'PAIR' }, - { prim: 'SWAP' }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '2' }] }, - { prim: 'CDR' }, - { prim: 'CAR' }, - { prim: 'PAIR' }, - { prim: 'SWAP' }, - { prim: 'CAR' }, - { prim: 'PAIR' }, - { prim: 'PAIR' }, - { prim: 'NIL', args: [{ prim: 'operation' }] }, - { prim: 'PAIR' } - ] - ] - } - ] - ] - } - ] - ] - } -]; - -export const ticketStorage4 = [ - { bytes: '00000d4f0cf2fae2437f924120ef030f53abd4d4e520' }, - { int: '140' }, - { int: '1' }, - { int: '141' } -]; - -export const ticketCode4 = [ - { - prim: 'parameter', - args: [ - { - prim: 'or', - args: [ - { - prim: 'or', - args: [ - { - prim: 'or', - args: [ - { - prim: 'pair', - args: [ - { - prim: 'contract', - args: [ - { - prim: 'pair', - args: [ - { prim: 'nat', annots: ['%opening_price'] }, - { - prim: 'pair', - args: [ - { prim: 'nat', annots: ['%set_reserve_price'] }, - { - prim: 'pair', - args: [ - { - prim: 'timestamp', - annots: ['%set_start_time'] - }, - { - prim: 'pair', - args: [ - { - prim: 'int', - annots: ['%set_round_time'] - }, - { - prim: 'ticket', - args: [{ prim: 'nat' }], - annots: ['%ticket'] - } - ] - } - ] - } - ] - } - ] - } - ], - annots: ['%destination'] - }, - { - prim: 'pair', - args: [ - { prim: 'nat', annots: ['%opening_price'] }, - { - prim: 'pair', - args: [ - { prim: 'nat', annots: ['%reserve_price'] }, - { - prim: 'pair', - args: [ - { prim: 'timestamp', annots: ['%start_time'] }, - { - prim: 'pair', - args: [ - { prim: 'int', annots: ['%round_time'] }, - { prim: 'nat', annots: ['%ticket_id'] } - ] - } - ] - } - ] - } - ] - } - ], - annots: ['%auction'] - }, - { prim: 'nat', annots: ['%burn'] } - ] - }, - { - prim: 'or', - args: [ - { - prim: 'map', - args: [{ prim: 'string' }, { prim: 'bytes' }], - annots: ['%mint'] - }, - { prim: 'ticket', args: [{ prim: 'nat' }], annots: ['%receive'] } - ] - } - ] - }, - { - prim: 'pair', - args: [ - { - prim: 'contract', - args: [{ prim: 'ticket', args: [{ prim: 'nat' }] }], - annots: ['%destination'] - }, - { prim: 'nat', annots: ['%ticket_id'] } - ], - annots: ['%send'] - } - ] - } - ] - }, - { - prim: 'storage', - args: [ - { - prim: 'pair', - args: [ - { prim: 'address', annots: ['%admin'] }, - { - prim: 'pair', - args: [ - { - prim: 'big_map', - args: [{ prim: 'nat' }, { prim: 'ticket', args: [{ prim: 'nat' }] }], - annots: ['%tickets'] - }, - { - prim: 'pair', - args: [ - { prim: 'nat', annots: ['%current_id'] }, - { - prim: 'big_map', - args: [ - { prim: 'nat' }, - { - prim: 'pair', - args: [ - { prim: 'nat' }, - { prim: 'map', args: [{ prim: 'string' }, { prim: 'bytes' }] } - ] - } - ], - annots: ['%token_metadata'] - } - ] - } - ] - } - ] - } - ] - }, - { - prim: 'code', - args: [ - [ - { prim: 'PUSH', args: [{ prim: 'mutez' }, { int: '0' }] }, - { prim: 'AMOUNT' }, - { prim: 'COMPARE' }, - { prim: 'EQ' }, - { - prim: 'IF', - args: [ - [], - [ - { prim: 'PUSH', args: [{ prim: 'string' }, { string: 'failed assertion' }] }, - { prim: 'FAILWITH' } - ] - ] - }, - { prim: 'UNPAIR' }, - { prim: 'SWAP' }, - { prim: 'UNPAIR' }, - { prim: 'SWAP' }, - { prim: 'UNPAIR' }, - { prim: 'SWAP' }, - { prim: 'UNPAIR' }, - { prim: 'DIG', args: [{ int: '4' }] }, - { - prim: 'IF_LEFT', - args: [ - [ - { - prim: 'IF_LEFT', - args: [ - [ - { - prim: 'IF_LEFT', - args: [ - [ - { prim: 'DIG', args: [{ int: '4' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '5' }] }, - { prim: 'SENDER' }, - { prim: 'COMPARE' }, - { prim: 'EQ' }, - { - prim: 'IF', - args: [ - [], - [ - { - prim: 'PUSH', - args: [ - { prim: 'string' }, - { string: 'failed assertion' } - ] - }, - { prim: 'FAILWITH' } - ] - ] - }, - { prim: 'DIG', args: [{ int: '3' }] }, - { - prim: 'NONE', - args: [{ prim: 'ticket', args: [{ prim: 'nat' }] }] - }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '3' }] }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'GET_AND_UPDATE' }, - { - prim: 'IF_NONE', - args: [ - [ - { prim: 'DROP', args: [{ int: '5' }] }, - { - prim: 'PUSH', - args: [ - { prim: 'string' }, - { string: 'no tickets' } - ] - }, - { prim: 'FAILWITH' } - ], - [ - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '3' }] }, - { prim: 'CAR' }, - { - prim: 'PUSH', - args: [{ prim: 'mutez' }, { int: '0' }] - }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'DIG', args: [{ int: '4' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '5' }] }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CAR' }, - { prim: 'PAIR' }, - { prim: 'DIG', args: [{ int: '4' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '5' }] }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CAR' }, - { prim: 'PAIR' }, - { prim: 'DIG', args: [{ int: '4' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '5' }] }, - { prim: 'CDR' }, - { prim: 'CDR' }, - { prim: 'CAR' }, - { prim: 'PAIR' }, - { prim: 'DIG', args: [{ int: '4' }] }, - { prim: 'CDR' }, - { prim: 'CAR' }, - { prim: 'PAIR' }, - { prim: 'TRANSFER_TOKENS' }, - { prim: 'DIG', args: [{ int: '3' }] }, - { prim: 'DIG', args: [{ int: '3' }] }, - { prim: 'PAIR' }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'PAIR' }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'PAIR' }, - { prim: 'NIL', args: [{ prim: 'operation' }] }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'CONS' }, - { prim: 'PAIR' } - ] - ] - } - ], - [ - { prim: 'DIG', args: [{ int: '4' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '5' }] }, - { prim: 'SENDER' }, - { prim: 'COMPARE' }, - { prim: 'EQ' }, - { - prim: 'IF', - args: [ - [], - [ - { - prim: 'PUSH', - args: [ - { prim: 'string' }, - { string: 'failed assertion' } - ] - }, - { prim: 'FAILWITH' } - ] - ] - }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'PUSH', args: [{ prim: 'nat' }, { int: '1' }] }, - { prim: 'DIG', args: [{ int: '3' }] }, - { prim: 'ADD' }, - { prim: 'PAIR' }, - { prim: 'DIG', args: [{ int: '2' }] }, - { - prim: 'NONE', - args: [{ prim: 'ticket', args: [{ prim: 'nat' }] }] - }, - { prim: 'DIG', args: [{ int: '3' }] }, - { prim: 'UPDATE' }, - { prim: 'PAIR' }, - { prim: 'SWAP' }, - { prim: 'PAIR' }, - { prim: 'NIL', args: [{ prim: 'operation' }] }, - { prim: 'PAIR' } - ] - ] - } - ], - [ - { - prim: 'IF_LEFT', - args: [ - [ - { prim: 'DIG', args: [{ int: '4' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '5' }] }, - { prim: 'SENDER' }, - { prim: 'COMPARE' }, - { prim: 'EQ' }, - { - prim: 'IF', - args: [ - [], - [ - { - prim: 'PUSH', - args: [ - { prim: 'string' }, - { string: 'failed assertion' } - ] - }, - { prim: 'FAILWITH' } - ] - ] - }, - { prim: 'DIG', args: [{ int: '3' }] }, - { prim: 'PUSH', args: [{ prim: 'nat' }, { int: '1' }] }, - { prim: 'DIG', args: [{ int: '3' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '4' }] }, - { prim: 'TICKET' }, - { prim: 'SOME' }, - { prim: 'DIG', args: [{ int: '3' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '4' }] }, - { prim: 'GET_AND_UPDATE' }, - { prim: 'DROP' }, - { prim: 'DIG', args: [{ int: '3' }] }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'DIG', args: [{ int: '3' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '4' }] }, - { prim: 'PAIR' }, - { prim: 'SOME' }, - { prim: 'DIG', args: [{ int: '3' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '4' }] }, - { prim: 'UPDATE' }, - { prim: 'PUSH', args: [{ prim: 'nat' }, { int: '1' }] }, - { prim: 'DIG', args: [{ int: '3' }] }, - { prim: 'ADD' }, - { prim: 'PAIR' }, - { prim: 'SWAP' }, - { prim: 'PAIR' }, - { prim: 'SWAP' }, - { prim: 'PAIR' }, - { prim: 'NIL', args: [{ prim: 'operation' }] }, - { prim: 'PAIR' } - ], - [ - { prim: 'READ_TICKET' }, - { prim: 'UNPAIR' }, - { prim: 'DROP' }, - { prim: 'UNPAIR' }, - { prim: 'DROP' }, - { prim: 'DIG', args: [{ int: '4' }] }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'SOME' }, - { prim: 'DIG', args: [{ int: '3' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '4' }] }, - { prim: 'GET_AND_UPDATE' }, - { prim: 'DROP' }, - { prim: 'PUSH', args: [{ prim: 'nat' }, { int: '1' }] }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'COMPARE' }, - { prim: 'EQ' }, - { - prim: 'IF', - args: [ - [], - [ - { - prim: 'PUSH', - args: [ - { prim: 'string' }, - { string: 'failed assertion' } - ] - }, - { prim: 'FAILWITH' } - ] - ] - }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'PUSH', args: [{ prim: 'nat' }, { int: '1' }] }, - { prim: 'DIG', args: [{ int: '3' }] }, - { prim: 'ADD' }, - { prim: 'PAIR' }, - { prim: 'SWAP' }, - { prim: 'PAIR' }, - { prim: 'SWAP' }, - { prim: 'PAIR' }, - { prim: 'NIL', args: [{ prim: 'operation' }] }, - { prim: 'PAIR' } - ] - ] - } - ] - ] - } - ], - [ - { prim: 'DIG', args: [{ int: '4' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '5' }] }, - { prim: 'SENDER' }, - { prim: 'COMPARE' }, - { prim: 'EQ' }, - { - prim: 'IF', - args: [ - [], - [ - { prim: 'PUSH', args: [{ prim: 'string' }, { string: 'failed assertion' }] }, - { prim: 'FAILWITH' } - ] - ] - }, - { prim: 'DIG', args: [{ int: '3' }] }, - { prim: 'NONE', args: [{ prim: 'ticket', args: [{ prim: 'nat' }] }] }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'DUP' }, - { prim: 'DUG', args: [{ int: '3' }] }, - { prim: 'CDR' }, - { prim: 'GET_AND_UPDATE' }, - { - prim: 'IF_NONE', - args: [ - [ - { prim: 'DROP', args: [{ int: '5' }] }, - { prim: 'PUSH', args: [{ prim: 'string' }, { string: 'no tickets' }] }, - { prim: 'FAILWITH' } - ], - [ - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'CAR' }, - { prim: 'PUSH', args: [{ prim: 'mutez' }, { int: '0' }] }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'TRANSFER_TOKENS' }, - { prim: 'DIG', args: [{ int: '3' }] }, - { prim: 'DIG', args: [{ int: '3' }] }, - { prim: 'PAIR' }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'PAIR' }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'PAIR' }, - { prim: 'NIL', args: [{ prim: 'operation' }] }, - { prim: 'DIG', args: [{ int: '2' }] }, - { prim: 'CONS' }, - { prim: 'PAIR' } - ] - ] - } - ] - ] - } - ] - ] - } -]; diff --git a/integration-tests/data/code_with_ticket_proto14.ts b/integration-tests/data/code_with_ticket_proto14.ts new file mode 100644 index 0000000000..5b01a11e95 --- /dev/null +++ b/integration-tests/data/code_with_ticket_proto14.ts @@ -0,0 +1,1693 @@ +export const ticketStorageProto14 = { prim: 'Pair', args: [{ prim: 'None' }, { prim: 'None' }] }; + +export const ticketCodeProto14 = [ + { + prim: 'storage', + args: [ + { + prim: 'pair', + args: [ + { prim: 'option', args: [{ prim: 'ticket', args: [{ prim: 'int' }] }], annots: ['%x'] }, + { prim: 'option', args: [{ prim: 'ticket', args: [{ prim: 'string' }] }], annots: ['%y'] } + ] + } + ] + }, + { + prim: 'parameter', + args: [ + { + prim: 'or', + args: [ + { prim: 'unit', annots: ['%auto_call'] }, + { prim: 'ticket', args: [{ prim: 'int' }], annots: ['%run'] } + ] + } + ] + }, + { + prim: 'code', + args: [ + [ + { prim: 'UNPAIR' }, + { + prim: 'IF_LEFT', + args: [ + [ + { prim: 'DROP' }, + { prim: 'PUSH', args: [{ prim: 'nat' }, { int: '43' }] }, + { prim: 'PUSH', args: [{ prim: 'int' }, { int: '1' }] }, + { prim: 'TICKET' }, + { prim: 'NIL', args: [{ prim: 'operation' }] }, + { prim: 'SELF', annots: ['%run'] }, + { prim: 'PUSH', args: [{ prim: 'mutez' }, { int: '0' }] }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'TRANSFER_TOKENS' }, + { prim: 'CONS' } + ], + [ + { prim: 'READ_TICKET' }, + { prim: 'PUSH', args: [{ prim: 'nat' }, { int: '42' }] }, + { prim: 'PUSH', args: [{ prim: 'string' }, { string: 'abc' }] }, + { prim: 'TICKET' }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'SWAP' }, + { prim: 'SOME' }, + { prim: 'SWAP' }, + { prim: 'CAR' }, + { prim: 'PAIR' }, + { prim: 'DUG', args: [{ int: '2' }] }, + { prim: 'GET', args: [{ int: '4' }] }, + { prim: 'DUP' }, + { prim: 'PUSH', args: [{ prim: 'nat' }, { int: '3' }] }, + { prim: 'SWAP' }, + { prim: 'EDIV' }, + { + prim: 'IF_NONE', + args: [ + [ + { prim: 'PUSH', args: [{ prim: 'int' }, { int: '20' }] }, + { prim: 'FAILWITH' } + ], + [{ prim: 'CAR' }] + ] + }, + { prim: 'SWAP' }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '2' }] }, + { prim: 'SUB' }, + { prim: 'ISNAT' }, + { + prim: 'IF_NONE', + args: [ + [ + { prim: 'PUSH', args: [{ prim: 'int' }, { int: '20' }] }, + { prim: 'FAILWITH' } + ], + [] + ] + }, + { prim: 'PUSH', args: [{ prim: 'nat' }, { int: '3' }] }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'EDIV' }, + { + prim: 'IF_NONE', + args: [ + [ + { prim: 'PUSH', args: [{ prim: 'int' }, { int: '20' }] }, + { prim: 'FAILWITH' } + ], + [{ prim: 'CAR' }] + ] + }, + { prim: 'PAIR' }, + { prim: 'SWAP' }, + { prim: 'SPLIT_TICKET' }, + { + prim: 'IF_NONE', + args: [ + [ + { prim: 'PUSH', args: [{ prim: 'int' }, { int: '20' }] }, + { prim: 'FAILWITH' } + ], + [] + ] + }, + { prim: 'UNPAIR' }, + { prim: 'SWAP' }, + { prim: 'PAIR' }, + { prim: 'JOIN_TICKETS' }, + { prim: 'SWAP' }, + { prim: 'CDR' }, + { prim: 'SWAP' }, + { prim: 'PAIR' }, + { prim: 'NIL', args: [{ prim: 'operation' }] } + ] + ] + }, + { prim: 'PAIR' } + ] + ] + } +]; + +export const ticketStorage2Proto14 = { + prim: 'Pair', + args: [{ bytes: '00006dba164f4293b862a5e2c5ab84888ea8d7f8cbe6' }, { int: '39' }] +}; + +export const ticketCode2Proto14 = [ + { + prim: 'parameter', + args: [ + { + prim: 'or', + args: [ + { prim: 'ticket', args: [{ prim: 'unit' }], annots: ['%receive'] }, + { + prim: 'pair', + args: [ + { + prim: 'contract', + args: [{ prim: 'ticket', args: [{ prim: 'unit' }] }], + annots: ['%destination'] + }, + { prim: 'nat', annots: ['%amount'] }, + { prim: 'address', annots: ['%ticketer'] } + ], + annots: ['%send'] + } + ] + } + ] + }, + { + prim: 'storage', + args: [ + { + prim: 'pair', + args: [ + { prim: 'address', annots: ['%manager'] }, + { + prim: 'big_map', + args: [{ prim: 'address' }, { prim: 'ticket', args: [{ prim: 'unit' }] }], + annots: ['%tickets'] + } + ] + } + ] + }, + { + prim: 'code', + args: [ + [ + { prim: 'AMOUNT' }, + { prim: 'PUSH', args: [{ prim: 'mutez' }, { int: '0' }] }, + [ + [{ prim: 'COMPARE' }, { prim: 'EQ' }], + { prim: 'IF', args: [[], [[{ prim: 'UNIT' }, { prim: 'FAILWITH' }]]] } + ], + { prim: 'UNPAIR', args: [{ int: '3' }] }, + { + prim: 'IF_LEFT', + args: [ + [ + { prim: 'READ_TICKET' }, + { prim: 'CAR', annots: ['@ticketer'] }, + { prim: 'DUP' }, + { prim: 'DIG', args: [{ int: '4' }] }, + { prim: 'NONE', args: [{ prim: 'ticket', args: [{ prim: 'unit' }] }] }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'GET_AND_UPDATE' }, + [ + { + prim: 'IF_NONE', + args: [ + [{ prim: 'DIG', args: [{ int: '2' }] }], + [ + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'PAIR' }, + { prim: 'JOIN_TICKETS' }, + [ + { + prim: 'IF_NONE', + args: [[[{ prim: 'UNIT' }, { prim: 'FAILWITH' }]], []] + } + ] + ] + ] + } + ], + { prim: 'SOME' }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'GET_AND_UPDATE' }, + [{ prim: 'IF_NONE', args: [[], [[{ prim: 'UNIT' }, { prim: 'FAILWITH' }]]] }], + { prim: 'SWAP' }, + { prim: 'PAIR' }, + { prim: 'NIL', args: [{ prim: 'operation' }] } + ], + [ + { prim: 'DUP', args: [{ int: '2' }], annots: ['@manager'] }, + { prim: 'SENDER' }, + [ + [{ prim: 'COMPARE' }, { prim: 'EQ' }], + { prim: 'IF', args: [[], [[{ prim: 'UNIT' }, { prim: 'FAILWITH' }]]] } + ], + { prim: 'UNPAIR', args: [{ int: '3' }] }, + { prim: 'DIG', args: [{ int: '4' }] }, + { prim: 'NONE', args: [{ prim: 'ticket', args: [{ prim: 'unit' }] }] }, + { prim: 'DUP', args: [{ int: '5' }], annots: ['@ticketer'] }, + { prim: 'GET_AND_UPDATE' }, + [{ prim: 'IF_NONE', args: [[[{ prim: 'UNIT' }, { prim: 'FAILWITH' }]], []] }], + { prim: 'READ_TICKET' }, + { prim: 'GET', args: [{ int: '4' }], annots: ['@total_amount'] }, + { prim: 'DUP', args: [{ int: '5' }], annots: ['@amount'] }, + { prim: 'SWAP' }, + { prim: 'SUB' }, + { prim: 'ISNAT' }, + [ + { + prim: 'IF_NONE', + args: [ + [[{ prim: 'UNIT' }, { prim: 'FAILWITH' }]], + [{ prim: 'RENAME', annots: ['@remaining_amount'] }] + ] + } + ], + { prim: 'DIG', args: [{ int: '4' }] }, + { prim: 'PAIR' }, + { prim: 'SWAP' }, + { prim: 'SPLIT_TICKET' }, + [{ prim: 'IF_NONE', args: [[[{ prim: 'UNIT' }, { prim: 'FAILWITH' }]], []] }], + { prim: 'UNPAIR', annots: ['@to_send', '@to_keep'] }, + { prim: 'DUG', args: [{ int: '5' }] }, + { prim: 'SOME' }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'GET_AND_UPDATE' }, + [{ prim: 'IF_NONE', args: [[], [[{ prim: 'UNIT' }, { prim: 'FAILWITH' }]]] }], + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'PAIR' }, + { prim: 'SWAP' }, + { prim: 'PUSH', args: [{ prim: 'mutez' }, { int: '0' }] }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'TRANSFER_TOKENS' }, + { prim: 'NIL', args: [{ prim: 'operation' }] }, + { prim: 'SWAP' }, + { prim: 'CONS' } + ] + ] + }, + { prim: 'PAIR' } + ] + ] + } +]; + +export const ticketStorage3Proto14 = { + prim: 'Pair', + args: [ + [ + { bytes: '00000d4f0cf2fae2437f924120ef030f53abd4d4e520' }, + { int: '90' }, + { int: '10' }, + { prim: 'False' }, + { int: '1609898008' }, + { int: '600' } + ], + { int: '139' } + ] +}; + +export const ticketCode3Proto14 = [ + { + prim: 'parameter', + args: [ + { + prim: 'or', + args: [ + { + prim: 'or', + args: [ + { + prim: 'or', + args: [ + { + prim: 'contract', + args: [{ prim: 'ticket', args: [{ prim: 'nat' }] }], + annots: ['%buy'] + }, + { + prim: 'contract', + args: [{ prim: 'ticket', args: [{ prim: 'nat' }] }], + annots: ['%cancel'] + } + ] + }, + { + prim: 'or', + args: [ + { + prim: 'pair', + args: [ + { prim: 'nat', annots: ['%opening_price'] }, + { + prim: 'pair', + args: [ + { prim: 'nat', annots: ['%set_reserve_price'] }, + { + prim: 'pair', + args: [ + { prim: 'timestamp', annots: ['%set_start_time'] }, + { + prim: 'pair', + args: [ + { prim: 'int', annots: ['%set_round_time'] }, + { + prim: 'ticket', + args: [{ prim: 'nat' }], + annots: ['%ticket'] + } + ] + } + ] + } + ] + } + ], + annots: ['%configure'] + }, + { prim: 'nat', annots: ['%drop_price'] } + ] + } + ] + }, + { prim: 'unit', annots: ['%start'] } + ] + } + ] + }, + { + prim: 'storage', + args: [ + { + prim: 'pair', + args: [ + { + prim: 'pair', + args: [ + { prim: 'address', annots: ['%admin'] }, + { + prim: 'pair', + args: [ + { prim: 'nat', annots: ['%current_price'] }, + { + prim: 'pair', + args: [ + { prim: 'nat', annots: ['%reserve_price'] }, + { + prim: 'pair', + args: [ + { prim: 'bool', annots: ['%in_progress'] }, + { + prim: 'pair', + args: [ + { prim: 'timestamp', annots: ['%start_time'] }, + { prim: 'int', annots: ['%round_time'] } + ] + } + ] + } + ] + } + ] + } + ], + annots: ['%data'] + }, + { + prim: 'big_map', + args: [{ prim: 'nat' }, { prim: 'ticket', args: [{ prim: 'nat' }] }], + annots: ['%tickets'] + } + ] + } + ] + }, + { + prim: 'code', + args: [ + [ + { prim: 'UNPAIR' }, + { prim: 'SWAP' }, + { prim: 'UNPAIR' }, + { prim: 'DIG', args: [{ int: '2' }] }, + { + prim: 'IF_LEFT', + args: [ + [ + { + prim: 'IF_LEFT', + args: [ + [ + { + prim: 'IF_LEFT', + args: [ + [ + { prim: 'NOW' }, + { prim: 'AMOUNT' }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '4' }] }, + { prim: 'CAR' }, + { prim: 'SENDER' }, + { prim: 'COMPARE' }, + { prim: 'NEQ' }, + { + prim: 'IF', + args: [ + [], + [ + { + prim: 'PUSH', + args: [ + { prim: 'string' }, + { string: 'failed assertion' } + ] + }, + { prim: 'FAILWITH' } + ] + ] + }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '4' }] }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CAR' }, + { + prim: 'IF', + args: [ + [], + [ + { + prim: 'PUSH', + args: [ + { prim: 'string' }, + { string: 'failed assertion' } + ] + }, + { prim: 'FAILWITH' } + ] + ] + }, + { prim: 'PUSH', args: [{ prim: 'mutez' }, { int: '1' }] }, + { prim: 'DIG', args: [{ int: '4' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '5' }] }, + { prim: 'CDR' }, + { prim: 'CAR' }, + { prim: 'MUL' }, + { prim: 'SWAP' }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '2' }] }, + { prim: 'COMPARE' }, + { prim: 'EQ' }, + { + prim: 'IF', + args: [ + [], + [ + { + prim: 'PUSH', + args: [ + { prim: 'string' }, + { string: 'failed assertion' } + ] + }, + { prim: 'FAILWITH' } + ] + ] + }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '4' }] }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'DIG', args: [{ int: '4' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '5' }] }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CAR' }, + { prim: 'ADD' }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'COMPARE' }, + { prim: 'LE' }, + { + prim: 'IF', + args: [ + [], + [ + { + prim: 'PUSH', + args: [ + { prim: 'string' }, + { string: 'failed assertion' } + ] + }, + { prim: 'FAILWITH' } + ] + ] + }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '3' }] }, + { prim: 'CAR' }, + { prim: 'CONTRACT', args: [{ prim: 'unit' }] }, + { + prim: 'IF_NONE', + args: [ + [ + { prim: 'DROP', args: [{ int: '4' }] }, + { + prim: 'PUSH', + args: [ + { prim: 'string' }, + { string: 'contract does not match' } + ] + }, + { prim: 'FAILWITH' } + ], + [ + { prim: 'SWAP' }, + { + prim: 'PUSH', + args: [{ prim: 'unit' }, { prim: 'Unit' }] + }, + { prim: 'TRANSFER_TOKENS' }, + { prim: 'DIG', args: [{ int: '3' }] }, + { + prim: 'NONE', + args: [ + { prim: 'ticket', args: [{ prim: 'nat' }] } + ] + }, + { + prim: 'PUSH', + args: [{ prim: 'nat' }, { int: '0' }] + }, + { prim: 'GET_AND_UPDATE' }, + { + prim: 'IF_NONE', + args: [ + [ + { prim: 'DROP', args: [{ int: '4' }] }, + { + prim: 'PUSH', + args: [ + { prim: 'string' }, + { string: 'ticket does not exist' } + ] + }, + { prim: 'FAILWITH' } + ], + [ + { prim: 'DIG', args: [{ int: '3' }] }, + { + prim: 'PUSH', + args: [ + { prim: 'mutez' }, + { int: '0' } + ] + }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'TRANSFER_TOKENS' }, + { prim: 'SWAP' }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '4' }] }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { + prim: 'PUSH', + args: [ + { prim: 'bool' }, + { prim: 'False' } + ] + }, + { prim: 'PAIR' }, + { prim: 'DIG', args: [{ int: '4' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '5' }] }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CAR' }, + { prim: 'PAIR' }, + { prim: 'DIG', args: [{ int: '4' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '5' }] }, + { prim: 'CDR' }, + { prim: 'CAR' }, + { prim: 'PAIR' }, + { prim: 'DIG', args: [{ int: '4' }] }, + { prim: 'CAR' }, + { prim: 'PAIR' }, + { prim: 'PAIR' }, + { + prim: 'NIL', + args: [{ prim: 'operation' }] + }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'CONS' }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'CONS' }, + { prim: 'PAIR' } + ] + ] + } + ] + ] + } + ], + [ + { prim: 'SWAP' }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '2' }] }, + { prim: 'CAR' }, + { prim: 'SENDER' }, + { prim: 'COMPARE' }, + { prim: 'EQ' }, + { + prim: 'IF', + args: [ + [], + [ + { + prim: 'PUSH', + args: [ + { prim: 'string' }, + { string: 'failed assertion' } + ] + }, + { prim: 'FAILWITH' } + ] + ] + }, + { prim: 'SWAP' }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '2' }] }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CAR' }, + { + prim: 'IF', + args: [ + [], + [ + { + prim: 'PUSH', + args: [ + { prim: 'string' }, + { string: 'failed assertion' } + ] + }, + { prim: 'FAILWITH' } + ] + ] + }, + { prim: 'DIG', args: [{ int: '2' }] }, + { + prim: 'NONE', + args: [{ prim: 'ticket', args: [{ prim: 'nat' }] }] + }, + { prim: 'PUSH', args: [{ prim: 'nat' }, { int: '0' }] }, + { prim: 'GET_AND_UPDATE' }, + { + prim: 'IF_NONE', + args: [ + [ + { prim: 'DROP', args: [{ int: '3' }] }, + { + prim: 'PUSH', + args: [ + { prim: 'string' }, + { string: 'ticket does not exist' } + ] + }, + { prim: 'FAILWITH' } + ], + [ + { prim: 'DIG', args: [{ int: '2' }] }, + { + prim: 'PUSH', + args: [{ prim: 'mutez' }, { int: '0' }] + }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'TRANSFER_TOKENS' }, + { prim: 'SWAP' }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '3' }] }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { + prim: 'PUSH', + args: [{ prim: 'bool' }, { prim: 'False' }] + }, + { prim: 'PAIR' }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '4' }] }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CAR' }, + { prim: 'PAIR' }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '4' }] }, + { prim: 'CDR' }, + { prim: 'CAR' }, + { prim: 'PAIR' }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'CAR' }, + { prim: 'PAIR' }, + { prim: 'PAIR' }, + { prim: 'NIL', args: [{ prim: 'operation' }] }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'CONS' }, + { prim: 'PAIR' } + ] + ] + } + ] + ] + } + ], + [ + { + prim: 'IF_LEFT', + args: [ + [ + { prim: 'SWAP' }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '2' }] }, + { prim: 'CAR' }, + { prim: 'SOURCE' }, + { prim: 'COMPARE' }, + { prim: 'EQ' }, + { + prim: 'IF', + args: [ + [], + [ + { + prim: 'PUSH', + args: [ + { prim: 'string' }, + { string: 'failed assertion' } + ] + }, + { prim: 'FAILWITH' } + ] + ] + }, + { prim: 'SWAP' }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '2' }] }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CAR' }, + { prim: 'NOT' }, + { + prim: 'IF', + args: [ + [], + [ + { + prim: 'PUSH', + args: [ + { prim: 'string' }, + { string: 'failed assertion' } + ] + }, + { prim: 'FAILWITH' } + ] + ] + }, + { prim: 'UNPAIR' }, + { prim: 'SWAP' }, + { prim: 'UNPAIR' }, + { prim: 'SWAP' }, + { prim: 'UNPAIR' }, + { prim: 'SWAP' }, + { prim: 'UNPAIR' }, + { prim: 'DIG', args: [{ int: '6' }] }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'SOME' }, + { prim: 'PUSH', args: [{ prim: 'nat' }, { int: '0' }] }, + { prim: 'UPDATE' }, + { prim: 'SWAP' }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'PAIR' }, + { prim: 'PUSH', args: [{ prim: 'bool' }, { prim: 'False' }] }, + { prim: 'PAIR' }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'PAIR' }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'PAIR' }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'CAR' }, + { prim: 'PAIR' }, + { prim: 'PAIR' }, + { prim: 'NIL', args: [{ prim: 'operation' }] }, + { prim: 'PAIR' } + ], + [ + { prim: 'NOW' }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '3' }] }, + { prim: 'CAR' }, + { prim: 'SENDER' }, + { prim: 'COMPARE' }, + { prim: 'EQ' }, + { + prim: 'IF', + args: [ + [], + [ + { + prim: 'PUSH', + args: [ + { prim: 'string' }, + { string: 'failed assertion' } + ] + }, + { prim: 'FAILWITH' } + ] + ] + }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '3' }] }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CAR' }, + { + prim: 'IF', + args: [ + [], + [ + { + prim: 'PUSH', + args: [ + { prim: 'string' }, + { string: 'failed assertion' } + ] + }, + { prim: 'FAILWITH' } + ] + ] + }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '3' }] }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CAR' }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '3' }] }, + { prim: 'COMPARE' }, + { prim: 'GE' }, + { + prim: 'IF', + args: [ + [], + [ + { + prim: 'PUSH', + args: [ + { prim: 'string' }, + { string: 'failed assertion' } + ] + }, + { prim: 'FAILWITH' } + ] + ] + }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '3' }] }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '4' }] }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CAR' }, + { prim: 'ADD' }, + { prim: 'SWAP' }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '2' }] }, + { prim: 'COMPARE' }, + { prim: 'GT' }, + { + prim: 'IF', + args: [ + [], + [ + { + prim: 'PUSH', + args: [ + { prim: 'string' }, + { string: 'failed assertion' } + ] + }, + { prim: 'FAILWITH' } + ] + ] + }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '4' }] }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'PAIR' }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'CAR' }, + { prim: 'PAIR' }, + { prim: 'DUP' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'PAIR' }, + { prim: 'SWAP' }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '2' }] }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CAR' }, + { prim: 'PAIR' }, + { prim: 'SWAP' }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '2' }] }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CAR' }, + { prim: 'PAIR' }, + { prim: 'SWAP' }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '2' }] }, + { prim: 'CDR' }, + { prim: 'CAR' }, + { prim: 'PAIR' }, + { prim: 'SWAP' }, + { prim: 'CAR' }, + { prim: 'PAIR' }, + { prim: 'PAIR' }, + { prim: 'NIL', args: [{ prim: 'operation' }] }, + { prim: 'PAIR' } + ] + ] + } + ] + ] + } + ], + [ + { prim: 'DROP' }, + { prim: 'NOW' }, + { prim: 'SWAP' }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '2' }] }, + { prim: 'CAR' }, + { prim: 'SOURCE' }, + { prim: 'COMPARE' }, + { prim: 'EQ' }, + { + prim: 'IF', + args: [ + [], + [ + { prim: 'PUSH', args: [{ prim: 'string' }, { string: 'failed assertion' }] }, + { prim: 'FAILWITH' } + ] + ] + }, + { prim: 'SWAP' }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '2' }] }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CAR' }, + { prim: 'NOT' }, + { + prim: 'IF', + args: [ + [], + [ + { prim: 'PUSH', args: [{ prim: 'string' }, { string: 'failed assertion' }] }, + { prim: 'FAILWITH' } + ] + ] + }, + { prim: 'SWAP' }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '2' }] }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CAR' }, + { prim: 'SWAP' }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '2' }] }, + { prim: 'COMPARE' }, + { prim: 'GE' }, + { + prim: 'IF', + args: [ + [], + [ + { prim: 'PUSH', args: [{ prim: 'string' }, { string: 'failed assertion' }] }, + { prim: 'FAILWITH' } + ] + ] + }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'NONE', args: [{ prim: 'ticket', args: [{ prim: 'nat' }] }] }, + { prim: 'PUSH', args: [{ prim: 'nat' }, { int: '0' }] }, + { prim: 'GET_AND_UPDATE' }, + { + prim: 'IF_NONE', + args: [ + [ + { prim: 'DROP', args: [{ int: '3' }] }, + { prim: 'PUSH', args: [{ prim: 'string' }, { string: 'no ticket' }] }, + { prim: 'FAILWITH' } + ], + [ + { prim: 'SOME' }, + { prim: 'PUSH', args: [{ prim: 'nat' }, { int: '0' }] }, + { prim: 'UPDATE' }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '3' }] }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'PUSH', args: [{ prim: 'bool' }, { prim: 'True' }] }, + { prim: 'PAIR' }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '4' }] }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CAR' }, + { prim: 'PAIR' }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '4' }] }, + { prim: 'CDR' }, + { prim: 'CAR' }, + { prim: 'PAIR' }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'CAR' }, + { prim: 'PAIR' }, + { prim: 'DUP' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'PAIR' }, + { prim: 'SWAP' }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '2' }] }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CAR' }, + { prim: 'PAIR' }, + { prim: 'SWAP' }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '2' }] }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CAR' }, + { prim: 'PAIR' }, + { prim: 'SWAP' }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '2' }] }, + { prim: 'CDR' }, + { prim: 'CAR' }, + { prim: 'PAIR' }, + { prim: 'SWAP' }, + { prim: 'CAR' }, + { prim: 'PAIR' }, + { prim: 'PAIR' }, + { prim: 'NIL', args: [{ prim: 'operation' }] }, + { prim: 'PAIR' } + ] + ] + } + ] + ] + } + ] + ] + } +]; + +export const ticketStorage4Proto14 = [ + { bytes: '00000d4f0cf2fae2437f924120ef030f53abd4d4e520' }, + { int: '140' }, + { int: '1' }, + { int: '141' } +]; + +export const ticketCode4Proto14 = [ + { + prim: 'parameter', + args: [ + { + prim: 'or', + args: [ + { + prim: 'or', + args: [ + { + prim: 'or', + args: [ + { + prim: 'pair', + args: [ + { + prim: 'contract', + args: [ + { + prim: 'pair', + args: [ + { prim: 'nat', annots: ['%opening_price'] }, + { + prim: 'pair', + args: [ + { prim: 'nat', annots: ['%set_reserve_price'] }, + { + prim: 'pair', + args: [ + { + prim: 'timestamp', + annots: ['%set_start_time'] + }, + { + prim: 'pair', + args: [ + { + prim: 'int', + annots: ['%set_round_time'] + }, + { + prim: 'ticket', + args: [{ prim: 'nat' }], + annots: ['%ticket'] + } + ] + } + ] + } + ] + } + ] + } + ], + annots: ['%destination'] + }, + { + prim: 'pair', + args: [ + { prim: 'nat', annots: ['%opening_price'] }, + { + prim: 'pair', + args: [ + { prim: 'nat', annots: ['%reserve_price'] }, + { + prim: 'pair', + args: [ + { prim: 'timestamp', annots: ['%start_time'] }, + { + prim: 'pair', + args: [ + { prim: 'int', annots: ['%round_time'] }, + { prim: 'nat', annots: ['%ticket_id'] } + ] + } + ] + } + ] + } + ] + } + ], + annots: ['%auction'] + }, + { prim: 'nat', annots: ['%burn'] } + ] + }, + { + prim: 'or', + args: [ + { + prim: 'map', + args: [{ prim: 'string' }, { prim: 'bytes' }], + annots: ['%mint'] + }, + { prim: 'ticket', args: [{ prim: 'nat' }], annots: ['%receive'] } + ] + } + ] + }, + { + prim: 'pair', + args: [ + { + prim: 'contract', + args: [{ prim: 'ticket', args: [{ prim: 'nat' }] }], + annots: ['%destination'] + }, + { prim: 'nat', annots: ['%ticket_id'] } + ], + annots: ['%send'] + } + ] + } + ] + }, + { + prim: 'storage', + args: [ + { + prim: 'pair', + args: [ + { prim: 'address', annots: ['%admin'] }, + { + prim: 'pair', + args: [ + { + prim: 'big_map', + args: [{ prim: 'nat' }, { prim: 'ticket', args: [{ prim: 'nat' }] }], + annots: ['%tickets'] + }, + { + prim: 'pair', + args: [ + { prim: 'nat', annots: ['%current_id'] }, + { + prim: 'big_map', + args: [ + { prim: 'nat' }, + { + prim: 'pair', + args: [ + { prim: 'nat' }, + { prim: 'map', args: [{ prim: 'string' }, { prim: 'bytes' }] } + ] + } + ], + annots: ['%token_metadata'] + } + ] + } + ] + } + ] + } + ] + }, + { + prim: 'code', + args: [ + [ + { prim: 'PUSH', args: [{ prim: 'mutez' }, { int: '0' }] }, + { prim: 'AMOUNT' }, + { prim: 'COMPARE' }, + { prim: 'EQ' }, + { + prim: 'IF', + args: [ + [], + [ + { prim: 'PUSH', args: [{ prim: 'string' }, { string: 'failed assertion' }] }, + { prim: 'FAILWITH' } + ] + ] + }, + { prim: 'UNPAIR' }, + { prim: 'SWAP' }, + { prim: 'UNPAIR' }, + { prim: 'SWAP' }, + { prim: 'UNPAIR' }, + { prim: 'SWAP' }, + { prim: 'UNPAIR' }, + { prim: 'DIG', args: [{ int: '4' }] }, + { + prim: 'IF_LEFT', + args: [ + [ + { + prim: 'IF_LEFT', + args: [ + [ + { + prim: 'IF_LEFT', + args: [ + [ + { prim: 'DIG', args: [{ int: '4' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '5' }] }, + { prim: 'SENDER' }, + { prim: 'COMPARE' }, + { prim: 'EQ' }, + { + prim: 'IF', + args: [ + [], + [ + { + prim: 'PUSH', + args: [ + { prim: 'string' }, + { string: 'failed assertion' } + ] + }, + { prim: 'FAILWITH' } + ] + ] + }, + { prim: 'DIG', args: [{ int: '3' }] }, + { + prim: 'NONE', + args: [{ prim: 'ticket', args: [{ prim: 'nat' }] }] + }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '3' }] }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'GET_AND_UPDATE' }, + { + prim: 'IF_NONE', + args: [ + [ + { prim: 'DROP', args: [{ int: '5' }] }, + { + prim: 'PUSH', + args: [ + { prim: 'string' }, + { string: 'no tickets' } + ] + }, + { prim: 'FAILWITH' } + ], + [ + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '3' }] }, + { prim: 'CAR' }, + { + prim: 'PUSH', + args: [{ prim: 'mutez' }, { int: '0' }] + }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'DIG', args: [{ int: '4' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '5' }] }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CAR' }, + { prim: 'PAIR' }, + { prim: 'DIG', args: [{ int: '4' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '5' }] }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CAR' }, + { prim: 'PAIR' }, + { prim: 'DIG', args: [{ int: '4' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '5' }] }, + { prim: 'CDR' }, + { prim: 'CDR' }, + { prim: 'CAR' }, + { prim: 'PAIR' }, + { prim: 'DIG', args: [{ int: '4' }] }, + { prim: 'CDR' }, + { prim: 'CAR' }, + { prim: 'PAIR' }, + { prim: 'TRANSFER_TOKENS' }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'PAIR' }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'PAIR' }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'PAIR' }, + { prim: 'NIL', args: [{ prim: 'operation' }] }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'CONS' }, + { prim: 'PAIR' } + ] + ] + } + ], + [ + { prim: 'DIG', args: [{ int: '4' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '5' }] }, + { prim: 'SENDER' }, + { prim: 'COMPARE' }, + { prim: 'EQ' }, + { + prim: 'IF', + args: [ + [], + [ + { + prim: 'PUSH', + args: [ + { prim: 'string' }, + { string: 'failed assertion' } + ] + }, + { prim: 'FAILWITH' } + ] + ] + }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'PUSH', args: [{ prim: 'nat' }, { int: '1' }] }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'ADD' }, + { prim: 'PAIR' }, + { prim: 'DIG', args: [{ int: '2' }] }, + { + prim: 'NONE', + args: [{ prim: 'ticket', args: [{ prim: 'nat' }] }] + }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'UPDATE' }, + { prim: 'PAIR' }, + { prim: 'SWAP' }, + { prim: 'PAIR' }, + { prim: 'NIL', args: [{ prim: 'operation' }] }, + { prim: 'PAIR' } + ] + ] + } + ], + [ + { + prim: 'IF_LEFT', + args: [ + [ + { prim: 'DIG', args: [{ int: '4' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '5' }] }, + { prim: 'SENDER' }, + { prim: 'COMPARE' }, + { prim: 'EQ' }, + { + prim: 'IF', + args: [ + [], + [ + { + prim: 'PUSH', + args: [ + { prim: 'string' }, + { string: 'failed assertion' } + ] + }, + { prim: 'FAILWITH' } + ] + ] + }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'PUSH', args: [{ prim: 'nat' }, { int: '1' }] }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '4' }] }, + { prim: 'TICKET' }, + { prim: 'SOME' }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '4' }] }, + { prim: 'GET_AND_UPDATE' }, + { prim: 'DROP' }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '4' }] }, + { prim: 'PAIR' }, + { prim: 'SOME' }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '4' }] }, + { prim: 'UPDATE' }, + { prim: 'PUSH', args: [{ prim: 'nat' }, { int: '1' }] }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'ADD' }, + { prim: 'PAIR' }, + { prim: 'SWAP' }, + { prim: 'PAIR' }, + { prim: 'SWAP' }, + { prim: 'PAIR' }, + { prim: 'NIL', args: [{ prim: 'operation' }] }, + { prim: 'PAIR' } + ], + [ + { prim: 'READ_TICKET' }, + { prim: 'UNPAIR' }, + { prim: 'DROP' }, + { prim: 'UNPAIR' }, + { prim: 'DROP' }, + { prim: 'DIG', args: [{ int: '4' }] }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'SOME' }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '4' }] }, + { prim: 'GET_AND_UPDATE' }, + { prim: 'DROP' }, + { prim: 'PUSH', args: [{ prim: 'nat' }, { int: '1' }] }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'COMPARE' }, + { prim: 'EQ' }, + { + prim: 'IF', + args: [ + [], + [ + { + prim: 'PUSH', + args: [ + { prim: 'string' }, + { string: 'failed assertion' } + ] + }, + { prim: 'FAILWITH' } + ] + ] + }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'PUSH', args: [{ prim: 'nat' }, { int: '1' }] }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'ADD' }, + { prim: 'PAIR' }, + { prim: 'SWAP' }, + { prim: 'PAIR' }, + { prim: 'SWAP' }, + { prim: 'PAIR' }, + { prim: 'NIL', args: [{ prim: 'operation' }] }, + { prim: 'PAIR' } + ] + ] + } + ] + ] + } + ], + [ + { prim: 'DIG', args: [{ int: '4' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '5' }] }, + { prim: 'SENDER' }, + { prim: 'COMPARE' }, + { prim: 'EQ' }, + { + prim: 'IF', + args: [ + [], + [ + { prim: 'PUSH', args: [{ prim: 'string' }, { string: 'failed assertion' }] }, + { prim: 'FAILWITH' } + ] + ] + }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'NONE', args: [{ prim: 'ticket', args: [{ prim: 'nat' }] }] }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'DUP' }, + { prim: 'DUG', args: [{ int: '3' }] }, + { prim: 'CDR' }, + { prim: 'GET_AND_UPDATE' }, + { + prim: 'IF_NONE', + args: [ + [ + { prim: 'DROP', args: [{ int: '5' }] }, + { prim: 'PUSH', args: [{ prim: 'string' }, { string: 'no tickets' }] }, + { prim: 'FAILWITH' } + ], + [ + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'CAR' }, + { prim: 'PUSH', args: [{ prim: 'mutez' }, { int: '0' }] }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'TRANSFER_TOKENS' }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'DIG', args: [{ int: '3' }] }, + { prim: 'PAIR' }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'PAIR' }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'PAIR' }, + { prim: 'NIL', args: [{ prim: 'operation' }] }, + { prim: 'DIG', args: [{ int: '2' }] }, + { prim: 'CONS' }, + { prim: 'PAIR' } + ] + ] + } + ] + ] + } + ] + ] + } +]; diff --git a/integration-tests/local-forging.spec.ts b/integration-tests/local-forging.spec.ts index dda547e098..bdcfa22822 100644 --- a/integration-tests/local-forging.spec.ts +++ b/integration-tests/local-forging.spec.ts @@ -1,11 +1,11 @@ import { CONFIGS } from "./config"; -import { commonCases, kathmanduCases } from './data/allTestsCases'; +import { commonCases, limaCases } from './data/allTestsCases'; import { LocalForger, ProtocolsHash } from '@taquito/local-forging' import { Protocols, TezosToolkit } from "@taquito/taquito"; CONFIGS().forEach(({ rpc, protocol }) => { const Tezos = new TezosToolkit(rpc); - const kathmandunetAndAlpha = protocol === Protocols.ProtoALpha || protocol === Protocols.PtKathman ? test: test.skip; + const limanetAndAlpha = protocol === Protocols.PtLimaPtL || protocol === Protocols.ProtoALpha ? test: test.skip; describe(`Test local forger: ${rpc}`, () => { @@ -24,18 +24,15 @@ CONFIGS().forEach(({ rpc, protocol }) => { }); }); - kathmanduCases.forEach(({ name, operation, expected }) => { - - kathmandunetAndAlpha(`Should give the same result as when forging with the rpc: ${name} (${rpc})`, async done => { + limaCases.forEach(({ name, operation, expected }) => { + limanetAndAlpha(`Should give the same result as when forging with the rpc: ${name} (${rpc})`, async done => { const localForger = new LocalForger(protocol as unknown as ProtocolsHash); - const result = await localForger.forge(operation); const rpcResult = await Tezos.rpc.forgeOperations(operation); expect(result).toEqual(rpcResult); expect(await localForger.parse(result)).toEqual(expected || operation); - done(); }); }); }); -}) \ No newline at end of file +}) diff --git a/integration-tests/wallet-deploy-having-ticket.spec.ts b/integration-tests/wallet-deploy-having-ticket.spec.ts new file mode 100644 index 0000000000..356c376f4a --- /dev/null +++ b/integration-tests/wallet-deploy-having-ticket.spec.ts @@ -0,0 +1,102 @@ +import { CONFIGS } from "./config"; +import { ticketCode, ticketStorage } from './data/code_with_ticket'; +import { ticketCodeProto14, ticketStorageProto14 } from './data/code_with_ticket_proto14'; +import { Protocols } from "@taquito/taquito"; + +CONFIGS().forEach(({ lib, rpc, setup, protocol }) => { + const Tezos = lib; + const kathmandunet = protocol === Protocols.PtKathman ? test: test.skip; + const limanetAndAlpha = protocol === Protocols.PtLimaPtL || protocol === Protocols.ProtoALpha ? test: test.skip; + + describe(`Test contract origination having ticket with init through wallet api using: ${rpc}`, () => { + + beforeEach(async (done) => { + await setup(); + done(); + }); + + kathmandunet('Verify wallet.originate for a contract having ticket with init', async (done) => { + const op = await Tezos.wallet.originate({ + code: ticketCodeProto14, + init: ticketStorageProto14 + }).send(); + + await op.confirmation(); + expect(op.opHash).toBeDefined(); + + done(); + }); + + kathmandunet('Verify wallet.originate having ticket with init in JSON', async (done) => { + const op = await Tezos.wallet.originate({ + code: ticketCodeProto14, + init: { prim: 'Pair', args: [ { prim: 'None' }, { prim: 'None' } ] } + }).send(); + + await op.confirmation(); + expect(op.opHash).toBeDefined(); + done(); + }); + + kathmandunet('Verify wallet.originate for a contract having ticket with storage', async (done) => { + const op = await Tezos.wallet.originate({ + code: ticketCodeProto14, + storage: { + '%x': null, + '%y': null + } + }).send(); + + await op.confirmation(); + expect(op.opHash).toBeDefined(); + + done(); + }); + }); + + describe(`Test contract origination having ticket with init through wallet api using: ${rpc}`, () => { + + beforeEach(async (done) => { + await setup(); + done(); + }); + + limanetAndAlpha('Verify wallet.originate for a contract having ticket with init', async (done) => { + const op = await Tezos.wallet.originate({ + code: ticketCode, + init: ticketStorage + }).send(); + + await op.confirmation(); + expect(op.opHash).toBeDefined(); + + done(); + }); + + limanetAndAlpha('Verify wallet.originate having ticket with init in JSON', async (done) => { + const op = await Tezos.wallet.originate({ + code: ticketCode, + init: { prim: 'Pair', args: [ { prim: 'None' }, { prim: 'None' } ] } + }).send(); + + await op.confirmation(); + expect(op.opHash).toBeDefined(); + done(); + }); + + limanetAndAlpha('Verify wallet.originate for a contract having ticket with storage', async (done) => { + const op = await Tezos.wallet.originate({ + code: ticketCode, + storage: { + '%x': null, + '%y': null + } + }).send(); + + await op.confirmation(); + expect(op.opHash).toBeDefined(); + + done(); + }); + }); +}) diff --git a/integration-tests/wallet-edo-deploy-having-ticket.spec.ts b/integration-tests/wallet-edo-deploy-having-ticket.spec.ts deleted file mode 100644 index e1dc7209b0..0000000000 --- a/integration-tests/wallet-edo-deploy-having-ticket.spec.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { CONFIGS } from "./config"; -import { ticketCode, ticketStorage } from './data/code_with_ticket'; - -CONFIGS().forEach(({ lib, rpc, setup }) => { - const Tezos = lib; - - describe(`Test contract origination having ticket with init through wallet api using: ${rpc}`, () => { - - beforeEach(async (done) => { - await setup(); - done() - }) - - it('Verify wallet.originate for a contract having ticket with init', async (done) => { - const op = await Tezos.wallet.originate({ - code: ticketCode, - init: ticketStorage - }).send(); - - await op.confirmation(); - expect(op.opHash).toBeDefined(); - - done(); - }); - - it('Verify wallet.originate having ticket with init in JSON', async (done) => { - const op = await Tezos.wallet.originate({ - code: ticketCode, - init: { prim: 'Pair', args: [ { prim: 'None' }, { prim: 'None' } ] } - }).send(); - - await op.confirmation(); - expect(op.opHash).toBeDefined(); - done(); - }); - - it('Verify wallet.originate for a contract having ticket with storage', async (done) => { - const op = await Tezos.wallet.originate({ - code: ticketCode, - storage: { - '%x': null, - '%y': null - } - }).send(); - - await op.confirmation(); - expect(op.opHash).toBeDefined(); - - done(); - }); - }); -}) diff --git a/packages/taquito-local-forging/src/constants.ts b/packages/taquito-local-forging/src/constants.ts index ac18252490..1d2965e41d 100644 --- a/packages/taquito-local-forging/src/constants.ts +++ b/packages/taquito-local-forging/src/constants.ts @@ -49,6 +49,8 @@ export enum CODEC { TX_ROLLUP_ID = 'tx_rollup_id', TX_ROLLUP_BATCH_CONTENT = 'tx_rollup_batch_content', OP_INCREASE_PAID_STORAGE = 'increase_paid_storage', + OP_UPDATE_CONSENSUS_KEY = 'update_consensus_key', + OP_DRAIN_DELEGATE = 'drain_delegate', } // See https://tezos.gitlab.io/whitedoc/michelson.html#full-grammar @@ -189,7 +191,7 @@ export const opMapping: { [key: string]: string } = { '85': 'SAPLING_EMPTY_STATE', '86': 'SAPLING_VERIFY_UPDATE', '87': 'ticket', - '88': 'TICKET', + '88': 'TICKET_DEPRECATED', '89': 'READ_TICKET', '8a': 'SPLIT_TICKET', '8b': 'JOIN_TICKETS', @@ -205,6 +207,9 @@ export const opMapping: { [key: string]: string } = { '95': 'MIN_BLOCK_TIME', '96': 'sapling_transaction', '97': 'EMIT', + '98': 'Lambda_rec', + '99': 'LAMBDA_REC', + '9a': 'TICKET', }; export const opMappingReverse = (() => { @@ -215,7 +220,7 @@ export const opMappingReverse = (() => { return result; })(); -// See https://tezos.gitlab.io/api/p2p.html +// See https://tezos.gitlab.io/shell/p2p_api.html?highlight=p2p export const kindMapping: { [key: number]: string } = { 0x04: 'activate_account', 0x6b: 'reveal', @@ -231,6 +236,8 @@ export const kindMapping: { [key: number]: string } = { 0x97: 'tx_rollup_submit_batch', 0x9e: 'transfer_ticket', 0x71: 'increase_paid_storage', + 0x72: 'update_consensus_key', + 0x09: 'drain_delegate', }; export const kindMappingReverse = (() => { diff --git a/packages/taquito-local-forging/src/decoder.ts b/packages/taquito-local-forging/src/decoder.ts index 291eb9ec69..72fea186fe 100644 --- a/packages/taquito-local-forging/src/decoder.ts +++ b/packages/taquito-local-forging/src/decoder.ts @@ -29,6 +29,8 @@ import { DelegationSchema, EndorsementSchema, IncreasePaidStorageSchema, + UpdateConsensusKeySchema, + DrainDelegateSchema, ManagerOperationSchema, operationDecoder, OriginationSchema, @@ -101,4 +103,8 @@ decoders[CODEC.OP_TX_ROLLUP_SUBMIT_BATCH] = (val: Uint8ArrayConsumer) => schemaDecoder(decoders)(TxRollupSubmitBatchSchema)(val); decoders[CODEC.OP_INCREASE_PAID_STORAGE] = (val: Uint8ArrayConsumer) => schemaDecoder(decoders)(IncreasePaidStorageSchema)(val); +decoders[CODEC.OP_UPDATE_CONSENSUS_KEY] = (val: Uint8ArrayConsumer) => + schemaDecoder(decoders)(UpdateConsensusKeySchema)(val); +decoders[CODEC.OP_DRAIN_DELEGATE] = (val: Uint8ArrayConsumer) => + schemaDecoder(decoders)(DrainDelegateSchema)(val); decoders[CODEC.MANAGER] = schemaDecoder(decoders)(ManagerOperationSchema); diff --git a/packages/taquito-local-forging/src/encoder.ts b/packages/taquito-local-forging/src/encoder.ts index 146f1d77f3..8edc649177 100644 --- a/packages/taquito-local-forging/src/encoder.ts +++ b/packages/taquito-local-forging/src/encoder.ts @@ -29,6 +29,8 @@ import { DelegationSchema, EndorsementSchema, IncreasePaidStorageSchema, + UpdateConsensusKeySchema, + DrainDelegateSchema, ManagerOperationSchema, operationEncoder, OriginationSchema, @@ -93,4 +95,7 @@ encoders[CODEC.OP_TX_ROLLUP_SUBMIT_BATCH] = (val: any) => schemaEncoder(encoders)(TxRollupSubmitBatchSchema)(val); encoders[CODEC.OP_INCREASE_PAID_STORAGE] = (val: any) => schemaEncoder(encoders)(IncreasePaidStorageSchema)(val); +encoders[CODEC.OP_UPDATE_CONSENSUS_KEY] = (val: any) => + schemaEncoder(encoders)(UpdateConsensusKeySchema)(val); +encoders[CODEC.OP_DRAIN_DELEGATE] = (val: any) => schemaEncoder(encoders)(DrainDelegateSchema)(val); encoders[CODEC.MANAGER] = schemaEncoder(encoders)(ManagerOperationSchema); diff --git a/packages/taquito-local-forging/src/proto14-kathmandu/codec-proto14.ts b/packages/taquito-local-forging/src/proto14-kathmandu/codec-proto14.ts new file mode 100644 index 0000000000..f439c2ad03 --- /dev/null +++ b/packages/taquito-local-forging/src/proto14-kathmandu/codec-proto14.ts @@ -0,0 +1,60 @@ +import { OversizedEntryPointError } from '../error'; +import { entrypointMappingReverse, ENTRYPOINT_MAX_LENGTH } from '../constants'; +import { valueDecoderProto14, valueEncoderProto14 } from './michelson/codec-proto14'; +import { extractRequiredLen, MichelsonValue } from '../michelson/codec'; +import { entrypointDecoder } from '../codec'; +import { Uint8ArrayConsumer } from '../uint8array-consumer'; +import { pad } from '../utils'; + +export const parametersDecoderProto14 = (val: Uint8ArrayConsumer) => { + const preamble = val.consume(1); + if (preamble[0] === 0x00) { + return; + } else { + const encodedEntrypoint = entrypointDecoder(val); + const params = extractRequiredLen(val); + const parameters = valueDecoderProto14(new Uint8ArrayConsumer(params)); + return { + entrypoint: encodedEntrypoint, + value: parameters, + }; + } +}; +export const entrypointEncoderProto14 = (entrypoint: string) => { + if (entrypoint in entrypointMappingReverse) { + return `${entrypointMappingReverse[entrypoint]}`; + } else { + if (entrypoint.length > ENTRYPOINT_MAX_LENGTH) { + throw new OversizedEntryPointError(entrypoint); + } + + const value = { string: entrypoint }; + return `ff${valueEncoderProto14(value).slice(8)}`; + } +}; + +export const parametersEncoderProto14 = (val: { entrypoint: string; value: MichelsonValue }) => { + if (!val || (val.entrypoint === 'default' && 'prim' in val.value && val.value.prim === 'Unit')) { + return '00'; + } + + const encodedEntrypoint = entrypointEncoderProto14(val.entrypoint); + const parameters = valueEncoderProto14(val.value); + const length = (parameters.length / 2).toString(16).padStart(8, '0'); + return `ff${encodedEntrypoint}${length}${parameters}`; +}; + +export const valueParameterEncoderProto14 = (value: MichelsonValue) => { + const valueEncoded = valueEncoderProto14(value); + return `${pad(valueEncoded.length / 2)}${valueEncoded}`; +}; + +export const valueParameterDecoderProto14 = (val: Uint8ArrayConsumer) => { + const value = extractRequiredLen(val); + return valueDecoderProto14(new Uint8ArrayConsumer(value)); +}; + +export const entrypointNameEncoderProto14 = (entrypoint: string) => { + const value = { string: entrypoint }; + return `${valueEncoderProto14(value).slice(2)}`; +}; diff --git a/packages/taquito-local-forging/src/proto14-kathmandu/constants-proto14.ts b/packages/taquito-local-forging/src/proto14-kathmandu/constants-proto14.ts new file mode 100644 index 0000000000..5a9dc6d5e6 --- /dev/null +++ b/packages/taquito-local-forging/src/proto14-kathmandu/constants-proto14.ts @@ -0,0 +1,168 @@ +/* + * Some code in this file is originally from sotez + * Copyright (c) 2018 Andrew Kishino + */ + +// See https://tezos.gitlab.io/whitedoc/michelson.html#full-grammar +export const opMappingProto14: { [key: string]: string } = { + '00': 'parameter', + '01': 'storage', + '02': 'code', + '03': 'False', + '04': 'Elt', + '05': 'Left', + '06': 'None', + '07': 'Pair', + '08': 'Right', + '09': 'Some', + '0a': 'True', + '0b': 'Unit', + '0c': 'PACK', + '0d': 'UNPACK', + '0e': 'BLAKE2B', + '0f': 'SHA256', + '10': 'SHA512', + '11': 'ABS', + '12': 'ADD', + '13': 'AMOUNT', + '14': 'AND', + '15': 'BALANCE', + '16': 'CAR', + '17': 'CDR', + '18': 'CHECK_SIGNATURE', + '19': 'COMPARE', + '1a': 'CONCAT', + '1b': 'CONS', + '1c': 'CREATE_ACCOUNT', // Removed in Edo + '1d': 'CREATE_CONTRACT', // Removed in Edo + '1e': 'IMPLICIT_ACCOUNT', + '1f': 'DIP', + '20': 'DROP', + '21': 'DUP', + '22': 'EDIV', + '23': 'EMPTY_MAP', + '24': 'EMPTY_SET', + '25': 'EQ', + '26': 'EXEC', + '27': 'FAILWITH', + '28': 'GE', + '29': 'GET', + '2a': 'GT', + '2b': 'HASH_KEY', + '2c': 'IF', + '2d': 'IF_CONS', + '2e': 'IF_LEFT', + '2f': 'IF_NONE', + '30': 'INT', + '31': 'LAMBDA', + '32': 'LE', + '33': 'LEFT', + '34': 'LOOP', + '35': 'LSL', + '36': 'LSR', + '37': 'LT', + '38': 'MAP', + '39': 'MEM', + '3a': 'MUL', + '3b': 'NEG', + '3c': 'NEQ', + '3d': 'NIL', + '3e': 'NONE', + '3f': 'NOT', + '40': 'NOW', + '41': 'OR', + '42': 'PAIR', + '43': 'PUSH', + '44': 'RIGHT', + '45': 'SIZE', + '46': 'SOME', + '47': 'SOURCE', + '48': 'SENDER', + '49': 'SELF', + '4a': 'STEPS_TO_QUOTA', // Removed in Edo + '4b': 'SUB', + '4c': 'SWAP', + '4d': 'TRANSFER_TOKENS', + '4e': 'SET_DELEGATE', + '4f': 'UNIT', + '50': 'UPDATE', + '51': 'XOR', + '52': 'ITER', + '53': 'LOOP_LEFT', + '54': 'ADDRESS', + '55': 'CONTRACT', + '56': 'ISNAT', + '57': 'CAST', + '58': 'RENAME', + '59': 'bool', + '5a': 'contract', + '5b': 'int', + '5c': 'key', + '5d': 'key_hash', + '5e': 'lambda', + '5f': 'list', + '60': 'map', + '61': 'big_map', + '62': 'nat', + '63': 'option', + '64': 'or', + '65': 'pair', + '66': 'set', + '67': 'signature', + '68': 'string', + '69': 'bytes', + '6a': 'mutez', + '6b': 'timestamp', + '6c': 'unit', + '6d': 'operation', + '6e': 'address', + '6f': 'SLICE', + '70': 'DIG', + '71': 'DUG', + '72': 'EMPTY_BIG_MAP', + '73': 'APPLY', + '74': 'chain_id', + '75': 'CHAIN_ID', + '76': 'LEVEL', + '77': 'SELF_ADDRESS', + '78': 'never', + '79': 'NEVER', + '7a': 'UNPAIR', + '7b': 'VOTING_POWER', + '7c': 'TOTAL_VOTING_POWER', + '7d': 'KECCAK', + '7e': 'SHA3', + '7f': 'PAIRING_CHECK', + '80': 'bls12_381_g1', + '81': 'bls12_381_g2', + '82': 'bls12_381_fr', + '83': 'sapling_state', + '84': 'sapling_transaction_deprecated', + '85': 'SAPLING_EMPTY_STATE', + '86': 'SAPLING_VERIFY_UPDATE', + '87': 'ticket', + '88': 'TICKET', + '89': 'READ_TICKET', + '8a': 'SPLIT_TICKET', + '8b': 'JOIN_TICKETS', + '8c': 'GET_AND_UPDATE', + '8d': 'chest', + '8e': 'chest_key', + '8f': 'OPEN_CHEST', + '90': 'VIEW', + '91': 'view', + '92': 'constant', + '93': 'SUB_MUTEZ', + '94': 'tx_rollup_l2_address', + '95': 'MIN_BLOCK_TIME', + '96': 'sapling_transaction', + '97': 'EMIT', +}; + +export const opMappingReverseProto14 = (() => { + const result: { [key: string]: string } = {}; + Object.keys(opMappingProto14).forEach((key: string) => { + result[opMappingProto14[key]] = key; + }); + return result; +})(); diff --git a/packages/taquito-local-forging/src/proto14-kathmandu/decoder-proto14.ts b/packages/taquito-local-forging/src/proto14-kathmandu/decoder-proto14.ts new file mode 100644 index 0000000000..1daf16a915 --- /dev/null +++ b/packages/taquito-local-forging/src/proto14-kathmandu/decoder-proto14.ts @@ -0,0 +1,105 @@ +import { + addressDecoder, + ballotDecoder, + blockPayloadHashDecoder, + branchDecoder, + burnLimitDecoder, + delegateDecoder, + entrypointNameDecoder, + int16Decoder, + int32Decoder, + pkhDecoder, + proposalDecoder, + proposalsDecoder, + publicKeyDecoder, + smartContractAddressDecoder, + txRollupBatchContentDecoder, + txRollupIdDecoder, + txRollupOriginationParamDecoder, + tz1Decoder, + zarithDecoder, +} from '../codec'; +import { CODEC } from '../constants'; +import { scriptDecoderProto14 } from './michelson/codec-proto14'; +import { parametersDecoderProto14, valueParameterDecoderProto14 } from './codec-proto14'; +import { + ActivationSchema, + BallotSchema, + DelegationSchema, + EndorsementSchema, + IncreasePaidStorageSchema, + ManagerOperationSchema, + operationDecoder, + OriginationSchema, + ProposalsSchema, + RegisterGlobalConstantSchema, + RevealSchema, + schemaDecoder, + SeedNonceRevelationSchema, + TransactionSchema, + TransferTicketSchema, + TxRollupOriginationSchema, + TxRollupSubmitBatchSchema, +} from '../schema/operation'; +import { Uint8ArrayConsumer } from '../uint8array-consumer'; +import { toHexString } from '../utils'; + +export type Decoder = (val: Uint8ArrayConsumer) => string | number | object | undefined; + +export const decodersProto14: { [key: string]: Decoder } = { + [CODEC.SECRET]: (val) => toHexString(val.consume(20)), + [CODEC.RAW]: (val) => toHexString(val.consume(32)), + [CODEC.TZ1]: tz1Decoder, + [CODEC.BRANCH]: branchDecoder, + [CODEC.ZARITH]: zarithDecoder, + [CODEC.PUBLIC_KEY]: publicKeyDecoder, + [CODEC.PKH]: pkhDecoder, + [CODEC.DELEGATE]: delegateDecoder, + [CODEC.INT32]: int32Decoder, + [CODEC.SCRIPT]: scriptDecoderProto14, + [CODEC.BALLOT_STATEMENT]: ballotDecoder, + [CODEC.PROPOSAL]: proposalDecoder, + [CODEC.PROPOSAL_ARR]: proposalsDecoder, + [CODEC.PARAMETERS]: parametersDecoderProto14, + [CODEC.ADDRESS]: addressDecoder, + [CODEC.SMART_CONTRACT_ADDRESS]: smartContractAddressDecoder, + [CODEC.VALUE]: valueParameterDecoderProto14, + [CODEC.INT16]: int16Decoder, + [CODEC.BLOCK_PAYLOAD_HASH]: blockPayloadHashDecoder, + [CODEC.ENTRYPOINT]: entrypointNameDecoder, + [CODEC.TX_ROLLUP_ORIGINATION_PARAM]: txRollupOriginationParamDecoder, + [CODEC.TX_ROLLUP_ID]: txRollupIdDecoder, + [CODEC.TX_ROLLUP_BATCH_CONTENT]: txRollupBatchContentDecoder, + [CODEC.BURN_LIMIT]: burnLimitDecoder, +}; + +decodersProto14[CODEC.OPERATION] = operationDecoder(decodersProto14); +decodersProto14[CODEC.OP_ACTIVATE_ACCOUNT] = (val: Uint8ArrayConsumer) => + schemaDecoder(decodersProto14)(ActivationSchema)(val); +decodersProto14[CODEC.OP_DELEGATION] = (val: Uint8ArrayConsumer) => + schemaDecoder(decodersProto14)(DelegationSchema)(val); +decodersProto14[CODEC.OP_TRANSACTION] = (val: Uint8ArrayConsumer) => + schemaDecoder(decodersProto14)(TransactionSchema)(val); +decodersProto14[CODEC.OP_ORIGINATION] = (val: Uint8ArrayConsumer) => + schemaDecoder(decodersProto14)(OriginationSchema)(val); +decodersProto14[CODEC.OP_BALLOT] = (val: Uint8ArrayConsumer) => + schemaDecoder(decodersProto14)(BallotSchema)(val); +decodersProto14[CODEC.OP_ENDORSEMENT] = (val: Uint8ArrayConsumer) => + schemaDecoder(decodersProto14)(EndorsementSchema)(val); +decodersProto14[CODEC.OP_SEED_NONCE_REVELATION] = (val: Uint8ArrayConsumer) => + schemaDecoder(decodersProto14)(SeedNonceRevelationSchema)(val); +decodersProto14[CODEC.OP_PROPOSALS] = (val: Uint8ArrayConsumer) => + schemaDecoder(decodersProto14)(ProposalsSchema)(val); +decodersProto14[CODEC.OP_REVEAL] = (val: Uint8ArrayConsumer) => + schemaDecoder(decodersProto14)(RevealSchema)(val); +decodersProto14[CODEC.OP_REGISTER_GLOBAL_CONSTANT] = (val: Uint8ArrayConsumer) => + schemaDecoder(decodersProto14)(RegisterGlobalConstantSchema)(val); +decodersProto14[CODEC.OP_TRANSFER_TICKET] = (val: Uint8ArrayConsumer) => + schemaDecoder(decodersProto14)(TransferTicketSchema)(val); +decodersProto14[CODEC.OP_TX_ROLLUP_ORIGINATION] = (val: Uint8ArrayConsumer) => + schemaDecoder(decodersProto14)(TxRollupOriginationSchema)(val); +decodersProto14[CODEC.OP_TX_ROLLUP_SUBMIT_BATCH] = (val: Uint8ArrayConsumer) => + schemaDecoder(decodersProto14)(TxRollupSubmitBatchSchema)(val); +decodersProto14[CODEC.OP_INCREASE_PAID_STORAGE] = (val: Uint8ArrayConsumer) => + schemaDecoder(decodersProto14)(IncreasePaidStorageSchema)(val); +decodersProto14[CODEC.MANAGER] = schemaDecoder(decodersProto14)(ManagerOperationSchema); diff --git a/packages/taquito-local-forging/src/proto14-kathmandu/encoder-proto14.ts b/packages/taquito-local-forging/src/proto14-kathmandu/encoder-proto14.ts new file mode 100644 index 0000000000..289666acfe --- /dev/null +++ b/packages/taquito-local-forging/src/proto14-kathmandu/encoder-proto14.ts @@ -0,0 +1,104 @@ +import { + addressEncoder, + ballotEncoder, + blockPayloadHashEncoder, + branchEncoder, + burnLimitEncoder, + delegateEncoder, + int16Encoder, + int32Encoder, + pkhEncoder, + proposalEncoder, + proposalsEncoder, + publicKeyEncoder, + smartContractAddressEncoder, + txRollupBatchContentEncoder, + txRollupIdEncoder, + txRollupOriginationParamEncoder, + tz1Encoder, + zarithEncoder, +} from '../codec'; +import { CODEC } from '../constants'; +import { + entrypointNameEncoderProto14, + parametersEncoderProto14, + valueParameterEncoderProto14, +} from './codec-proto14'; +import { scriptEncoderProto14 } from './michelson/codec-proto14'; +import { + ActivationSchema, + BallotSchema, + DelegationSchema, + EndorsementSchema, + IncreasePaidStorageSchema, + ManagerOperationSchema, + operationEncoder, + OriginationSchema, + ProposalsSchema, + RegisterGlobalConstantSchema, + RevealSchema, + schemaEncoder, + SeedNonceRevelationSchema, + TransactionSchema, + TransferTicketSchema, + TxRollupOriginationSchema, + TxRollupSubmitBatchSchema, +} from '../schema/operation'; + +export type Encoder = (val: T) => string; + +export const encodersProto14: { [key: string]: Encoder } = { + [CODEC.SECRET]: (val: string) => val, + [CODEC.RAW]: (val: string) => val, + [CODEC.TZ1]: tz1Encoder, + [CODEC.BRANCH]: branchEncoder, + [CODEC.ZARITH]: zarithEncoder, + [CODEC.PUBLIC_KEY]: publicKeyEncoder, + [CODEC.PKH]: pkhEncoder, + [CODEC.DELEGATE]: delegateEncoder, + [CODEC.SCRIPT]: scriptEncoderProto14, + [CODEC.BALLOT_STATEMENT]: ballotEncoder, + [CODEC.PROPOSAL]: proposalEncoder, + [CODEC.PROPOSAL_ARR]: proposalsEncoder, + [CODEC.INT32]: int32Encoder, + [CODEC.PARAMETERS]: parametersEncoderProto14, + [CODEC.ADDRESS]: addressEncoder, + [CODEC.SMART_CONTRACT_ADDRESS]: smartContractAddressEncoder, + [CODEC.VALUE]: valueParameterEncoderProto14, + [CODEC.INT16]: int16Encoder, + [CODEC.BLOCK_PAYLOAD_HASH]: blockPayloadHashEncoder, + [CODEC.ENTRYPOINT]: entrypointNameEncoderProto14, + [CODEC.TX_ROLLUP_ORIGINATION_PARAM]: txRollupOriginationParamEncoder, + [CODEC.TX_ROLLUP_ID]: txRollupIdEncoder, + [CODEC.TX_ROLLUP_BATCH_CONTENT]: txRollupBatchContentEncoder, + [CODEC.BURN_LIMIT]: burnLimitEncoder, +}; + +encodersProto14[CODEC.OPERATION] = operationEncoder(encodersProto14); +encodersProto14[CODEC.OP_ACTIVATE_ACCOUNT] = (val: any) => + schemaEncoder(encodersProto14)(ActivationSchema)(val); +encodersProto14[CODEC.OP_DELEGATION] = (val: any) => + schemaEncoder(encodersProto14)(DelegationSchema)(val); +encodersProto14[CODEC.OP_TRANSACTION] = (val: any) => + schemaEncoder(encodersProto14)(TransactionSchema)(val); +encodersProto14[CODEC.OP_ORIGINATION] = (val: any) => + schemaEncoder(encodersProto14)(OriginationSchema)(val); +encodersProto14[CODEC.OP_BALLOT] = (val: any) => schemaEncoder(encodersProto14)(BallotSchema)(val); +encodersProto14[CODEC.OP_ENDORSEMENT] = (val: any) => + schemaEncoder(encodersProto14)(EndorsementSchema)(val); +encodersProto14[CODEC.OP_SEED_NONCE_REVELATION] = (val: any) => + schemaEncoder(encodersProto14)(SeedNonceRevelationSchema)(val); +encodersProto14[CODEC.OP_PROPOSALS] = (val: any) => + schemaEncoder(encodersProto14)(ProposalsSchema)(val); +encodersProto14[CODEC.OP_REVEAL] = (val: any) => schemaEncoder(encodersProto14)(RevealSchema)(val); +encodersProto14[CODEC.OP_REGISTER_GLOBAL_CONSTANT] = (val: any) => + schemaEncoder(encodersProto14)(RegisterGlobalConstantSchema)(val); +encodersProto14[CODEC.OP_TRANSFER_TICKET] = (val: any) => + schemaEncoder(encodersProto14)(TransferTicketSchema)(val); +encodersProto14[CODEC.OP_TX_ROLLUP_ORIGINATION] = (val: any) => + schemaEncoder(encodersProto14)(TxRollupOriginationSchema)(val); +encodersProto14[CODEC.OP_TX_ROLLUP_SUBMIT_BATCH] = (val: any) => + schemaEncoder(encodersProto14)(TxRollupSubmitBatchSchema)(val); +encodersProto14[CODEC.OP_INCREASE_PAID_STORAGE] = (val: any) => + schemaEncoder(encodersProto14)(IncreasePaidStorageSchema)(val); +encodersProto14[CODEC.MANAGER] = schemaEncoder(encodersProto14)(ManagerOperationSchema); diff --git a/packages/taquito-local-forging/src/proto14-kathmandu/michelson/codec-proto14.ts b/packages/taquito-local-forging/src/proto14-kathmandu/michelson/codec-proto14.ts new file mode 100644 index 0000000000..40f80efbee --- /dev/null +++ b/packages/taquito-local-forging/src/proto14-kathmandu/michelson/codec-proto14.ts @@ -0,0 +1,176 @@ +import { Uint8ArrayConsumer } from '../../uint8array-consumer'; +import { Decoder, Encoder } from '../../taquito-local-forging'; +import { opMappingReverseProto14, opMappingProto14 } from '../constants-proto14'; +import { pad } from '../../utils'; +import { UnexpectedMichelsonValueError } from '../../error'; +import { + bytesDecoder, + bytesEncoder, + decodeAnnots, + encodeAnnots, + extractRequiredLen, + intDecoder, + intEncoder, + isBytes, + isInt, + isPrim, + isString, + MichelsonValue, + PrimValue, + stringDecoder, + stringEncoder, +} from '../../michelson/codec'; + +export const scriptEncoderProto14: Encoder<{ code: MichelsonValue; storage: MichelsonValue }> = ( + script +) => { + const code = valueEncoderProto14(script.code); + const storage = valueEncoderProto14(script.storage); + return `${pad(code.length / 2, 8)}${code}${pad(storage.length / 2, 8)}${storage}`; +}; + +export const scriptDecoderProto14: Decoder = (value: Uint8ArrayConsumer) => { + const code = extractRequiredLen(value); + const storage = extractRequiredLen(value); + + return { + code: valueDecoderProto14(new Uint8ArrayConsumer(code)), + storage: valueDecoderProto14(new Uint8ArrayConsumer(storage)), + }; +}; + +export const valueEncoderProto14: Encoder = (value: MichelsonValue) => { + if (Array.isArray(value)) { + const encoded = value.map((x) => valueEncoderProto14(x)).join(''); + const len = encoded.length / 2; + return `02${pad(len)}${encoded}`; + } else if (isPrim(value)) { + return primEncoderProto14(value); + } else if (isBytes(value)) { + return bytesEncoder(value); + } else if (isString(value)) { + return stringEncoder(value); + } else if (isInt(value)) { + return intEncoder(value); + } + + throw new UnexpectedMichelsonValueError(JSON.stringify(value)); +}; + +export const valueDecoderProto14: Decoder = (value: Uint8ArrayConsumer) => { + const preamble = value.consume(1); + switch (preamble[0]) { + case 0x0a: + return bytesDecoder(value); + case 0x01: + return stringDecoder(value); + case 0x00: + return intDecoder(value); + case 0x02: { + const val = new Uint8ArrayConsumer(extractRequiredLen(value)); + const results = []; + while (val.length() > 0) { + results.push(valueDecoderProto14(val)); + } + return results; + } + default: + return primDecoderProto14(value, preamble); + } +}; + +export const primEncoderProto14: Encoder = (value) => { + const hasAnnot = +Array.isArray(value.annots); + const argsCount = Array.isArray(value.args) ? value.args.length : 0; + + // Specify the number of args max is 3 without annotation + const preamble = pad(Math.min(2 * argsCount + hasAnnot + 0x03, 9), 2); + + const op = opMappingReverseProto14[value.prim]; + + let encodedArgs = (value.args || []).map((arg) => valueEncoderProto14(arg)).join(''); + const encodedAnnots = Array.isArray(value.annots) ? encodeAnnots(value.annots) : ''; + + if (value.prim === 'LAMBDA' && argsCount) { + encodedArgs = pad(encodedArgs.length / 2) + encodedArgs + pad(0); + } + + if ((value.prim === 'pair' || value.prim === 'Pair') && argsCount > 2) { + encodedArgs = + encodedAnnots === '' + ? pad(encodedArgs.length / 2) + encodedArgs + pad(0) + : pad(encodedArgs.length / 2) + encodedArgs; + } + + if (value.prim === 'view' && value.args) { + encodedArgs = pad(encodedArgs.length / 2) + encodedArgs + pad(0); + } + + return `${preamble}${op}${encodedArgs}${encodedAnnots}`; +}; + +export const primDecoderProto14 = (value: Uint8ArrayConsumer, preamble: Uint8Array) => { + const hasAnnot = (preamble[0] - 0x03) % 2 === 1; + let argsCount = Math.floor((preamble[0] - 0x03) / 2); + const op = value.consume(1)[0].toString(16).padStart(2, '0'); + + const result: Partial = { + prim: opMappingProto14[op], + }; + + if (opMappingProto14[op] === 'LAMBDA') { + value.consume(4); + } + + if (opMappingProto14[op] === 'view') { + if (argsCount != 0) { + return primViewDecoderProto14(value, result); + } else { + return result; + } + } + + let combPairArgs; + let combPairAnnots; + if ((opMappingProto14[op] === 'pair' || opMappingProto14[op] === 'Pair') && argsCount > 2) { + combPairArgs = decodeCombPair(value); + argsCount = 0; + combPairAnnots = decodeAnnots(value); + } + + const args = new Array(argsCount).fill(0).map(() => valueDecoderProto14(value)); + + if (opMappingProto14[op] === 'LAMBDA') { + value.consume(4); + } + + if (combPairArgs) { + result['args'] = combPairArgs as any; + } else if (args.length) { + result['args'] = args as any; + } + + if (combPairAnnots && (combPairAnnots as any)[0] !== '') { + result['annots'] = combPairAnnots as any; + } else if (hasAnnot) { + result['annots'] = decodeAnnots(value) as any; + } + + return result; +}; + +export const primViewDecoderProto14 = (value: Uint8ArrayConsumer, result: Partial) => { + value.consume(4); + result['args'] = new Array(4).fill(0).map(() => valueDecoderProto14(value)) as any; + value.consume(4); + return result; +}; + +export const decodeCombPair: Decoder = (val: Uint8ArrayConsumer) => { + const array = new Uint8ArrayConsumer(extractRequiredLen(val)); + const args = []; + while (array.length() > 0) { + args.push(valueDecoderProto14(array)); + } + return args; +}; diff --git a/packages/taquito-local-forging/src/protocols.ts b/packages/taquito-local-forging/src/protocols.ts index 6fd06c7d96..9db2df7b69 100644 --- a/packages/taquito-local-forging/src/protocols.ts +++ b/packages/taquito-local-forging/src/protocols.ts @@ -11,6 +11,7 @@ export enum ProtocolsHash { Psithaca2 = 'Psithaca2MLRFYargivpo7YvUr7wUDqyxrdhC5CQq78mRvimz6A', PtJakart2 = 'PtJakart2xVj7pYXJBXrqHgd82rdkLey5ZeeGwDgPp9rhQUbSqY', PtKathman = 'PtKathmankSpLLDALzWw7CGD2j2MtyveTwboEYokqUCP4a1LxMg', + PtLimaPtL = 'PtLimaPtLMwfNinJi9rCfDPWea8dFgTZ1MeJ9f1m2SRic6ayiwW', ProtoALpha = 'ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK', } @@ -27,7 +28,8 @@ const protoLevel: Record = { Psithaca2MLRFYargivpo7YvUr7wUDqyxrdhC5CQq78mRvimz6A: 12, PtJakart2xVj7pYXJBXrqHgd82rdkLey5ZeeGwDgPp9rhQUbSqY: 13, PtKathmankSpLLDALzWw7CGD2j2MtyveTwboEYokqUCP4a1LxMg: 14, - ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK: 15, + PtLimaPtLMwfNinJi9rCfDPWea8dFgTZ1MeJ9f1m2SRic6ayiwW: 15, + ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK: 16, }; export function ProtoInferiorTo(a: ProtocolsHash, b: ProtocolsHash): boolean { diff --git a/packages/taquito-local-forging/src/schema/operation.ts b/packages/taquito-local-forging/src/schema/operation.ts index f572406e84..46f4c91ff2 100644 --- a/packages/taquito-local-forging/src/schema/operation.ts +++ b/packages/taquito-local-forging/src/schema/operation.ts @@ -136,6 +136,21 @@ export const IncreasePaidStorageSchema = { destination: CODEC.SMART_CONTRACT_ADDRESS, }; +export const UpdateConsensusKeySchema = { + source: CODEC.PKH, + fee: CODEC.ZARITH, + counter: CODEC.ZARITH, + gas_limit: CODEC.ZARITH, + storage_limit: CODEC.ZARITH, + pk: CODEC.PUBLIC_KEY, +}; + +export const DrainDelegateSchema = { + consensus_key: CODEC.PKH, + delegate: CODEC.PKH, + destination: CODEC.PKH, +}; + export const operationEncoder = (encoders: { [key: string]: (val: object) => string }) => (operation: { kind: string }) => { if (!(operation.kind in encoders) || !(operation.kind in kindMappingReverse)) { diff --git a/packages/taquito-local-forging/src/taquito-local-forging.ts b/packages/taquito-local-forging/src/taquito-local-forging.ts index 60672a1786..03efa8ae6f 100644 --- a/packages/taquito-local-forging/src/taquito-local-forging.ts +++ b/packages/taquito-local-forging/src/taquito-local-forging.ts @@ -11,7 +11,9 @@ import { Uint8ArrayConsumer } from './uint8array-consumer'; import { validateBlock, ValidationResult, InvalidOperationKindError } from '@taquito/utils'; import { InvalidBlockHashError, InvalidOperationSchemaError } from './error'; import { validateMissingProperty, validateOperationKind } from './validator'; -import { ProtocolsHash } from './protocols'; +import { ProtocolsHash, ProtoInferiorTo } from './protocols'; +import { decodersProto14 } from './proto14-kathmandu/decoder-proto14'; +import { encodersProto14 } from './proto14-kathmandu/encoder-proto14'; export { CODEC, opMapping, opMappingReverse } from './constants'; export * from './decoder'; @@ -21,16 +23,27 @@ export * from './interface'; export { VERSION } from './version'; export { ProtocolsHash } from './protocols'; -const PROTOCOL_CURRENT = ProtocolsHash.Psithaca2; +const PROTOCOL_CURRENT = ProtocolsHash.PtKathman; export function getCodec(codec: CODEC, _proto: ProtocolsHash) { - return { - encoder: encoders[codec], - decoder: (hex: string) => { - const consumer = Uint8ArrayConsumer.fromHexString(hex); - return decoders[codec](consumer) as any; - }, - }; + // use proto14 encoders & decoders if it's kathmandu or prior + if (_proto === ProtocolsHash.PtKathman || ProtoInferiorTo(_proto, PROTOCOL_CURRENT)) { + return { + encoder: encodersProto14[codec], + decoder: (hex: string) => { + const consumer = Uint8ArrayConsumer.fromHexString(hex); + return decodersProto14[codec](consumer) as any; + }, + }; + } else { + return { + encoder: encoders[codec], + decoder: (hex: string) => { + const consumer = Uint8ArrayConsumer.fromHexString(hex); + return decoders[codec](consumer) as any; + }, + }; + } } export class LocalForger implements Forger { diff --git a/packages/taquito-local-forging/src/validator.ts b/packages/taquito-local-forging/src/validator.ts index f80afde7e7..65c4935794 100644 --- a/packages/taquito-local-forging/src/validator.ts +++ b/packages/taquito-local-forging/src/validator.ts @@ -15,6 +15,8 @@ import { TxRollupOriginationSchema, TxRollupSubmitBatchSchema, IncreasePaidStorageSchema, + UpdateConsensusKeySchema, + DrainDelegateSchema, } from './schema/operation'; type OperationKind = @@ -31,7 +33,9 @@ type OperationKind = | OpKind.TRANSFER_TICKET | OpKind.TX_ROLLUP_ORIGINATION | OpKind.TX_ROLLUP_SUBMIT_BATCH - | OpKind.INCREASE_PAID_STORAGE; + | OpKind.INCREASE_PAID_STORAGE + | OpKind.UPDATE_CONSENSUS_KEY + | OpKind.DRAIN_DELEGATE; const OperationKindMapping = { activate_account: ActivationSchema, @@ -48,6 +52,8 @@ const OperationKindMapping = { tx_rollup_origination: TxRollupOriginationSchema, tx_rollup_submit_batch: TxRollupSubmitBatchSchema, increase_paid_storage: IncreasePaidStorageSchema, + update_consensus_key: UpdateConsensusKeySchema, + drain_delegate: DrainDelegateSchema, }; // Asymmetric difference: only account for things in arr2 that are not present in arr1, not vice versa diff --git a/packages/taquito-local-forging/test/michelson/encoder.spec.ts b/packages/taquito-local-forging/test/michelson/encoder.spec.ts index a9e7e3cba3..7753bb7d10 100644 --- a/packages/taquito-local-forging/test/michelson/encoder.spec.ts +++ b/packages/taquito-local-forging/test/michelson/encoder.spec.ts @@ -1,4 +1,5 @@ import { valueEncoder } from '../../src/michelson/codec'; +import { valueEncoderProto14 } from '../../src/proto14-kathmandu/michelson/codec-proto14'; describe('valueEncoder', () => { test('Should produce value encoding for bytes', () => { @@ -13,3 +14,17 @@ describe('valueEncoder', () => { expect(valueEncoder(value)).toEqual('07070a0000000202020a000000020405'); }); }); + +describe('valueEncoderProto14', () => { + test('Should produce value encoding for bytes', () => { + expect(valueEncoderProto14({ bytes: '0202' })).toEqual('0a000000020202'); + }); + + test('Should produce valid encoding for prim', () => { + const value = { + prim: 'Pair', + args: [{ bytes: '0202' }, { bytes: '0405' }], + }; + expect(valueEncoderProto14(value)).toEqual('07070a0000000202020a000000020405'); + }); +}); diff --git a/packages/taquito-local-forging/test/taquito-local-forging.spec.ts b/packages/taquito-local-forging/test/taquito-local-forging.spec.ts index 646b91b740..55d8062626 100644 --- a/packages/taquito-local-forging/test/taquito-local-forging.spec.ts +++ b/packages/taquito-local-forging/test/taquito-local-forging.spec.ts @@ -6,8 +6,11 @@ import { ProtocolsHash, Uint8ArrayConsumer, } from '../src/taquito-local-forging'; -import { ticketCode3, ticketStorage3 } from '../../../integration-tests/data/code_with_ticket'; -import { commonCases, kathmanduCases } from '../../../integration-tests/data/allTestsCases'; +import { + ticketCode3Proto14, + ticketStorage3Proto14, +} from '../../../integration-tests/data/code_with_ticket_proto14'; +import { commonCases, limaCases } from '../../../integration-tests/data/allTestsCases'; import { InvalidOperationSchemaError, InvalidBlockHashError, @@ -28,10 +31,10 @@ describe('Forge and parse operations default protocol', () => { }); }); - describe('Forge and parse operations kathmandu protocol', () => { - const localForger = new LocalForger(); - kathmanduCases.forEach(({ name, operation, expected }) => { - test(`Common test: ${name}`, async (done) => { + describe('Forge and parse operations lima protocol', () => { + const localForger = new LocalForger(ProtocolsHash.PtLimaPtL); + limaCases.forEach(({ name, operation, expected }) => { + test(`Lima test: ${name}`, async (done) => { const result = await localForger.forge(operation); expect(await localForger.parse(result)).toEqual(expected || operation); done(); @@ -166,8 +169,8 @@ describe('Forge and parse operations default protocol', () => { storage_limit: '10', balance: '0', script: { - code: ticketCode3, - storage: ticketStorage3, + code: ticketCode3Proto14, + storage: ticketStorage3Proto14, }, }, ], diff --git a/packages/taquito-rpc/test/data/rpc-responses.ts b/packages/taquito-rpc/test/data/rpc-responses.ts index ac17b5314f..f6382a3eca 100644 --- a/packages/taquito-rpc/test/data/rpc-responses.ts +++ b/packages/taquito-rpc/test/data/rpc-responses.ts @@ -4875,7 +4875,11 @@ export const blockLimanetSample = { cycle_position: 2027, expected_commitment: false, }, - voting_period_info: { voting_period: { index: 5, kind: 'proposal', start_position: 102400 }, position: 2027, remaining: 2068 }, + voting_period_info: { + voting_period: { index: 5, kind: 'proposal', start_position: 102400 }, + position: 2027, + remaining: 2068, + }, nonce_hash: null, deactivated: [], balance_updates: [