diff --git a/go.mod b/go.mod index bfa84e964..99fe9d5d5 100644 --- a/go.mod +++ b/go.mod @@ -14,19 +14,19 @@ require ( github.com/gosuri/uilive v0.0.4 github.com/logrusorgru/aurora/v4 v4.0.0 github.com/manifoldco/promptui v0.9.0 - github.com/onflow/cadence v1.0.0-preview.34 - github.com/onflow/cadence-tools/languageserver v1.0.0-preview.32 - github.com/onflow/cadence-tools/lint v1.0.0-preview.32 - github.com/onflow/cadence-tools/test v1.0.0-preview.32 + github.com/onflow/cadence v1.0.0-preview.35 + github.com/onflow/cadence-tools/languageserver v1.0.0-preview.33 + github.com/onflow/cadence-tools/lint v1.0.0-preview.33 + github.com/onflow/cadence-tools/test v1.0.0-preview.33 github.com/onflow/contract-updater/lib/go/templates v1.0.1 github.com/onflow/fcl-dev-wallet v0.8.0-stable-cadence.1 - github.com/onflow/flixkit-go v1.2.1-cadence-v1-preview.18 - github.com/onflow/flow-core-contracts/lib/go/templates v1.0.0 - github.com/onflow/flow-emulator v1.0.0-preview.32 - github.com/onflow/flow-evm-gateway v0.19.0 - github.com/onflow/flow-go v0.35.14-crescendo-preview.27 - github.com/onflow/flow-go-sdk v1.0.0-preview.36 - github.com/onflow/flowkit/v2 v2.0.0-stable-cadence-alpha.24 + github.com/onflow/flixkit-go v1.2.1-cadence-v1-preview.19 + github.com/onflow/flow-core-contracts/lib/go/templates v1.3.0 + github.com/onflow/flow-emulator v1.0.0-preview.33 + github.com/onflow/flow-evm-gateway v0.21.0 + github.com/onflow/flow-go v0.35.14-crescendo-preview.27.0.20240626210601-604590f19db9 + github.com/onflow/flow-go-sdk v1.0.0-preview.37 + github.com/onflow/flowkit/v2 v2.0.0-stable-cadence-alpha.25 github.com/onflow/go-ethereum v1.13.4 github.com/onflowser/flowser/v3 v3.2.1-0.20240131200229-7d4d22715f48 github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c @@ -36,7 +36,7 @@ require ( github.com/rs/zerolog v1.33.0 github.com/sergi/go-diff v1.3.1 github.com/spf13/afero v1.10.0 - github.com/spf13/cobra v1.8.0 + github.com/spf13/cobra v1.8.1 github.com/spf13/viper v1.16.0 github.com/stretchr/testify v1.9.0 golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 @@ -203,14 +203,14 @@ require ( github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/onflow/atree v0.7.0-rc.2 // indirect github.com/onflow/crypto v0.25.1 // indirect - github.com/onflow/flow-core-contracts/lib/go/contracts v1.1.0 // indirect + github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.0 // indirect github.com/onflow/flow-ft/lib/go/contracts v1.0.0 // indirect github.com/onflow/flow-ft/lib/go/templates v1.0.0 // indirect github.com/onflow/flow-nft/lib/go/contracts v1.2.1 // indirect github.com/onflow/flow-nft/lib/go/templates v1.2.0 // indirect github.com/onflow/flow/protobuf/go/flow v0.4.4 // indirect github.com/onflow/nft-storefront/lib/go/contracts v1.0.0 // indirect - github.com/onflow/sdks v0.5.1-0.20230912225508-b35402f12bba // indirect + github.com/onflow/sdks v0.6.0-preview.1 // indirect github.com/onflow/wal v1.0.2 // indirect github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect github.com/pelletier/go-toml/v2 v2.0.8 // indirect diff --git a/go.sum b/go.sum index df038be48..a259560ea 100644 --- a/go.sum +++ b/go.sum @@ -1221,8 +1221,8 @@ github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwc github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0qnXZOBM= -github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= +github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/crate-crypto/go-ipa v0.0.0-20230601170251-1830d0757c80/go.mod h1:gzbVz57IDJgQ9rLQwfSk696JGWof8ftznEL9GoAv3NI= github.com/crate-crypto/go-kzg-4844 v0.7.0 h1:C0vgZRk4q4EZ/JgPfzuSoxdCq3C3mOZMBShovmncxvA= github.com/crate-crypto/go-kzg-4844 v0.7.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc= @@ -2157,14 +2157,14 @@ github.com/onflow/atree v0.6.1-0.20230711151834-86040b30171f/go.mod h1:xvP61FoOs github.com/onflow/atree v0.7.0-rc.2 h1:mZmVrl/zPlfI44EjV3FdR2QwIqT8nz1sCONUBFcML/U= github.com/onflow/atree v0.7.0-rc.2/go.mod h1:xvP61FoOs95K7IYdIYRnNcYQGf4nbF/uuJ0tHf4DRuM= github.com/onflow/cadence v1.0.0-M3/go.mod h1:odXGZZ/wGNA5mwT8bC9v8u8EXACHllB2ABSZK65TGL8= -github.com/onflow/cadence v1.0.0-preview.34 h1:MJSli75W6LJVUqSx/tq4MQe64H1+EcQBD/sNgpOO4jE= -github.com/onflow/cadence v1.0.0-preview.34/go.mod h1:jOwvPSSLTr9TvaKMs7KKiBYMmpdpNNAFxBsjMlrqVD0= -github.com/onflow/cadence-tools/languageserver v1.0.0-preview.32 h1:bcXyutzucIKXvrOPU3YcTcYMNUsEVQpnPwBT4Y4n3eI= -github.com/onflow/cadence-tools/languageserver v1.0.0-preview.32/go.mod h1:jD3nHNc67XrWd/IC714vN1N7odAXjCfg8M/y+f5OdH4= -github.com/onflow/cadence-tools/lint v1.0.0-preview.32 h1:ikRHM2aBd1OT8go4Ru/UWmmoEgfRHsWo1Hh4uOlQ91o= -github.com/onflow/cadence-tools/lint v1.0.0-preview.32/go.mod h1:0DlaXiefoamdXaOvMDLY5xg+qtkjG2YP82iCaDAGkp0= -github.com/onflow/cadence-tools/test v1.0.0-preview.32 h1:UBxfDY+za0cU0Dxt2t5bro+XtnZyvdPKiAHtRIujLfk= -github.com/onflow/cadence-tools/test v1.0.0-preview.32/go.mod h1:V5JDHX9mm+ta2Ejl+oActaxGNiToaABs4M+m1a871TY= +github.com/onflow/cadence v1.0.0-preview.35 h1:HZgt/9Foa6sCSH9SNaIFUSXK6q2ZxETg0ivsZbf+hhU= +github.com/onflow/cadence v1.0.0-preview.35/go.mod h1:jOwvPSSLTr9TvaKMs7KKiBYMmpdpNNAFxBsjMlrqVD0= +github.com/onflow/cadence-tools/languageserver v1.0.0-preview.33 h1:eepGWEYAh0V/xklsh8XFpENrnWJ3x/Hu3XhUGtwiu6Y= +github.com/onflow/cadence-tools/languageserver v1.0.0-preview.33/go.mod h1:3gRwz39hOVR9++tdUbV07eEYb1p0eXtPylLOqYmequw= +github.com/onflow/cadence-tools/lint v1.0.0-preview.33 h1:nTdKGCIBW/nWDLLBjkVgvMQxgaj+9F5+8o2NMXGs1Ac= +github.com/onflow/cadence-tools/lint v1.0.0-preview.33/go.mod h1:j+eA2hhi5a+g8SIPZhLLvw9SNFaASg+LS1m+kpb6fDc= +github.com/onflow/cadence-tools/test v1.0.0-preview.33 h1:LfV5rphRD0KeTcJskMjjzA6QU3hQNNKPsVzB9OfK17w= +github.com/onflow/cadence-tools/test v1.0.0-preview.33/go.mod h1:iehbYZI1AYGWFQ4ve+OmSgPEd5c9A/ygpmoXZc3P8Lw= github.com/onflow/contract-updater/lib/go/templates v1.0.1 h1:xPj898Y8OgLLbXH8+JeKVBV6J+nqPZjiLgGM3Abucto= github.com/onflow/contract-updater/lib/go/templates v1.0.1/go.mod h1:OXO6s0X7OW4Q6QTfAfnjoOmibEPgs0psOfMi+tPyzQE= github.com/onflow/crypto v0.25.0/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI= @@ -2172,25 +2172,25 @@ github.com/onflow/crypto v0.25.1 h1:0txy2PKPMM873JbpxQNbJmuOJtD56bfs48RQfm0ts5A= github.com/onflow/crypto v0.25.1/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI= github.com/onflow/fcl-dev-wallet v0.8.0-stable-cadence.1 h1:IqdUzdqFCSW0klWmA3J9c17ZyQTab9SWcWSLouX6o0Q= github.com/onflow/fcl-dev-wallet v0.8.0-stable-cadence.1/go.mod h1:kc42jkiuoPJmxMRFjfbRO9XvnR/3XLheaOerxVMDTiw= -github.com/onflow/flixkit-go v1.2.1-cadence-v1-preview.18 h1:3IznBzxdXKrVJ8YDaA2dSQD2HQeWmsL3HsjZY86L+5o= -github.com/onflow/flixkit-go v1.2.1-cadence-v1-preview.18/go.mod h1:dZqcdrsDdvBs5433bkXC8KN0l/jCamerWcmaB1P7YM4= -github.com/onflow/flow-core-contracts/lib/go/contracts v1.1.0 h1:AegPBm079X0qjneUYs+mRCpEUxSZ1lw5h4MbuXHlqn0= -github.com/onflow/flow-core-contracts/lib/go/contracts v1.1.0/go.mod h1:u/mkP/B+PbV33tEG3qfkhhBlydSvAKxfLZSfB4lsJHg= -github.com/onflow/flow-core-contracts/lib/go/templates v1.0.0 h1:za6bxPPW4JIsthhasUDTa1ruKjIO8DIhun9INQfj61Y= -github.com/onflow/flow-core-contracts/lib/go/templates v1.0.0/go.mod h1:NgbMOYnMh0GN48VsNKZuiwK7uyk38Wyo8jN9+C9QE30= -github.com/onflow/flow-emulator v1.0.0-preview.32 h1:VkJL7u75XUB8077CQvojKhxSCGirGCrsjAxjTOUIpD4= -github.com/onflow/flow-emulator v1.0.0-preview.32/go.mod h1:wwHM6+cJ5s3BIS9Wj0pXTRumj9n929fqwNuXqOD1g7g= -github.com/onflow/flow-evm-gateway v0.19.0 h1:gFhwFftwrbLbveLDfTm9R9IDCPgHmHlgsveaneQ3Kz8= -github.com/onflow/flow-evm-gateway v0.19.0/go.mod h1:yvA5LRcr7xn7EniccsX19ap0yUHzfMUj2nxLyRwiu+Y= +github.com/onflow/flixkit-go v1.2.1-cadence-v1-preview.19 h1:B8WO5T36P+TJ7CodehFze8VTOXw7RcKwbFTKNEAn1d0= +github.com/onflow/flixkit-go v1.2.1-cadence-v1-preview.19/go.mod h1:Dyqp/qkvrIzVzebZi2OlauljPmr65mtVZpc12wjIhR0= +github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.0 h1:cq3RfBr9TnTSnsGlUHMjMGZib24Horfb1XJqMpkN5ew= +github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.0/go.mod h1:u/mkP/B+PbV33tEG3qfkhhBlydSvAKxfLZSfB4lsJHg= +github.com/onflow/flow-core-contracts/lib/go/templates v1.3.0 h1:aMFJdB2CW+Dzm+AJ5QN6J1yWh+a0l2RxHN2/TtLaXUo= +github.com/onflow/flow-core-contracts/lib/go/templates v1.3.0/go.mod h1:NgbMOYnMh0GN48VsNKZuiwK7uyk38Wyo8jN9+C9QE30= +github.com/onflow/flow-emulator v1.0.0-preview.33 h1:1LFVpZJrgAZjPr5Jou3dbg6zOO5GMREnmE1dr9ndnJE= +github.com/onflow/flow-emulator v1.0.0-preview.33/go.mod h1:4T/kFzo8jccGF8GbxLlu3b/jwBH6GxX8p0hTPURHZ7k= +github.com/onflow/flow-evm-gateway v0.21.0 h1:8pbSLatORAqnvycOFECwD7aFvrezbPgfJX43Z9ajirw= +github.com/onflow/flow-evm-gateway v0.21.0/go.mod h1:GkRS6AN1YS7ltXWbMNKA32btSQcXUt5EoqPJ+y5nBgo= github.com/onflow/flow-ft/lib/go/contracts v1.0.0 h1:mToacZ5NWqtlWwk/7RgIl/jeKB/Sy/tIXdw90yKHcV0= github.com/onflow/flow-ft/lib/go/contracts v1.0.0/go.mod h1:PwsL8fC81cjnUnTfmyL/HOIyHnyaw/JA474Wfj2tl6A= github.com/onflow/flow-ft/lib/go/templates v1.0.0 h1:6cMS/lUJJ17HjKBfMO/eh0GGvnpElPgBXx7h5aoWJhs= github.com/onflow/flow-ft/lib/go/templates v1.0.0/go.mod h1:uQ8XFqmMK2jxyBSVrmyuwdWjTEb+6zGjRYotfDJ5pAE= -github.com/onflow/flow-go v0.35.14-crescendo-preview.27 h1:sWjWsutcFOP9o/etZF3Zii0eq4MMqKQchquwmyElWCQ= -github.com/onflow/flow-go v0.35.14-crescendo-preview.27/go.mod h1:P7AnyTH5W+hNm5pmhnYasIh7T6Z2kU4tiy53NJKvhZA= +github.com/onflow/flow-go v0.35.14-crescendo-preview.27.0.20240626210601-604590f19db9 h1:9GfHBXy9T8QEAkwX+KkmZjJadSOAVgiyn2n8s7sSueY= +github.com/onflow/flow-go v0.35.14-crescendo-preview.27.0.20240626210601-604590f19db9/go.mod h1:SE4kph7kpF6ydOXObtueEecGk3Hrjy/if/0UHY/eRO8= github.com/onflow/flow-go-sdk v1.0.0-M1/go.mod h1:TDW0MNuCs4SvqYRUzkbRnRmHQL1h4X8wURsCw9P9beo= -github.com/onflow/flow-go-sdk v1.0.0-preview.36 h1:3g72MjmZPEEVAbtDATbjwqKoNSB7yHLWswUHSAB5zwQ= -github.com/onflow/flow-go-sdk v1.0.0-preview.36/go.mod h1:mjkXIluC+kseYyd8Z1aTq73IiffAUeoY5fuX/C2Z+1w= +github.com/onflow/flow-go-sdk v1.0.0-preview.37 h1:ujeIQheD+skzFt9+eOT9nXcc1rFxVLSCzwisEI3+2DA= +github.com/onflow/flow-go-sdk v1.0.0-preview.37/go.mod h1:2aSN7RdKzxWoCtCyOJz9W/ZNqkLgQDQS3hKLYwPlvGw= github.com/onflow/flow-nft/lib/go/contracts v1.2.1 h1:woAAS5z651sDpi7ihAHll8NvRS9uFXIXkL6xR+bKFZY= github.com/onflow/flow-nft/lib/go/contracts v1.2.1/go.mod h1:2gpbza+uzs1k7x31hkpBPlggIRkI53Suo0n2AyA2HcE= github.com/onflow/flow-nft/lib/go/templates v1.2.0 h1:JSQyh9rg0RC+D1930BiRXN8lrtMs+ubVMK6aQPon6Yc= @@ -2198,14 +2198,15 @@ github.com/onflow/flow-nft/lib/go/templates v1.2.0/go.mod h1:p+2hRvtjLUR3MW1NsoJ github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20231121210617-52ee94b830c2/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk= github.com/onflow/flow/protobuf/go/flow v0.4.4 h1:lD1owoZGFgLcvdLZDmP0Kc4GOuQeSU3/d7hrujFzt6k= github.com/onflow/flow/protobuf/go/flow v0.4.4/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk= -github.com/onflow/flowkit/v2 v2.0.0-stable-cadence-alpha.24 h1:D6cbWqxuwjg/vXtNWyvViCNpWjUPMYfMewA9P4oT14s= -github.com/onflow/flowkit/v2 v2.0.0-stable-cadence-alpha.24/go.mod h1:89ipBRMJE9nWRimoqaa02+l6kCQuBiVyzszI6N3a6Sk= +github.com/onflow/flowkit/v2 v2.0.0-stable-cadence-alpha.25 h1:O5+TsPkN7nzVAaDZTnAww5Dx5p9ZczQHgLOZdq0xJFI= +github.com/onflow/flowkit/v2 v2.0.0-stable-cadence-alpha.25/go.mod h1:xEMke42kCoEtqkzc7+zkaWU5l22EpThdJ1YZuKutAMY= github.com/onflow/go-ethereum v1.13.4 h1:iNO86fm8RbBbhZ87ZulblInqCdHnAQVY8okBrNsTevc= github.com/onflow/go-ethereum v1.13.4/go.mod h1:cE/gEUkAffhwbVmMJYz+t1dAfVNHNwZCgc3BWtZxBGY= github.com/onflow/nft-storefront/lib/go/contracts v1.0.0 h1:sxyWLqGm/p4EKT6DUlQESDG1ZNMN9GjPCm1gTq7NGfc= github.com/onflow/nft-storefront/lib/go/contracts v1.0.0/go.mod h1:kMeq9zUwCrgrSojEbTUTTJpZ4WwacVm2pA7LVFr+glk= -github.com/onflow/sdks v0.5.1-0.20230912225508-b35402f12bba h1:rIehuhO6bj4FkwE4VzwEjX7MoAlOhUJENBJLqDqVxAo= github.com/onflow/sdks v0.5.1-0.20230912225508-b35402f12bba/go.mod h1:F0dj0EyHC55kknLkeD10js4mo14yTdMotnWMslPirrU= +github.com/onflow/sdks v0.6.0-preview.1 h1:mb/cUezuqWEP1gFZNAgUI4boBltudv4nlfxke1KBp9k= +github.com/onflow/sdks v0.6.0-preview.1/go.mod h1:F0dj0EyHC55kknLkeD10js4mo14yTdMotnWMslPirrU= github.com/onflow/wal v1.0.2 h1:5bgsJVf2O3cfMNK12fiiTyYZ8cOrUiELt3heBJfHOhc= github.com/onflow/wal v1.0.2/go.mod h1:iMC8gkLqu4nkbkAla5HkSBb+FGyQOZiWz3DYm2wSXCk= github.com/onflowser/flowser/v3 v3.2.1-0.20240131200229-7d4d22715f48 h1:eBS8Rm1V9TTGpj9lcpoCi6MIwWgYQZ8crJ7cSrS39Y4= @@ -2435,8 +2436,8 @@ github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3 github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM= -github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= -github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= +github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= +github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= diff --git a/install.ps1 b/install.ps1 index 9d8c67d88..f4b4b52b3 100644 --- a/install.ps1 +++ b/install.ps1 @@ -8,6 +8,8 @@ The destination path to install to. .Parameter Version The version to install. +.Parameter C1Version + The Cadence 1 version to install. .Parameter AddToPath Add the absolute destination path to the 'User' scope environment variable 'Path'. .Parameter GitHubToken @@ -23,6 +25,7 @@ #> param ( [string] $version="", + [string] $c1Version="", [string] $directory = "$env:APPDATA\Flow", [bool] $addToPath = $true, [string] $githubToken = "" @@ -36,12 +39,11 @@ Set-ItemProperty HKCU:\Console VirtualTerminalLevel -Type DWORD 1 $ErrorActionPreference = "Stop" $repo = "onflow/flow-cli" -$versionURL = "https://api.github.com/repos/$repo/releases/latest" $assetsURL = "https://github.com/$repo/releases/download" # Add the GitHub token to the web request headers if it was provided $webRequestOptions = if ($githubToken) { - @{ 'Headers' = @{ 'Authorization' = "Bearer $githubToken" } } + @{ 'Headers' = @{ 'Authorization' = "Bearer $githubToken" } } } else { @{} } @@ -49,16 +51,15 @@ $webRequestOptions = if ($githubToken) { # Function to get the latest version function Get-Version { param ( - [string]$repo, [string]$searchTerm, - [hashtable]$webRequestOptions + [bool]$prerelease ) $page = 1 $version = $null while (-not $version) { - $response = Invoke-WebRequest -Uri "https://api.github.com/repos/$repo/releases?per_page=100&page=$page" -UseBasicParsing @webRequestOptions -ErrorAction SilentlyContinue + $response = Invoke-WebRequest -Uri "https://api.github.com/repos/$repo/releases?per_page=10&page=$page" -UseBasicParsing @webRequestOptions -ErrorAction SilentlyContinue $status = $response.StatusCode if ($status -eq 403 -and $githubTokenHeader) { @@ -75,7 +76,7 @@ function Get-Version { $jsonResponse = $response.Content | ConvertFrom-Json foreach ($release in $jsonResponse) { - if ($release.tag_name -like "*$searchTerm*") { + if (($release.prerelease -eq $prerelease) -and ($release.tag_name -like "*$searchTerm*")) { $version = $release.tag_name break } @@ -87,27 +88,46 @@ function Get-Version { return $version } -if (-not $version) { - $version = Get-Version -repo $repo -searchTerm "cadence-v1.0.0" -webRequestOptions $webRequestOptions -} +function Install-FlowCLI { + param ( + [string]$version, + [string]$destinationFileName + ) + + Write-Output("Installing version {0} ..." -f $version) + + New-Item -ItemType Directory -Force -Path $directory | Out-Null + + $progressPreference = 'silentlyContinue' + + Invoke-WebRequest -Uri "$assetsURL/$version/flow-cli-$version-windows-amd64.zip" -UseBasicParsing -OutFile "$directory\flow.zip" @webRequestOptions -Write-Output("Installing version {0} ..." -f $version) + Expand-Archive -Path "$directory\flow.zip" -DestinationPath "$directory" -Force -New-Item -ItemType Directory -Force -Path $directory | Out-Null + try { + Stop-Process -Name flow -Force + Start-Sleep -Seconds 1 + } + catch {} + + Move-Item -Path "$directory\flow-cli.exe" -Destination "$directory\$destinationFileName" -Force +} + +if (-not $version) { + Write-Output "Getting version of latest stable release ..." -$progressPreference = 'silentlyContinue' + $version = Get-Version -searchTerm '' -prerelease $false +} -Invoke-WebRequest -Uri "$assetsURL/$version/flow-cli-$version-windows-amd64.zip" -UseBasicParsing -OutFile "$directory\flow.zip" @webRequestOptions +Install-FlowCLI -version $version -destinationFileName "flow.exe" -Expand-Archive -Path "$directory\flow.zip" -DestinationPath "$directory" -Force +if (-not $c1version) { + Write-Output "Getting version of latest Cadence 1.0 preview release ..." -try { - Stop-Process -Name flow -Force - Start-Sleep -Seconds 1 + $c1version = Get-Version -searchTerm "cadence-v1.0.0" -prerelease $true } -catch {} -Move-Item -Path "$directory\flow-cli.exe" -Destination "$directory\flow-c1.exe" -Force +Install-FlowCLI -version $c1Version -destinationFileName "flow-c1.exe" # Check if the directory is already in the PATH $existingPaths = [Environment]::GetEnvironmentVariable("PATH", [System.EnvironmentVariableTarget]::User).Split(';') @@ -121,7 +141,11 @@ if ($addToPath -and $existingPaths -notcontains $directory) { } Write-Output "" -Write-Output "Successfully installed Flow CLI $version" -Write-Output "PRE-RELEASE: Use the 'flow-c1' command to interact with this Cadence 1.0 CLI pre-release." +Write-Output "Successfully installed Flow CLI $version as 'flow'." +Write-Output "Use the 'flow' command to interact with the Flow CLI compatible with versions of Cadence before 1.0 (only)." +Write-Output "" +Write-Output "Successfully installed Flow CLI $c1Version as 'flow-c1'." +Write-Output "Use the 'flow-c1' command to interact with the Flow CLI preview compatible with Cadence 1.0 (only)." +Write-Output "" -Start-Sleep -Seconds 1 \ No newline at end of file +Start-Sleep -Seconds 1 diff --git a/install.sh b/install.sh index 265843f6b..330c9cad3 100755 --- a/install.sh +++ b/install.sh @@ -5,12 +5,12 @@ set -e REPO="ryokik/flow-cli" ASSETS_URL="https://github.com/$REPO/releases/download/" -# The version to download, set by get_version (defaults to args[1]) +# The version to install (defaults to args[1]) VERSION="$1" +# The Cadence 1.0 version to install (defaults to args[2]) +C1VERSION="$2" # The architecture string, set by get_architecture ARCH="" -# The tag search term to use if no version is specified (first match is used) -SEARCH_TERM="cadence-v1.0.0" # Optional environment variable for Github API token # If GITHUB_TOKEN is set, use it in the curl requests to avoid rate limiting @@ -61,81 +61,118 @@ get_architecture() { TARGET_PATH="${_targetpath}" } -# Get the latest version from remote if none specified in args. -page=1 get_version() { - if [ -z "$VERSION" ] - then - VERSION="" - if [ -n "$github_token_header" ] - then - response=$(curl -H "$github_token_header" -s "https://api.github.com/repos/$REPO/releases?per_page=100&page=$page" -w "%{http_code}") - else - response=$(curl -s "https://api.github.com/repos/$REPO/releases?per_page=100&page=$page" -w "%{http_code}") - fi + local search_term="$1" + local page="$2" + + local version="" + + response=$(curl -H "$github_token_header" -s "https://api.github.com/repos/$REPO/releases?per_page=10&page=$page" -w "%{http_code}") status=$(echo "$response" | tail -n 1) if [ "$status" -eq "403" ] && [ -n "$github_token_header" ] then - echo "Failed to get latest version from Github API, is your GITHUB_TOKEN valid? Trying without authentication..." + echo "Failed to get releases from Github API, is your GITHUB_TOKEN valid? Re-trying without authentication ..." github_token_header="" - get_version + get_version "$search_term" "$page" fi if [ "$status" -ne "200" ] then - echo "Failed to get latest version from Github API, please manually specify a version to install as an argument to this script." + echo "Failed to get releases from Github API, please manually specify a version to install as an argument to this script." return 1 fi - VERSION=$(echo "$response" | grep -E 'tag_name' | grep -E "$SEARCH_TERM" | head -n 1 | cut -d '"' -f 4) + version=$(echo "$response" | grep -E 'tag_name' | grep -E "$search_term" | head -n 1 | cut -d '"' -f 4) - if [ -z "$VERSION" ] + if [ -z "$version" ] then - page=$((page+1)) - get_version + get_version "$search_term" "$((page+1))" fi - fi + + echo "$version" } -# Determine the system architecure, download the appropriate binary, and -# install it in `/usr/local/bin` on macOS and `~/.local/bin` on Linux -# with executable permission. -main() { +get_latest() { + local version="" - get_architecture || exit 1 - get_version || exit 1 + response=$(curl -H "$github_token_header" -s "https://api.github.com/repos/$REPO/releases/latest" -w "%{http_code}") + + status=$(echo "$response" | tail -n 1) + if [ "$status" -eq "403" ] && [ -n "$github_token_header" ] + then + echo "Failed to get latest release from Github API, is your GITHUB_TOKEN valid? Re-trying without authentication ..." + github_token_header="" + get_latest + fi + + if [ "$status" -ne "200" ] + then + echo "Failed to get latest release from Github API, please manually specify a version to install as an argument to this script." + return 1 + fi + + echo "$response" | grep -E 'tag_name' | grep -E "$search_term" | head -n 1 | cut -d '"' -f 4 +} + +# Function to download and install a specified version +install_version() { + local version="$1" + local target_name="$2" - echo "Downloading version $VERSION ..." + echo "Installing version $version ..." tmpfile=$(mktemp 2>/dev/null || mktemp -t flow) - url="$ASSETS_URL$VERSION/flow-cli-$VERSION-$ARCH.tar.gz" - if [ -n "$github_token_header" ] - then - curl -H "$github_token_header" -L --progress-bar "$url" -o $tmpfile - else - curl -L --progress-bar "$url" -o $tmpfile - fi + url="$ASSETS_URL$version/flow-cli-$version-$ARCH.tar.gz" + curl -H "$github_token_header" -L --progress-bar "$url" -o "$tmpfile" # Ensure we don't receive a not found error as response. - if grep -q "Not Found" $tmpfile + if grep -q "Not Found" "$tmpfile" then - echo "Version $VERSION could not be found" + echo "Version $version could not be found" exit 1 fi - [ -d $TARGET_PATH ] || mkdir -p $TARGET_PATH + [ -d "$TARGET_PATH" ] || mkdir -p "$TARGET_PATH" + + tar -xf "$tmpfile" -C "$TARGET_PATH" + mv "$TARGET_PATH/flow-cli" "$TARGET_PATH/$target_name" + chmod +x "$TARGET_PATH/$target_name" +} + +# Determine the system architecture, download the appropriate binaries, and +# install them in `/usr/local/bin` on macOS and `~/.local/bin` on Linux +# with executable permissions. +main() { + get_architecture || exit 1 + + if [ -z "$VERSION" ] + then + echo "Getting version of latest stable release ..." + + VERSION=$(get_latest || exit 1) + fi + + install_version "$VERSION" "flow" - tar -xf $tmpfile -C $TARGET_PATH - mv $TARGET_PATH/flow-cli $TARGET_PATH/flow-c1 - chmod +x $TARGET_PATH/flow-c1 + if [ -z "$C1VERSION" ] + then + echo "Getting version of latest Cadence 1.0 preview release ..." + + C1VERSION=$(get_version "cadence-v1.0.0" 1 || exit 1) + fi + + install_version "$C1VERSION" "flow-c1" echo "" - echo "Successfully installed Flow CLI $VERSION to $TARGET_PATH." - echo "Make sure $TARGET_PATH is in your \$PATH environment variable." + echo "Successfully installed Flow CLI $VERSION as 'flow' in $TARGET_PATH." + echo "Use the 'flow' command to interact with the Flow CLI compatible with versions of Cadence before 1.0 (only)." echo "" - echo "PRE-RELEASE: Use the 'flow-c1' command to interact with this Cadence 1.0 CLI pre-release." + echo "Successfully installed Flow CLI $C1VERSION as 'flow-c1' in $TARGET_PATH." + echo "Use the 'flow-c1' command to interact with the Flow CLI preview compatible with Cadence 1.0 (only)." + echo "" + echo "Make sure $TARGET_PATH is in your \$PATH environment variable." echo "" } -main +main \ No newline at end of file diff --git a/internal/events/events.go b/internal/events/events.go index 0f72f844f..d59762bbf 100644 --- a/internal/events/events.go +++ b/internal/events/events.go @@ -23,6 +23,7 @@ import ( "encoding/json" "fmt" "io" + "sort" "github.com/onflow/cadence" jsoncdc "github.com/onflow/cadence/encoding/json" @@ -119,11 +120,21 @@ func eventString(writer io.Writer, event flow.Event) { _, _ = fmt.Fprintf(writer, " Tx ID\t%s\n", event.TransactionID) _, _ = fmt.Fprintf(writer, " Values\n") - fields := cadence.FieldsMappedByName(event.Value) + evt := event.Value - for _, field := range event.Value.EventType.Fields { - value := fields[field.Identifier] - printField(writer, field, value) + values := evt.FieldsMappedByName() + fields := evt.EventType.FieldsMappedByName() + + names := make([]string, 0, len(fields)) + for name := range fields { + names = append(names, name) + } + sort.Strings(names) + + for _, name := range names { + ty := fields[name] + value := values[name] + printField(writer, name, ty, value) } } @@ -131,25 +142,25 @@ func printValues(writer io.Writer, fieldIdentifier, typedId, valueString string) _, _ = fmt.Fprintf(writer, "\t\t- %s (%s): %s \n", fieldIdentifier, typedId, valueString) } -func printField(writer io.Writer, field cadence.Field, value cadence.Value) { +func printField(writer io.Writer, name string, ty cadence.Type, value cadence.Value) { v := value.String() var typeId string defer func() { if err := recover(); err != nil { - printValues(writer, field.Identifier, "?", v) + printValues(writer, name, "?", v) } }() - if field.Type != nil { + if ty != nil { //TODO: onflow/cadence issue #1672 //currently getting ID for cadence array will cause panic - typeId = field.Type.ID() + typeId = ty.ID() } if typeId == "" { // exception for not known typeId workaround for cadence arrays v = fmt.Sprintf("%s\n\t\thex: %x", v, v) typeId = "?" } - printValues(writer, field.Identifier, typeId, v) + printValues(writer, name, typeId, v) }