|
| 1 | +// Copyright (c) Mysten Labs, Inc. |
| 2 | +// SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +//# init --protocol-version 70 --accounts A --addresses P1=0x0 P2=0x0 P3=0x0 --simulator |
| 5 | + |
| 6 | +//# publish --upgradeable --sender A |
| 7 | +module P1::M { |
| 8 | + public fun foo(): u64 { 42 } |
| 9 | +} |
| 10 | + |
| 11 | +//# create-checkpoint |
| 12 | + |
| 13 | +//# upgrade --package P1 --upgrade-capability 1,1 --sender A |
| 14 | +module P2::M { |
| 15 | + public fun foo(): u64 { 43 } |
| 16 | +} |
| 17 | + |
| 18 | +//# upgrade --package P2 --upgrade-capability 1,1 --sender A |
| 19 | +module P3::M { |
| 20 | + public fun foo(): u64 { 44 } |
| 21 | +} |
| 22 | + |
| 23 | +//# programmable --sender A --inputs 42 @A |
| 24 | +//> 0: SplitCoins(Gas, [Input(0)]); |
| 25 | +//> 1: TransferObjects([Result(0)], Input(1)) |
| 26 | + |
| 27 | +//# create-checkpoint |
| 28 | + |
| 29 | +//# run-graphql |
| 30 | +{ # Fetch all package versions -- there should be 3 of these |
| 31 | + packageVersions(address: "@{P1}") { |
| 32 | + pageInfo { |
| 33 | + hasPreviousPage |
| 34 | + hasNextPage |
| 35 | + startCursor |
| 36 | + endCursor |
| 37 | + } |
| 38 | + edges { |
| 39 | + cursor |
| 40 | + node { |
| 41 | + address |
| 42 | + version |
| 43 | + } |
| 44 | + } |
| 45 | + } |
| 46 | +} |
| 47 | + |
| 48 | +//# run-graphql |
| 49 | +{ # Limit from the front |
| 50 | + packageVersions(address: "@{P1}", first: 2) { |
| 51 | + pageInfo { |
| 52 | + hasPreviousPage |
| 53 | + hasNextPage |
| 54 | + startCursor |
| 55 | + endCursor |
| 56 | + } |
| 57 | + edges { |
| 58 | + cursor |
| 59 | + node { |
| 60 | + address |
| 61 | + version |
| 62 | + } |
| 63 | + } |
| 64 | + } |
| 65 | +} |
| 66 | + |
| 67 | +//# run-graphql |
| 68 | +{ # Limit from the back |
| 69 | + packageVersions(address: "@{P1}", last: 2) { |
| 70 | + pageInfo { |
| 71 | + hasPreviousPage |
| 72 | + hasNextPage |
| 73 | + startCursor |
| 74 | + endCursor |
| 75 | + } |
| 76 | + edges { |
| 77 | + cursor |
| 78 | + node { |
| 79 | + address |
| 80 | + version |
| 81 | + } |
| 82 | + } |
| 83 | + } |
| 84 | +} |
| 85 | + |
| 86 | +//# run-graphql --cursors 1 |
| 87 | +{ # Offset at the front and then fetch from the front |
| 88 | + packageVersions(address: "@{P1}", after: "@{cursor_0}", first: 1) { |
| 89 | + pageInfo { |
| 90 | + hasPreviousPage |
| 91 | + hasNextPage |
| 92 | + startCursor |
| 93 | + endCursor |
| 94 | + } |
| 95 | + edges { |
| 96 | + cursor |
| 97 | + node { |
| 98 | + address |
| 99 | + version |
| 100 | + } |
| 101 | + } |
| 102 | + } |
| 103 | +} |
| 104 | + |
| 105 | +//# run-graphql --cursors 2 |
| 106 | +{ # Offset at the front such that the first page is not full |
| 107 | + packageVersions(address: "@{P1}", after: "@{cursor_0}", first: 2) { |
| 108 | + pageInfo { |
| 109 | + hasPreviousPage |
| 110 | + hasNextPage |
| 111 | + startCursor |
| 112 | + endCursor |
| 113 | + } |
| 114 | + edges { |
| 115 | + cursor |
| 116 | + node { |
| 117 | + address |
| 118 | + version |
| 119 | + } |
| 120 | + } |
| 121 | + } |
| 122 | +} |
| 123 | + |
| 124 | +//# run-graphql --cursors 2 |
| 125 | +{ # Offset at the front such that the first page is not full, fetch from the back |
| 126 | + packageVersions(address: "@{P1}", after: "@{cursor_0}", last: 2) { |
| 127 | + pageInfo { |
| 128 | + hasPreviousPage |
| 129 | + hasNextPage |
| 130 | + startCursor |
| 131 | + endCursor |
| 132 | + } |
| 133 | + edges { |
| 134 | + cursor |
| 135 | + node { |
| 136 | + address |
| 137 | + version |
| 138 | + } |
| 139 | + } |
| 140 | + } |
| 141 | +} |
| 142 | + |
| 143 | +//# run-graphql --cursors 3 |
| 144 | +{ # Offset at the back and fetch from the back |
| 145 | + packageVersions(address: "@{P1}", before: "@{cursor_0}", last: 1) { |
| 146 | + pageInfo { |
| 147 | + hasPreviousPage |
| 148 | + hasNextPage |
| 149 | + startCursor |
| 150 | + endCursor |
| 151 | + } |
| 152 | + edges { |
| 153 | + cursor |
| 154 | + node { |
| 155 | + address |
| 156 | + version |
| 157 | + } |
| 158 | + } |
| 159 | + } |
| 160 | +} |
| 161 | + |
| 162 | +//# run-graphql --cursors 3 |
| 163 | +{ # Offset at the back and fetch from the front |
| 164 | + packageVersions(address: "@{P1}", before: "@{cursor_0}", first: 1) { |
| 165 | + pageInfo { |
| 166 | + hasPreviousPage |
| 167 | + hasNextPage |
| 168 | + startCursor |
| 169 | + endCursor |
| 170 | + } |
| 171 | + edges { |
| 172 | + cursor |
| 173 | + node { |
| 174 | + address |
| 175 | + version |
| 176 | + } |
| 177 | + } |
| 178 | + } |
| 179 | +} |
| 180 | + |
| 181 | +//# run-graphql --cursors 2 |
| 182 | +{ # Offset at the back such that the first page is not full, fetch from the back |
| 183 | + packageVersions(address: "@{P1}", before: "@{cursor_0}", last: 2) { |
| 184 | + pageInfo { |
| 185 | + hasPreviousPage |
| 186 | + hasNextPage |
| 187 | + startCursor |
| 188 | + endCursor |
| 189 | + } |
| 190 | + edges { |
| 191 | + cursor |
| 192 | + node { |
| 193 | + address |
| 194 | + version |
| 195 | + } |
| 196 | + } |
| 197 | + } |
| 198 | +} |
| 199 | + |
| 200 | +//# run-graphql --cursors 2 |
| 201 | +{ # Offset at the back such that the first page is not full, fetch from the front |
| 202 | + packageVersions(address: "@{P1}", before: "@{cursor_0}", first: 2) { |
| 203 | + pageInfo { |
| 204 | + hasPreviousPage |
| 205 | + hasNextPage |
| 206 | + startCursor |
| 207 | + endCursor |
| 208 | + } |
| 209 | + edges { |
| 210 | + cursor |
| 211 | + node { |
| 212 | + address |
| 213 | + version |
| 214 | + } |
| 215 | + } |
| 216 | + } |
| 217 | +} |
| 218 | + |
| 219 | +//# run-graphql --cursors 1 3 |
| 220 | +{ # Offset at the front and back |
| 221 | + packageVersions(address: "@{P1}", after: "@{cursor_0}", before: "@{cursor_1}") { |
| 222 | + pageInfo { |
| 223 | + hasPreviousPage |
| 224 | + hasNextPage |
| 225 | + startCursor |
| 226 | + endCursor |
| 227 | + } |
| 228 | + edges { |
| 229 | + cursor |
| 230 | + node { |
| 231 | + address |
| 232 | + version |
| 233 | + } |
| 234 | + } |
| 235 | + } |
| 236 | +} |
| 237 | + |
| 238 | +//# run-graphql |
| 239 | +{ # Using packageVersions ..Before and ...After |
| 240 | + package(address: "@{P1}", version: 2) { |
| 241 | + packageVersionsBefore { |
| 242 | + nodes { version } |
| 243 | + } |
| 244 | + version |
| 245 | + packageVersionsAfter { |
| 246 | + nodes { version } |
| 247 | + } |
| 248 | + } |
| 249 | +} |
| 250 | + |
| 251 | +//# run-graphql |
| 252 | +{ # Object is not a package |
| 253 | + packageVersions(address: "@{obj_5_0}") { |
| 254 | + nodes { version } |
| 255 | + } |
| 256 | +} |
| 257 | + |
| 258 | +//# run-graphql |
| 259 | +{ # Anchor package doesn't exist at the checkpoint. |
| 260 | + doesntExist: checkpoint(sequenceNumber: 1) { |
| 261 | + query { |
| 262 | + packageVersions(address: "@{P2}") { |
| 263 | + nodes { version } |
| 264 | + } |
| 265 | + } |
| 266 | + } |
| 267 | + |
| 268 | + doesExist: checkpoint(sequenceNumber: 1) { |
| 269 | + query { |
| 270 | + packageVersions(address: "@{P1}") { |
| 271 | + nodes { version } |
| 272 | + } |
| 273 | + } |
| 274 | + } |
| 275 | +} |
0 commit comments