ecadlabs / taquito

A library for building dApps on the Tezos Blockchain - JavaScript / TypeScript
https://taquito.io
Apache License 2.0
298 stars 116 forks source link

Can't Deploy a Contract with On-chain Views #1227

Open keefertaylor opened 2 years ago

keefertaylor commented 2 years ago

Description I have a contract that contains onchain views. When I try to deploy with taquito against Hangzhounet, I receive the following error:

MichelineParseError: not an identifier: ;
    at new MichelineParseError (/Users/keefertaylor/kolibri-contracts/migrations/contracts-1.3/node_modules/@hover-labs/tezos-utils/node_modules/@taquito/taquito/node_modules/@taquito/michel-codec/src/micheline-parser.ts:12:9)
    <snip>
  token: { t: ';', v: ';', first: 1710999, last: 1711000 }

Character 1711000 corresponds to bolded 'w' in the code below:

""" view "getStabilityFee" unit nat { GET 7; # pair (nat %privateOwnerLiquidationThreshold) (nat %stabilityFee) CDR; # nat }; view "getStorage" unit (pair (pair (pair (pair (nat %amountLoaned) (nat %collateralizationPercentage)) (pair (nat %devFundSplit) (address %developerFundContractAddress))) (pair (pair (address %governorContractAddress) (bool %initialized)) (pair (address %initializerContractAddress) (nat %interestIndex)))) (pair (pair (pair (timestamp %lastInterestIndexUpdateTime) (nat %liquidationFeePercent)) (pair (address %liquidityPoolContractAddress) (address %ovenProxyContractAddress))) (pair (pair (nat %privateOwnerLiquidationThreshold) (nat %stabilityFee)) (pair (address %stabilityFundContractAddress) (address %tokenContractAddress))))) CDR; """

The contract is compiled using the latest version of SmartPy.

Steps To Reproduce Steps to reproduce the behavior:

  1. Grab contract source and storage from [this gist]((https://gist.github.com/keefertaylor/fee38b73eedf79366872baea54b14630). Gist has two files, the contract code and an suitable initial storage
  2. Use Taquito@11.0.1 and tttempt to deploy the source and storage with:
const Tezos = ... // Some TezosToolkit instance pointed at your favorite Hangzhou node
const contractSource = ... // From first file in gist above
const storage = ... // From second file in gist above
await Tezos.contract.originate({
  code: contractSource,
  init: storage,
})

Expected behavior

Contract should deploy to Hangzhou net, or at least fail with a more succinct error about what data is ill-tped.

Desktop (please complete the following information):

Built in typescript on OSX. Relevant versions: node: v14.17.6 ts-node: v10.2.1 @taquito/taquito: v11.0.1

roxaneletourneau commented 2 years ago

Thanks @keefertaylor for the detailed issue.

At the very end of the contract, there are extra spaces and a ; symbol (see screenshot). Not sure why it is there and where it is coming from, but I am able to deploy the contract by removing it.
image

So, the error is correct regarding the unexpected ; symbol, but as a follow-up task, we will need to investigate why the position returned in the error message is not accurate.