Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Invalid or misplaced code on line xyz - Parse error? #20

Open
moodmosaic opened this issue Jan 31, 2023 · 0 comments
Open

Invalid or misplaced code on line xyz - Parse error? #20

moodmosaic opened this issue Jan 31, 2023 · 0 comments

Comments

@moodmosaic
Copy link

Getting weird output with the following contract:

docker run ghcr.io/njordhov/clariform --version
0.4.0

docker run ghcr.io/njordhov/clariform \
"https://raw.githubusercontent.com/kenrogers/cargo/cf56971900c62fc1058e942fc48186dee90c4063/contracts/cargo.clar"
Invalid or misplaced code on line 28: (
Invalid or misplaced code on line 29: (
Invalid or misplaced code on line 38: (
Invalid or misplaced code on line 38: "
;; cargo
;; a simple decentralized shipment tracker

;; constants
(define-constant err-shipment-not-found (err u100))
(define-constant err-tx-sender-unauthorized (err u101))

;; data maps and vars
(define-data-var last-shipment-id uint u0)
(define-map shipments uint {location: (string-ascii 25), status: (string-ascii 25), shipper: principal, receiver: principal})

;; private functions
;;

;; public functions
(define-public (create-new-shipment (starting-location (string-ascii 25)) (receiver principal))
    (let
        (   (new-shipment-id (+ (var-get last-shipment-id) u1)))
        ;; #[filter(starting-location, receiver)]
        (map-set shipments new-shipment-id {location: starting-location, status: "In Transit", shipper: tx-sender, receiver: receiver})
        (ok "Shipment created successfully")))

[:invalid "("]

define-public (update-shipment (shipment-id uint) (current-location (string-ascii 25)))
    [:invalid "("]

let
    (   (previous-shipment (unwrap! (map-get? shipments shipment-id) err-shipment-not-found))
        (shipper (get shipper previous-shipment))
        (new-shipment-info (merge previous-shipment {location: current-location})))
    (asserts! (is-eq tx-sender shipper) err-tx-sender-unauthorized)
        ;; #[filter(shipment-id)]
    (map-set shipments shipment-id new-shipment-info)
    [:invalid "("]

ok [:invalid "\""]

Sh

Invalid or misplaced code on line 1: "
Invalid or misplaced code on line 1: )
Invalid or misplaced code on line 2: )
Invalid or misplaced code on line 3: )
ipment updated successfully

[:invalid "\""]

[:invalid ")"]
[:invalid ")"]
[:invalid ")"]

;; read only functions
(define-read-only (get-shipment (shipment-id uint))
    (ok (unwrap! (map-get? shipments shipment-id) err-shipment-not-found)))
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant