From d41423763290f1e2eaa158d36452864a71f975e4 Mon Sep 17 00:00:00 2001 From: EasonC13 Date: Wed, 2 Apr 2025 15:58:19 -0400 Subject: [PATCH 01/21] fix account link use suiscan --- scripts/src/init.ts | 24 ++--- scripts/yarn.lock | 211 ++++++++++++++++++++------------------------ 2 files changed, 106 insertions(+), 129 deletions(-) diff --git a/scripts/src/init.ts b/scripts/src/init.ts index 2a914cf..13bf4b6 100644 --- a/scripts/src/init.ts +++ b/scripts/src/init.ts @@ -1,26 +1,26 @@ -import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519'; -import { sleep, writeToFile } from './helpers'; - +import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519"; +import { sleep, writeToFile } from "./helpers"; const main = async () => { - console.log('Generating KeyPair...'); + console.log("Generating KeyPair..."); await sleep(1000); const keypair = new Ed25519Keypair(); const publicAddress = keypair.getPublicKey().toSuiAddress(); - const privateKey = keypair.getSecretKey() + const privateKey = keypair.getSecretKey(); const keyPairConfig = { publicAddress, - privateKey + privateKey, }; - await writeToFile('keypair.json', JSON.stringify(keyPairConfig, null, 2)); - - console.log('\nKeyPair written to file successfully @ keypair.json'); - console.log(`\nView your Sui account at https://explorer.polymedia.app/address/${publicAddress}?network=testnet`) + await writeToFile("keypair.json", JSON.stringify(keyPairConfig, null, 2)); -} + console.log("\nKeyPair written to file successfully @ keypair.json"); + console.log( + `\nView your Sui account at https://suiscan.xyz/testnet/account/${publicAddress}` + ); +}; -main(); \ No newline at end of file +main(); diff --git a/scripts/yarn.lock b/scripts/yarn.lock index 054b0e6..b15c397 100644 --- a/scripts/yarn.lock +++ b/scripts/yarn.lock @@ -3,14 +3,14 @@ "@0no-co/graphql.web@^1.0.5": - version "1.0.8" - resolved "https://registry.yarnpkg.com/@0no-co/graphql.web/-/graphql.web-1.0.8.tgz#20682c7839b0b5b7728ad944a8602ca46d983e75" - integrity sha512-8BG6woLtDMvXB9Ajb/uE+Zr/U7y4qJ3upXi0JQHZmsKUJa7HjF/gFvmL2f3/mSmfZoQGRr9VoY97LCX2uaFMzA== + version "1.1.2" + resolved "https://registry.yarnpkg.com/@0no-co/graphql.web/-/graphql.web-1.1.2.tgz#9af8deaf3f236c1c6ee99cc5349051475e5dcc83" + integrity sha512-N2NGsU5FLBhT8NZ+3l2YrzZSHITjNXNuDhC4iDiikv0IujaJ0Xc6xIxQZ/Ek3Cb+rgPjnLHYyJm11tInuJn+cw== "@0no-co/graphqlsp@^1.12.13": - version "1.12.13" - resolved "https://registry.yarnpkg.com/@0no-co/graphqlsp/-/graphqlsp-1.12.13.tgz#306769fb96a596171c3b152fb0529823b6c3c9c4" - integrity sha512-/C9yXft+mq+VdoniBgWvA+iK5X6cB50KKThg1je4bFIhhBNccLJlNbWFxOglXseKuisq+h5oIY4ELTVKs6GhRQ== + version "1.12.16" + resolved "https://registry.yarnpkg.com/@0no-co/graphqlsp/-/graphqlsp-1.12.16.tgz#58fe7bad53b3ad9fdf2d5f41ddeb9b418d289a03" + integrity sha512-B5pyYVH93Etv7xjT6IfB7QtMBdaaC07yjbhN6v8H7KgFStMkPvi+oWYBTibMFRMY89qwc9H8YixXg8SXDVgYWw== dependencies: "@gql.tada/internal" "^1.0.0" graphql "^15.5.0 || ^16.0.0 || ^17.0.0" @@ -22,19 +22,19 @@ dependencies: "@jridgewell/trace-mapping" "0.3.9" -"@gql.tada/cli-utils@1.6.1": - version "1.6.1" - resolved "https://registry.yarnpkg.com/@gql.tada/cli-utils/-/cli-utils-1.6.1.tgz#96bf13da9bcd9e9d34333a1870c65eed8a700d24" - integrity sha512-ZfYa5+rbK51c6ociTUL66qW1lyB9dXoAKNZMEAp2pWgPp16qZVBwopUaYxSKq4BML9eSiv0ocoJ7H6VW51ud7w== +"@gql.tada/cli-utils@1.6.3": + version "1.6.3" + resolved "https://registry.yarnpkg.com/@gql.tada/cli-utils/-/cli-utils-1.6.3.tgz#b893cec74908da4df0602691e2e0b1497fda8cda" + integrity sha512-jFFSY8OxYeBxdKi58UzeMXG1tdm4FVjXa8WHIi66Gzu9JWtCE6mqom3a8xkmSw+mVaybFW5EN2WXf1WztJVNyQ== dependencies: "@0no-co/graphqlsp" "^1.12.13" - "@gql.tada/internal" "1.0.7" + "@gql.tada/internal" "1.0.8" graphql "^15.5.0 || ^16.0.0 || ^17.0.0" -"@gql.tada/internal@1.0.7", "@gql.tada/internal@^1.0.0": - version "1.0.7" - resolved "https://registry.yarnpkg.com/@gql.tada/internal/-/internal-1.0.7.tgz#4fa478bbe58d88162f512d52866626fde0e1b439" - integrity sha512-mI/7l7If7YR4rBlgnkXihh1qxD7eO41o8nf5ZYjwYl4s6FGFQFZY1E1reV3AgRy8tDXbiuMz1bIVLpnxPXxKIQ== +"@gql.tada/internal@1.0.8", "@gql.tada/internal@^1.0.0": + version "1.0.8" + resolved "https://registry.yarnpkg.com/@gql.tada/internal/-/internal-1.0.8.tgz#3ba9fa6534809788bbbe103492f70b8e9d754027" + integrity sha512-XYdxJhtHC5WtZfdDqtKjcQ4d7R1s0d1rnlSs3OcBEUbYiPoJJfZU7tWsVXuv047Z6msvmr4ompJ7eLSK5Km57g== dependencies: "@0no-co/graphql.web" "^1.0.5" @@ -61,69 +61,63 @@ "@jridgewell/resolve-uri" "^3.0.3" "@jridgewell/sourcemap-codec" "^1.4.10" -"@mysten/bcs@1.0.4": - version "1.0.4" - resolved "https://registry.yarnpkg.com/@mysten/bcs/-/bcs-1.0.4.tgz#c8998ee7cb92d9e59e2fae735b69abe49d8037cb" - integrity sha512-6JoQi59GN/dVEBCNq8Rj4uOR0niDrJqDx/2gNQWXANwJakHIGH0AMniHrXP41B2dF+mZ3HVmh9Hi3otiEVQTrQ== +"@mysten/bcs@1.6.0": + version "1.6.0" + resolved "https://registry.yarnpkg.com/@mysten/bcs/-/bcs-1.6.0.tgz#ccd7153cef7a83a402724c8fb3b2603323a4aedc" + integrity sha512-ydDRYdIkIFCpHCcPvAkMC91fVwumjzbTgjqds0KsphDQI3jUlH3jFG5lfYNTmV6V3pkhOiRk1fupLBcsQsiszg== dependencies: - bs58 "^6.0.0" + "@scure/base" "^1.2.4" "@mysten/sui@^1.8.0": - version "1.8.0" - resolved "https://registry.yarnpkg.com/@mysten/sui/-/sui-1.8.0.tgz#e5f2363e9263578cf5ac4cc27231120ca0de0980" - integrity sha512-iL7yztpePS/GWFZ7yiD/Pl7ciuOD2ySyogJZmLFu4WxZfiIcXJX+U/U+Egq9VHvELk8+m+Z1OvvPlNQfuowMIg== + version "1.26.1" + resolved "https://registry.yarnpkg.com/@mysten/sui/-/sui-1.26.1.tgz#1f60709fe310868f051635940fe545e2e2ce2a2f" + integrity sha512-bBVvn2wZKipAvuUkKzHwGhs1JiIM33+b97d0uIWg3T6dJH/n1nfnGrzkBQsMGpoBAFOIUnKQAZmDwT4qvJbKkg== dependencies: "@graphql-typed-document-node/core" "^3.2.0" - "@mysten/bcs" "1.0.4" - "@noble/curves" "^1.4.2" - "@noble/hashes" "^1.4.0" - "@scure/bip32" "^1.4.0" - "@scure/bip39" "^1.3.0" - "@suchipi/femver" "^1.0.0" - bech32 "^2.0.0" + "@mysten/bcs" "1.6.0" + "@noble/curves" "^1.8.1" + "@noble/hashes" "^1.7.1" + "@scure/base" "^1.2.4" + "@scure/bip32" "^1.6.2" + "@scure/bip39" "^1.5.4" gql.tada "^1.8.2" graphql "^16.9.0" - tweetnacl "^1.0.3" + poseidon-lite "^0.2.0" valibot "^0.36.0" -"@noble/curves@^1.4.2", "@noble/curves@~1.6.0": - version "1.6.0" - resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.6.0.tgz#be5296ebcd5a1730fccea4786d420f87abfeb40b" - integrity sha512-TlaHRXDehJuRNR9TfZDNQ45mMEd5dwUwmicsafcIX4SsNiqnCHKjE/1alYPd/lDRVhxdhUAlv8uEhMCI5zjIJQ== +"@noble/curves@^1.8.1", "@noble/curves@~1.8.1": + version "1.8.1" + resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.8.1.tgz#19bc3970e205c99e4bdb1c64a4785706bce497ff" + integrity sha512-warwspo+UYUPep0Q+vtdVB4Ugn8GGQj8iyB3gnRWsztmUHTI3S1nhdiWNsPUGL0vud7JlRRk1XEu7Lq1KGTnMQ== dependencies: - "@noble/hashes" "1.5.0" - -"@noble/hashes@1.5.0", "@noble/hashes@^1.4.0", "@noble/hashes@~1.5.0": - version "1.5.0" - resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.5.0.tgz#abadc5ca20332db2b1b2aa3e496e9af1213570b0" - integrity sha512-1j6kQFb7QRru7eKN3ZDvRcP13rugwdxZqCjbiAVZfIJwgj2A65UmT4TgARXGlXgnRkORLTDTrO19ZErt7+QXgA== - -"@scure/base@~1.1.7", "@scure/base@~1.1.8": - version "1.1.8" - resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.1.8.tgz#8f23646c352f020c83bca750a82789e246d42b50" - integrity sha512-6CyAclxj3Nb0XT7GHK6K4zK6k2xJm6E4Ft0Ohjt4WgegiFUHEtFb2CGzmPmGBwoIhrLsqNLYfLr04Y1GePrzZg== - -"@scure/bip32@^1.4.0": - version "1.5.0" - resolved "https://registry.yarnpkg.com/@scure/bip32/-/bip32-1.5.0.tgz#dd4a2e1b8a9da60e012e776d954c4186db6328e6" - integrity sha512-8EnFYkqEQdnkuGBVpCzKxyIwDCBLDVj3oiX0EKUFre/tOjL/Hqba1D6n/8RcmaQy4f95qQFrO2A8Sr6ybh4NRw== + "@noble/hashes" "1.7.1" + +"@noble/hashes@1.7.1", "@noble/hashes@^1.7.1", "@noble/hashes@~1.7.1": + version "1.7.1" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.7.1.tgz#5738f6d765710921e7a751e00c20ae091ed8db0f" + integrity sha512-B8XBPsn4vT/KJAGqDzbwztd+6Yte3P4V7iafm24bxgDe/mlRuK6xmWPuCNrKt2vDafZ8MfJLlchDG/vYafQEjQ== + +"@scure/base@^1.2.4", "@scure/base@~1.2.2", "@scure/base@~1.2.4": + version "1.2.4" + resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.2.4.tgz#002eb571a35d69bdb4c214d0995dff76a8dcd2a9" + integrity sha512-5Yy9czTO47mqz+/J8GM6GIId4umdCk1wc1q8rKERQulIoc8VP9pzDcghv10Tl2E7R96ZUx/PhND3ESYUQX8NuQ== + +"@scure/bip32@^1.6.2": + version "1.6.2" + resolved "https://registry.yarnpkg.com/@scure/bip32/-/bip32-1.6.2.tgz#093caa94961619927659ed0e711a6e4bf35bffd0" + integrity sha512-t96EPDMbtGgtb7onKKqxRLfE5g05k7uHnHRM2xdE6BP/ZmxaLtPek4J4KfVn/90IQNrU1IOAqMgiDtUdtbe3nw== dependencies: - "@noble/curves" "~1.6.0" - "@noble/hashes" "~1.5.0" - "@scure/base" "~1.1.7" - -"@scure/bip39@^1.3.0": - version "1.4.0" - resolved "https://registry.yarnpkg.com/@scure/bip39/-/bip39-1.4.0.tgz#664d4f851564e2e1d4bffa0339f9546ea55960a6" - integrity sha512-BEEm6p8IueV/ZTfQLp/0vhw4NPnT9oWf5+28nvmeUICjP99f4vr2d+qc7AVGDDtwRep6ifR43Yed9ERVmiITzw== + "@noble/curves" "~1.8.1" + "@noble/hashes" "~1.7.1" + "@scure/base" "~1.2.2" + +"@scure/bip39@^1.5.4": + version "1.5.4" + resolved "https://registry.yarnpkg.com/@scure/bip39/-/bip39-1.5.4.tgz#07fd920423aa671be4540d59bdd344cc1461db51" + integrity sha512-TFM4ni0vKvCfBpohoh+/lY05i9gRbSwXWngAsF4CABQxoaOHijxuaZ2R6cStDQ5CHtHO9aGJTr4ksVJASRRyMA== dependencies: - "@noble/hashes" "~1.5.0" - "@scure/base" "~1.1.8" - -"@suchipi/femver@^1.0.0": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@suchipi/femver/-/femver-1.0.0.tgz#4909dcc069695e07bd23a64c4bfe411d11d9692f" - integrity sha512-bprE8+K5V+DPX7q2e2K57ImqNBdfGHDIWaGI5xHxZoxbKOuQZn4wzPiUxOAHnsUr3w3xHrWXwN7gnG/iIuEMIg== + "@noble/hashes" "~1.7.1" + "@scure/base" "~1.2.4" "@tsconfig/node10@^1.0.7": version "1.0.11" @@ -146,46 +140,29 @@ integrity sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA== "@types/node@^22.5.2": - version "22.5.2" - resolved "https://registry.yarnpkg.com/@types/node/-/node-22.5.2.tgz#e42344429702e69e28c839a7e16a8262a8086793" - integrity sha512-acJsPTEqYqulZS/Yp/S3GgeE6GZ0qYODUR8aVr/DkhHQ8l9nd4j5x1/ZJy9/gHrRlFMqkO6i0I3E27Alu4jjPg== + version "22.14.0" + resolved "https://registry.yarnpkg.com/@types/node/-/node-22.14.0.tgz#d3bfa3936fef0dbacd79ea3eb17d521c628bb47e" + integrity sha512-Kmpl+z84ILoG+3T/zQFyAJsU6EPTmOCj8/2+83fSN6djd6I4o7uOuGIH6vq3PrjY5BGitSbFuMN18j3iknubbA== dependencies: - undici-types "~6.19.2" + undici-types "~6.21.0" acorn-walk@^8.1.1: - version "8.3.3" - resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.3.3.tgz#9caeac29eefaa0c41e3d4c65137de4d6f34df43e" - integrity sha512-MxXdReSRhGO7VlFe1bRG/oI7/mdLV9B9JJT0N8vZOhF7gFRR5l3M8W9G8JxmKV+JC5mGqJ0QvqfSOLsCPa4nUw== + version "8.3.4" + resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.3.4.tgz#794dd169c3977edf4ba4ea47583587c5866236b7" + integrity sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g== dependencies: acorn "^8.11.0" acorn@^8.11.0, acorn@^8.4.1: - version "8.12.1" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.12.1.tgz#71616bdccbe25e27a54439e0046e89ca76df2248" - integrity sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg== + version "8.14.1" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.14.1.tgz#721d5dc10f7d5b5609a891773d47731796935dfb" + integrity sha512-OvQ/2pUDKmgfCg++xsTX1wGxfTaszcHVcTctW4UJB4hibJx2HXxxO5UmVgyjMa+ZDsiaf5wWLXYpRWMmBI0QHg== arg@^4.1.0: version "4.1.3" resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== -base-x@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/base-x/-/base-x-5.0.0.tgz#6d835ceae379130e1a4cb846a70ac4746f28ea9b" - integrity sha512-sMW3VGSX1QWVFA6l8U62MLKz29rRfpTlYdCqLdpLo1/Yd4zZwSbnUaDfciIAowAqvq7YFnWq9hrhdg1KYgc1lQ== - -bech32@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/bech32/-/bech32-2.0.0.tgz#078d3686535075c8c79709f054b1b226a133b355" - integrity sha512-LcknSilhIGatDAsY1ak2I8VtGaHNhgMSYVxFrGLXv+xLHytaKZKcaUJJUE7qmBr7h33o5YQwP55pMI0xmkpJwg== - -bs58@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/bs58/-/bs58-6.0.0.tgz#a2cda0130558535dd281a2f8697df79caaf425d8" - integrity sha512-PD0wEnEYg6ijszw/u8s+iI3H17cTymlrwkKhDhPZq+Sokl3AU4htyBFTjAeNAlCCmg0f53g6ih3jATyCKftTfw== - dependencies: - base-x "^5.0.0" - create-require@^1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333" @@ -197,30 +174,35 @@ diff@^4.0.1: integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== dotenv@^16.4.5: - version "16.4.5" - resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.4.5.tgz#cdd3b3b604cb327e286b4762e13502f717cb099f" - integrity sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg== + version "16.4.7" + resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.4.7.tgz#0e20c5b82950140aa99be360a8a5f52335f53c26" + integrity sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ== gql.tada@^1.8.2: - version "1.8.6" - resolved "https://registry.yarnpkg.com/gql.tada/-/gql.tada-1.8.6.tgz#4466cd818490edf67890b58f55a5fb617fe80ea1" - integrity sha512-XyN/BkZVEJ5kxgK8oDjHluLwXBLdlUO6P4+u/AmYfknFDj5M5AnaZMm3pntMDO9tpaaEczy9pfXDEJ6tYuTlyA== + version "1.8.10" + resolved "https://registry.yarnpkg.com/gql.tada/-/gql.tada-1.8.10.tgz#096a1b30d3c6fc74212fe07d507f01a4095f7f67" + integrity sha512-FrvSxgz838FYVPgZHGOSgbpOjhR+yq44rCzww3oOPJYi0OvBJjAgCiP6LEokZIYND2fUTXzQAyLgcvgw1yNP5A== dependencies: "@0no-co/graphql.web" "^1.0.5" "@0no-co/graphqlsp" "^1.12.13" - "@gql.tada/cli-utils" "1.6.1" - "@gql.tada/internal" "1.0.7" + "@gql.tada/cli-utils" "1.6.3" + "@gql.tada/internal" "1.0.8" "graphql@^15.5.0 || ^16.0.0 || ^17.0.0", graphql@^16.9.0: - version "16.9.0" - resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.9.0.tgz#1c310e63f16a49ce1fbb230bd0a000e99f6f115f" - integrity sha512-GGTKBX4SD7Wdb8mqeDLni2oaRGYQWjWHGKPQ24ZMnUtKfcsVoiv4uX8+LJr1K6U5VW2Lu1BwJnj7uiori0YtRw== + version "16.10.0" + resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.10.0.tgz#24c01ae0af6b11ea87bf55694429198aaa8e220c" + integrity sha512-AjqGKbDGUFRKIRCP9tCKiIGHyriz2oHEbPIbEtcSLSs4YjReZOIPQQWek4+6hjw62H9QShXHyaGivGiYVLeYFQ== make-error@^1.1.1: version "1.3.6" resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== +poseidon-lite@^0.2.0: + version "0.2.1" + resolved "https://registry.yarnpkg.com/poseidon-lite/-/poseidon-lite-0.2.1.tgz#7ad98e3a3aa5b91a1fd3a61a87460e9e46fd76d6" + integrity sha512-xIr+G6HeYfOhCuswdqcFpSX47SPhm0EpisWJ6h7fHlWwaVIvH3dLnejpatrtw6Xc6HaLrpq05y7VRfvDmDGIog== + ts-node@^10.9.2: version "10.9.2" resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.2.tgz#70f021c9e185bccdca820e26dc413805c101c71f" @@ -240,20 +222,15 @@ ts-node@^10.9.2: v8-compile-cache-lib "^3.0.1" yn "3.1.1" -tweetnacl@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-1.0.3.tgz#ac0af71680458d8a6378d0d0d050ab1407d35596" - integrity sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw== - typescript@^5.5.4: - version "5.5.4" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.5.4.tgz#d9852d6c82bad2d2eda4fd74a5762a8f5909e9ba" - integrity sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q== - -undici-types@~6.19.2: - version "6.19.8" - resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.19.8.tgz#35111c9d1437ab83a7cdc0abae2f26d88eda0a02" - integrity sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw== + version "5.8.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.8.2.tgz#8170b3702f74b79db2e5a96207c15e65807999e4" + integrity sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ== + +undici-types@~6.21.0: + version "6.21.0" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.21.0.tgz#691d00af3909be93a7faa13be61b3a5b50ef12cb" + integrity sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ== v8-compile-cache-lib@^3.0.1: version "3.0.1" From 67afbbc34d65679b837e6a692b640d50caaa7557 Mon Sep 17 00:00:00 2001 From: EasonC13 Date: Wed, 2 Apr 2025 16:22:54 -0400 Subject: [PATCH 02/21] update lesson 2 is Sui NFT --- README.md | 21 +++++- .../banana/sources/banana.move | 74 ------------------- .../banana_without_display/Move.toml | 37 ---------- .../sources/banana_without_display.move | 29 -------- .../{banana => sui_nft}/Move.lock | 18 ++--- .../{banana => sui_nft}/Move.toml | 5 +- .../sui_nft/sources/sui_nft.move | 69 +++++++++++++++++ 7 files changed, 98 insertions(+), 155 deletions(-) delete mode 100644 lessons/returning_objects/banana/sources/banana.move delete mode 100644 lessons/returning_objects/banana_without_display/Move.toml delete mode 100644 lessons/returning_objects/banana_without_display/sources/banana_without_display.move rename lessons/returning_objects/{banana => sui_nft}/Move.lock (60%) rename lessons/returning_objects/{banana => sui_nft}/Move.toml (97%) create mode 100644 lessons/returning_objects/sui_nft/sources/sui_nft.move diff --git a/README.md b/README.md index d736dbb..3ebf61c 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,8 @@ When learning Sui Move, developers are encouraged to use best practices to utili - [Handling Returned Objects](#handling-returned-objects) - [Exercise](#exercise) - [Objects as Input](#objects-as-input) - - [Exercise](#exercise-1) + - [Exercise 1: Input Objects - Counter](#exercise-1-input-objects---counter) + - [Exercise 2: Return Objects - SUIIII NFT](#exercise-2-return-objects---suiiii-nft) # Environment Setup @@ -107,6 +108,20 @@ The `delete` function receives the actual instance of the `SimpleObject` and del This usage is straightforward, but tends to leave developers wondering what this looks out in a wider context. In this lesson, you learn how to use objects as inputs in PTBs. -### Exercise +### Exercise 1: Input Objects - Counter + +View the contents [`counter.move`](./lessons/input_objects/counter/sources/counter.move). There is a deployed instance of this package on the Sui blockchain. The address of the package is [`0xad3225e7d4827f81dc0686177067e1b458e8468ceabcff3456888ce3d806eb8c`](https://suiscan.xyz/testnet/object/0xad3225e7d4827f81dc0686177067e1b458e8468ceabcff3456888ce3d806eb8c/txs) and the counter object is [0x1feb03541d20064d1876c26cfa44514f2e029c8201a2fe12a60589842b9d391d](https://suiscan.xyz/testnet/object/0x1feb03541d20064d1876c26cfa44514f2e029c8201a2fe12a60589842b9d391d/fields). + + +Navigate to [`scripts/lessons/input_objects/exercise.ts`](./scripts/src/lessons/input_objects/exercise.ts) and complete the exercise. + +### Exercise 2: Return Objects - SUIIII NFT + +The package of the SUIII NFT is at [`0x83feeef5abcb1d5caca48f5e4e2259f8fbbcac88c10d82cc95ed58ff6f0dcd79`](https://suiscan.xyz/testnet/object/0x83feeef5abcb1d5caca48f5e4e2259f8fbbcac88c10d82cc95ed58ff6f0dcd79/tx-blocks) and the NFT object type is [`0x83feeef5abcb1d5caca48f5e4e2259f8fbbcac88c10d82cc95ed58ff6f0dcd79::sui_nft::SuiNFT`](https://suiscan.xyz/testnet/collection/0x83feeef5abcb1d5caca48f5e4e2259f8fbbcac88c10d82cc95ed58ff6f0dcd79::sui_nft::SuiNFT/items). + + +View the contract at [`sui_nft.move`](./lessons/returning_objects/sui_nft/sources/sui_nft.move). Try to mint an NFT to your account and view it at explorer with PTBs. + +Navigate to [`scripts/lessons/return_objects/exercise.ts`](./scripts/src/lessons/return_objects/exercise.ts) and complete the exercise. -View the contents [`counter.move`](./lessons/input_objects/counter/sources/counter.move). There is a deployed instance of this package on the Sui blockchain. The address of the package is [`0xad3225e7d4827f81dc0686177067e1b458e8468ceabcff3456888ce3d806eb8c`](https://suiscan.xyz/testnet/object/0xad3225e7d4827f81dc0686177067e1b458e8468ceabcff3456888ce3d806eb8c/txs). Navigate to [`scripts/lessons/input_objects/exercise.ts`](./scripts/src/lessons/input_objects/exercise.ts) and complete the exercise. +> Bonus Challenge: Can you deploy the [SUIII NFT package](./lessons/returning_objects/sui_nft) yourself and use different text and images for the NFT? \ No newline at end of file diff --git a/lessons/returning_objects/banana/sources/banana.move b/lessons/returning_objects/banana/sources/banana.move deleted file mode 100644 index fcbf0ef..0000000 --- a/lessons/returning_objects/banana/sources/banana.move +++ /dev/null @@ -1,74 +0,0 @@ -module banana::banana { - - use sui::display; // https://docs.sui.io/references/framework/sui-framework/display - use sui::package; // https://docs.sui.io/references/framework/sui-framework/package - - /* - Struct for defining the Banana object type - - Abilities: - - key: allows this type to be an object on Sui - - store: allows this type to be freely transferrable by its owner and able to be wrapped in other objects - - Attributes: - - id: The object id of this object (required when using key ability) - - Further reading: - - key ability: https://move-book.com/storage/key-ability.html?highlight=key#the-key-ability - - store ability: https://move-book.com/storage/store-ability.html?highlight=store#ability-store - */ - public struct Banana has key, store { - id: UID, - } - - /* - Module's one-time witness to be used for setting up the display standard for the Banana type - - https://move-book.com/programmability/witness-pattern.html?highlight=one%20time#one-time-witness - */ - public struct BANANA has drop {} - - /* - Init function that sets up the display standard for the Banana object. This function will be called - once and only once during the package deployment. - - Further reading: - - Sui object display standard: https://docs.sui.io/standards/display - */ - fun init(otw: BANANA, ctx: &mut TxContext) { - let keys = vector[ - b"name".to_string(), - b"image_url".to_string(), - b"description".to_string(), - b"project_url".to_string(), - ]; - - let values = vector[ - b"banana".to_string(), - b"https://aggregator-devnet.walrus.space/v1/sSWivHob9Of1DTUgGUWt-Wk4pffzRdak5sN6Ld2VonE".to_string(), - b"Just a banana!".to_string(), - b"https://github.com/sui-foundation/sui-object-model-workshop".to_string(), - ]; - - let publisher = package::claim(otw, ctx); - - let mut display = display::new_with_fields( - &publisher, keys, values, ctx - ); - - display::update_version(&mut display); - - transfer::public_transfer(publisher, ctx.sender()); - transfer::public_transfer(display, ctx.sender()); - - } - - /* - Creates and returns a new Banana object. - */ - public fun new(ctx: &mut TxContext): Banana { - Banana { - id: object::new(ctx) - } - } -} \ No newline at end of file diff --git a/lessons/returning_objects/banana_without_display/Move.toml b/lessons/returning_objects/banana_without_display/Move.toml deleted file mode 100644 index 09fb665..0000000 --- a/lessons/returning_objects/banana_without_display/Move.toml +++ /dev/null @@ -1,37 +0,0 @@ -[package] -name = "banana_without_display" -edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move -# license = "" # e.g., "MIT", "GPL", "Apache 2.0" -# authors = ["..."] # e.g., ["Joe Smith (joesmith@noemail.com)", "John Snow (johnsnow@noemail.com)"] - -[dependencies] -Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/testnet" } - -# For remote import, use the `{ git = "...", subdir = "...", rev = "..." }`. -# Revision can be a branch, a tag, and a commit hash. -# MyRemotePackage = { git = "https://some.remote/host.git", subdir = "remote/path", rev = "main" } - -# For local dependencies use `local = path`. Path is relative to the package root -# Local = { local = "../path/to" } - -# To resolve a version conflict and force a specific version for dependency -# override use `override = true` -# Override = { local = "../conflicting/version", override = true } - -[addresses] -banana_without_display = "0x0" - -# Named addresses will be accessible in Move as `@name`. They're also exported: -# for example, `std = "0x1"` is exported by the Standard Library. -# alice = "0xA11CE" - -[dev-dependencies] -# The dev-dependencies section allows overriding dependencies for `--test` and -# `--dev` modes. You can introduce test-only dependencies here. -# Local = { local = "../path/to/dev-build" } - -[dev-addresses] -# The dev-addresses section allows overwriting named addresses for the `--test` -# and `--dev` modes. -# alice = "0xB0B" - diff --git a/lessons/returning_objects/banana_without_display/sources/banana_without_display.move b/lessons/returning_objects/banana_without_display/sources/banana_without_display.move deleted file mode 100644 index f699ca5..0000000 --- a/lessons/returning_objects/banana_without_display/sources/banana_without_display.move +++ /dev/null @@ -1,29 +0,0 @@ -module banana_without_display::banana { - - /* - Struct for defining the Banana object type - - Abilities: - - key: allows this type to be an object on Sui - - store: allows this type to be freely transferrable by its owner and able to be wrapped in other objects - - Attributes: - - id: The object id of this object (required when using key ability) - - Further reading: - - key ability: https://move-book.com/storage/key-ability.html?highlight=key#the-key-ability - - store ability: https://move-book.com/storage/store-ability.html?highlight=store#ability-store - */ - public struct Banana has key, store { - id: UID, - } - - /* - Creates and returns a new Banana object. - */ - public fun new(ctx: &mut TxContext): Banana { - Banana { - id: object::new(ctx) - } - } -} \ No newline at end of file diff --git a/lessons/returning_objects/banana/Move.lock b/lessons/returning_objects/sui_nft/Move.lock similarity index 60% rename from lessons/returning_objects/banana/Move.lock rename to lessons/returning_objects/sui_nft/Move.lock index ba5872a..d060b92 100644 --- a/lessons/returning_objects/banana/Move.lock +++ b/lessons/returning_objects/sui_nft/Move.lock @@ -1,27 +1,27 @@ # @generated by Move, please check-in and do not edit manually. [move] -version = 2 -manifest_digest = "201CD322904BD2F4D57F86F368FCABDA675EB95CBFAD348B3A5AF3C605E92D1D" +version = 3 +manifest_digest = "CCFD73EDA7FC660FF9AC2F586A30517E74B2FAD88FA65DCB376A1925058EBF73" deps_digest = "F8BBB0CCB2491CA29A3DF03D6F92277A4F3574266507ACD77214D37ECA3F3082" dependencies = [ - { name = "Sui" }, + { id = "Sui", name = "Sui" }, ] [[move.package]] -name = "MoveStdlib" +id = "MoveStdlib" source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/testnet", subdir = "crates/sui-framework/packages/move-stdlib" } [[move.package]] -name = "Sui" +id = "Sui" source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/testnet", subdir = "crates/sui-framework/packages/sui-framework" } dependencies = [ - { name = "MoveStdlib" }, + { id = "MoveStdlib", name = "MoveStdlib" }, ] [move.toolchain-version] -compiler-version = "1.30.3" +compiler-version = "1.40.3" edition = "2024.beta" flavor = "sui" @@ -29,6 +29,6 @@ flavor = "sui" [env.testnet] chain-id = "4c78adac" -original-published-id = "0xadfb946c8c887446d284dae80ac8501c02ec9b9157babb96ca884773bfbb7771" -latest-published-id = "0xadfb946c8c887446d284dae80ac8501c02ec9b9157babb96ca884773bfbb7771" +original-published-id = "0x83feeef5abcb1d5caca48f5e4e2259f8fbbcac88c10d82cc95ed58ff6f0dcd79" +latest-published-id = "0x83feeef5abcb1d5caca48f5e4e2259f8fbbcac88c10d82cc95ed58ff6f0dcd79" published-version = "1" diff --git a/lessons/returning_objects/banana/Move.toml b/lessons/returning_objects/sui_nft/Move.toml similarity index 97% rename from lessons/returning_objects/banana/Move.toml rename to lessons/returning_objects/sui_nft/Move.toml index 7cd5ccd..19d016e 100644 --- a/lessons/returning_objects/banana/Move.toml +++ b/lessons/returning_objects/sui_nft/Move.toml @@ -1,5 +1,5 @@ [package] -name = "banana" +name = "sui_nft" edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move # license = "" # e.g., "MIT", "GPL", "Apache 2.0" # authors = ["..."] # e.g., ["Joe Smith (joesmith@noemail.com)", "John Snow (johnsnow@noemail.com)"] @@ -19,7 +19,7 @@ Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-fram # Override = { local = "../conflicting/version", override = true } [addresses] -banana = "0x0" +sui_nft = "0x0" # Named addresses will be accessible in Move as `@name`. They're also exported: # for example, `std = "0x1"` is exported by the Standard Library. @@ -34,4 +34,3 @@ banana = "0x0" # The dev-addresses section allows overwriting named addresses for the `--test` # and `--dev` modes. # alice = "0xB0B" - diff --git a/lessons/returning_objects/sui_nft/sources/sui_nft.move b/lessons/returning_objects/sui_nft/sources/sui_nft.move new file mode 100644 index 0000000..64dfc70 --- /dev/null +++ b/lessons/returning_objects/sui_nft/sources/sui_nft.move @@ -0,0 +1,69 @@ +module sui_nft::sui_nft { + + use sui::display; // https://docs.sui.io/references/framework/sui-framework/display + use sui::package; // https://docs.sui.io/references/framework/sui-framework/package + + /* + Struct for defining the Sui NFT object type + + Abilities: + - key: allows this type to be an object on Sui + - store: allows this type to be freely transferrable by its owner and able to be wrapped in other objects + + Attributes: + - id: The object id of this object (required when using key ability) + + Further reading: + - key ability: https://move-book.comtorageey-ability.html?highlight=key#the-key-ability + - store ability: https://move-book.comtoragetore-ability.html?highlight=store#ability-store + */ + public struct SuiNFT has key, store { + id: UID, + } + + /* + Module's one-time witness to be used for setting up the display standard for the Sui NFT type + + https://move-book.comrogrammabilityitness-pattern.html?highlight=one%20time#one-time-witness + */ + public struct SUI_NFT has drop {} + + /* + Init function that sets up the display standard for the Sui NFT object. This function will be called + once and only once during the package deployment. + + Further reading: + - Sui object display standard: https://docs.sui.iotandardsisplay + */ + fun init(otw: SUI_NFT, ctx: &mut TxContext) { + let keys = vector[ + b"name".to_string(), + b"image_url".to_string(), + b"description".to_string(), + b"project_url".to_string(), + ]; + + let values = vector[ + b"SUIIIII".to_string(), + b"https://media.tenor.com/t3eKwU-odDgAAAAM/sui-siu.gif".to_string(), + b"SUIIIII it out!".to_string(), + b"https://github.com/sui-foundation/sui-object-model-workshop".to_string(), + ]; + + let publisher = package::claim(otw, ctx); + + let mut display = display::new_with_fields(&publisher, keys, values, ctx); + + display::update_version(&mut display); + + transfer::public_transfer(publisher, ctx.sender()); + transfer::public_transfer(display, ctx.sender()); + } + + /* + Creates and returns a new SuiNFT object. + */ + public fun new(ctx: &mut TxContext): SuiNFT { + SuiNFT {id: object::new(ctx)} + } +} From 688d693224f24e7deac3453fa59f5c904c8394b9 Mon Sep 17 00:00:00 2001 From: EasonC13 Date: Wed, 2 Apr 2025 16:49:28 -0400 Subject: [PATCH 03/21] add: task 3 scavenger descriptions --- README.md | 21 ++++- {scavenger => lessons/scavenger}/Move.lock | 16 ++-- {scavenger => lessons/scavenger}/Move.toml | 0 .../scavenger}/sources/key.move | 0 lessons/scavenger/sources/test_buck.move | 65 +++++++++++++ lessons/scavenger/sources/vault.move | 94 +++++++++++++++++++ scavenger/sources/vault.move | 91 ------------------ scripts/package.json | 5 +- .../src/lessons/return_objects/exercise.ts | 77 +++++++-------- .../src/lessons/scavenger_hunt/exercise.ts | 61 ++++++++++++ 10 files changed, 285 insertions(+), 145 deletions(-) rename {scavenger => lessons/scavenger}/Move.lock (74%) rename {scavenger => lessons/scavenger}/Move.toml (100%) rename {scavenger => lessons/scavenger}/sources/key.move (100%) create mode 100644 lessons/scavenger/sources/test_buck.move create mode 100644 lessons/scavenger/sources/vault.move delete mode 100644 scavenger/sources/vault.move create mode 100644 scripts/src/lessons/scavenger_hunt/exercise.ts diff --git a/README.md b/README.md index 3ebf61c..7c0edac 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,8 @@ When learning Sui Move, developers are encouraged to use best practices to utili - [Exercise](#exercise) - [Objects as Input](#objects-as-input) - [Exercise 1: Input Objects - Counter](#exercise-1-input-objects---counter) - - [Exercise 2: Return Objects - SUIIII NFT](#exercise-2-return-objects---suiiii-nft) + - [Exercise 2: Handling Returned Objects with PTBs - SUIIII NFT](#exercise-2-handling-returned-objects-with-ptbs---suiiii-nft) + - [Exercise 3: Scavenger Hunting with PTBs](#exercise-3-scavenger-hunting-with-ptbs) # Environment Setup @@ -115,7 +116,7 @@ View the contents [`counter.move`](./lessons/input_objects/counter/sources/count Navigate to [`scripts/lessons/input_objects/exercise.ts`](./scripts/src/lessons/input_objects/exercise.ts) and complete the exercise. -### Exercise 2: Return Objects - SUIIII NFT +### Exercise 2: Handling Returned Objects with PTBs - SUIIII NFT The package of the SUIII NFT is at [`0x83feeef5abcb1d5caca48f5e4e2259f8fbbcac88c10d82cc95ed58ff6f0dcd79`](https://suiscan.xyz/testnet/object/0x83feeef5abcb1d5caca48f5e4e2259f8fbbcac88c10d82cc95ed58ff6f0dcd79/tx-blocks) and the NFT object type is [`0x83feeef5abcb1d5caca48f5e4e2259f8fbbcac88c10d82cc95ed58ff6f0dcd79::sui_nft::SuiNFT`](https://suiscan.xyz/testnet/collection/0x83feeef5abcb1d5caca48f5e4e2259f8fbbcac88c10d82cc95ed58ff6f0dcd79::sui_nft::SuiNFT/items). @@ -124,4 +125,18 @@ View the contract at [`sui_nft.move`](./lessons/returning_objects/sui_nft/source Navigate to [`scripts/lessons/return_objects/exercise.ts`](./scripts/src/lessons/return_objects/exercise.ts) and complete the exercise. -> Bonus Challenge: Can you deploy the [SUIII NFT package](./lessons/returning_objects/sui_nft) yourself and use different text and images for the NFT? \ No newline at end of file +> Bonus Challenge: Can you deploy the [SUIII NFT package](./lessons/returning_objects/sui_nft) yourself and use different text and images for the NFT? + +### Exercise 3: Scavenger Hunting with PTBs + +In this exercise, you will try to get the `Bucket USD` coin in Testnet from the vault using a key created by PTBs. The deployed contract is at [`0x25dfcadb5927395b463a426e8d63425d654a6057affc368f4dc176e587f489a5`](https://suiscan.xyz/testnet/object/0x25dfcadb5927395b463a426e8d63425d654a6057affc368f4dc176e587f489a5/contracts). + +Navigate to [`scavenger`](./lessons/scavenger) to read the smart contract code. + +You will need to create a PTB to: +1. Create a key +2. Set the key code correctly +3. Use the key to withdraw the `Bucket USD` coin from the vault +4. Transfer the `Bucket USD` coin to your account + +Navigate to [`scripts/lessons/scavenger_hunt/exercise.ts`](./scripts/src/lessons/scavenger_hunt/exercise.ts) and complete the exercise. \ No newline at end of file diff --git a/scavenger/Move.lock b/lessons/scavenger/Move.lock similarity index 74% rename from scavenger/Move.lock rename to lessons/scavenger/Move.lock index e34373f..5751d4a 100644 --- a/scavenger/Move.lock +++ b/lessons/scavenger/Move.lock @@ -1,27 +1,27 @@ # @generated by Move, please check-in and do not edit manually. [move] -version = 2 +version = 3 manifest_digest = "126734ECE6CB3DEAB0DC716ACD7D3114DBCCD48ED4122BDBCAFF81249A4DD637" deps_digest = "F8BBB0CCB2491CA29A3DF03D6F92277A4F3574266507ACD77214D37ECA3F3082" dependencies = [ - { name = "Sui" }, + { id = "Sui", name = "Sui" }, ] [[move.package]] -name = "MoveStdlib" +id = "MoveStdlib" source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/mainnet", subdir = "crates/sui-framework/packages/move-stdlib" } [[move.package]] -name = "Sui" +id = "Sui" source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/mainnet", subdir = "crates/sui-framework/packages/sui-framework" } dependencies = [ - { name = "MoveStdlib" }, + { id = "MoveStdlib", name = "MoveStdlib" }, ] [move.toolchain-version] -compiler-version = "1.33.0" +compiler-version = "1.40.3" edition = "2024.beta" flavor = "sui" @@ -29,8 +29,8 @@ flavor = "sui" [env.testnet] chain-id = "4c78adac" -original-published-id = "0xd198abee8def4735cb8b1848e50d5cde4f680ee62e881cb5e2638cf7bdef4512" -latest-published-id = "0xd198abee8def4735cb8b1848e50d5cde4f680ee62e881cb5e2638cf7bdef4512" +original-published-id = "0x25dfcadb5927395b463a426e8d63425d654a6057affc368f4dc176e587f489a5" +latest-published-id = "0x25dfcadb5927395b463a426e8d63425d654a6057affc368f4dc176e587f489a5" published-version = "1" [env.mainnet] diff --git a/scavenger/Move.toml b/lessons/scavenger/Move.toml similarity index 100% rename from scavenger/Move.toml rename to lessons/scavenger/Move.toml diff --git a/scavenger/sources/key.move b/lessons/scavenger/sources/key.move similarity index 100% rename from scavenger/sources/key.move rename to lessons/scavenger/sources/key.move diff --git a/lessons/scavenger/sources/test_buck.move b/lessons/scavenger/sources/test_buck.move new file mode 100644 index 0000000..631b99c --- /dev/null +++ b/lessons/scavenger/sources/test_buck.move @@ -0,0 +1,65 @@ +module scavenger::test_buck { + + // ----- Use Statements ----- + + use sui::coin::{ Self }; + use sui::url; + use scavenger::vault; + + // ----- Structs ----- + + /// One-time witness type for the TEST_BUCK coin + /// The 'drop' ability allows this type to be dropped after the init function completes + public struct TEST_BUCK has drop {} + + // ----- Init Functions ----- + + /// Module initializer, called once when the module is published + /// @param test_buck - One-time witness for the TEST_BUCK currency + /// @param ctx - Transaction context for accessing sender and creating objects + fun init( + test_buck: TEST_BUCK, + ctx: &mut tx_context::TxContext, + ) { + // Create a new currency with the following parameters: + // - 9 decimals of precision + // - Symbol: BUCK + // - Name: Bucket USD + // - Description: Test token for the testnet + // - Icon URL: Link to the token's SVG image + let (mut treasury_cap, coin_metadata) = coin::create_currency( + test_buck, + 9, + b"BUCK", + b"Bucket USD", + b"Bucket USD at testnet for testing", + option::some( + url::new_unsafe_from_bytes( + b"https://bucket-cdn-eason.s3.us-west-1.amazonaws.com/BUCK.svg" + ) + ), + ctx + ); + // Freeze the metadata to make it immutable + transfer::public_freeze_object(coin_metadata); + + // Mint 10^19 tokens (10 billion tokens with 9 decimal places) + let coin = coin::mint( + &mut treasury_cap, + 10000000000000000000, + ctx + ); + // Freeze the treasury cap to prevent further minting + transfer::public_freeze_object(treasury_cap); + + // Create a new vault with: + // - The newly minted coins + // - Withdrawal amount of 10 billion (10^10) + // - Access code of 777 + let admin_cap = vault::new(coin, 10000000000, 777, ctx); + + // Transfer the admin capability to the transaction sender + transfer::public_transfer(admin_cap, tx_context::sender(ctx)); + } + +} diff --git a/lessons/scavenger/sources/vault.move b/lessons/scavenger/sources/vault.move new file mode 100644 index 0000000..cfcf875 --- /dev/null +++ b/lessons/scavenger/sources/vault.move @@ -0,0 +1,94 @@ +module scavenger::vault { + + use sui::coin; + use sui::balance; + use scavenger::key; + + public struct Vault has key { + id: UID, + balance: balance::Balance, + withdrawal_amount: u64, + code: u64 + } + + public struct AdminCap has key, store { + id: UID, + vault_id: ID + } + + public fun new( + coins: coin::Coin, + withdrawal_amount: u64, + code: u64, + ctx: &mut TxContext + ): AdminCap { + let new_vault = Vault { + id: object::new(ctx), + balance: coin::into_balance(coins), + withdrawal_amount, + code + }; + + let new_admin_cap = AdminCap { + id: object::new(ctx), + vault_id: new_vault.id.to_inner() + }; + + transfer::share_object(new_vault); + + new_admin_cap + } + + public fun withdraw( + vault: &mut Vault, key: key::Key, + ctx: &mut TxContext + ): coin::Coin { + + assert_valid_key_code(vault, &key);key.delete(); + let new_coin = coin::from_balance( + balance::split( + &mut vault.balance, + vault.withdrawal_amount + ), + ctx + ); + + new_coin + + } + + public fun empty( + vault: Vault, + admin_cap: AdminCap, + ctx: &mut TxContext + ): coin::Coin { + assert_valid_admin_cap(&vault, &admin_cap); + + let AdminCap {id: admin_cap_id, vault_id: _} = admin_cap; + admin_cap_id.delete(); + + let Vault { + id, + balance, + withdrawal_amount: _, + code: _ + } = vault; + id.delete(); + + coin::from_balance(balance, ctx) + } + + fun assert_valid_key_code(vault: &Vault, key: &key::Key) { + assert!(vault.code == key.get_code()); + } + + fun assert_valid_admin_cap( + vault: &Vault, + admin_cap: &AdminCap + ) { + assert!( + vault.id.to_inner() == admin_cap.vault_id + ); + } + +} diff --git a/scavenger/sources/vault.move b/scavenger/sources/vault.move deleted file mode 100644 index 95fca18..0000000 --- a/scavenger/sources/vault.move +++ /dev/null @@ -1,91 +0,0 @@ -module scavenger::vault { - - use sui::coin; - use sui::balance; - use sui::sui::SUI; - - use scavenger::key; - - public struct Vault has key { - id: UID, - balance: balance::Balance, - withdrawal_amount: u64, - code: u64 - } - - public struct AdminCap has key, store { - id: UID, - vault_id: ID - } - - public fun new( - sui_coins: coin::Coin, - withdrawal_amount: u64, - code: u64, - ctx: &mut TxContext - ): AdminCap { - let new_vault = Vault { - id: object::new(ctx), - balance: coin::into_balance(sui_coins), - withdrawal_amount, - code - }; - - let new_admin_cap = AdminCap { - id: object::new(ctx), - vault_id: new_vault.id.to_inner() - }; - - transfer::share_object( - new_vault - ); - - new_admin_cap - } - - public fun withdraw(vault: &mut Vault, key: key::Key, ctx: &mut TxContext): coin::Coin { - - assert_valid_key_code(vault, &key); - - key.delete(); - let new_coin = coin::from_balance( - balance::split( - &mut vault.balance, - vault.withdrawal_amount - ), - ctx - ); - - new_coin - - } - - public fun empty(vault: Vault, admin_cap: AdminCap, ctx: &mut TxContext): coin::Coin { - assert_valid_admin_cap(&vault, &admin_cap); - - let AdminCap { - id: admin_cap_id, - vault_id: _ - } = admin_cap; - admin_cap_id.delete(); - - let Vault { - id, - balance, - withdrawal_amount: _, - code: _ - } = vault; - id.delete(); - - coin::from_balance(balance, ctx) - } - - fun assert_valid_key_code(vault: &Vault, key: &key::Key) { - assert!(vault.code == key.get_code()); - } - - fun assert_valid_admin_cap(vault: &Vault, admin_cap: &AdminCap) { - assert!(vault.id.to_inner() == admin_cap.vault_id); - } - -} \ No newline at end of file diff --git a/scripts/package.json b/scripts/package.json index f2e96f3..562cc41 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -11,10 +11,11 @@ "scripts": { "init-keypair": "ts-node src/init.ts", "return-objects": "ts-node src/lessons/return_objects/exercise.ts", - "input-objects": "ts-node src/lessons/input_objects/exercise.ts" + "input-objects": "ts-node src/lessons/input_objects/exercise.ts", + "scavenger-hunt": "ts-node src/lessons/scavenger_hunt/exercise.ts" }, "dependencies": { "@mysten/sui": "^1.8.0", "dotenv": "^16.4.5" } -} +} \ No newline at end of file diff --git a/scripts/src/lessons/return_objects/exercise.ts b/scripts/src/lessons/return_objects/exercise.ts index f535da3..95533e7 100644 --- a/scripts/src/lessons/return_objects/exercise.ts +++ b/scripts/src/lessons/return_objects/exercise.ts @@ -1,80 +1,75 @@ -import { Transaction } from '@mysten/sui/transactions'; +import { Transaction } from "@mysten/sui/transactions"; import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519"; -import { getFullnodeUrl, SuiClient } from '@mysten/sui/client'; -import { decodeSuiPrivateKey } from '@mysten/sui/cryptography'; -import keyPairJson from '../../../keypair.json'; - +import { getFullnodeUrl, SuiClient } from "@mysten/sui/client"; +import { decodeSuiPrivateKey } from "@mysten/sui/cryptography"; +import keyPairJson from "../../../keypair.json"; /** - * + * * Global variables - * + * * These variables are used throughout the exercise below. - * + * */ const { secretKey } = decodeSuiPrivateKey(keyPairJson.privateKey); const keypair = Ed25519Keypair.fromSecretKey(secretKey); const suiAddress = keypair.getPublicKey().toSuiAddress(); -const PACKAGE_ADDRESS = `0xadfb946c8c887446d284dae80ac8501c02ec9b9157babb96ca884773bfbb7771`; +const PACKAGE_ADDRESS = `0x83feeef5abcb1d5caca48f5e4e2259f8fbbcac88c10d82cc95ed58ff6f0dcd79`; +const NFT_TYPE = `0x83feeef5abcb1d5caca48f5e4e2259f8fbbcac88c10d82cc95ed58ff6f0dcd79::sui_nft::SuiNFT`; const rpcUrl = getFullnodeUrl("testnet"); const suiClient = new SuiClient({ url: rpcUrl }); /** * Returning Objects: Exercise 1 - * - * In this exercise, you will be returned a new object from a function and must transfer it to an - * address, otherwise, the transaction will abort. - * + * + * In this exercise, you will be returned a new object from a function and must transfer it to an + * address, otherwise, the transaction will abort. + * * When finished, run the following command in the scripts directory to test your solution: - * + * * yarn return-objects - * - * RESOURCES: + * + * RESOURCES: * - https://sdk.mystenlabs.com/typescript/transaction-building/basics#transactions */ const main = async () => { - /** - * Task 1: - * + * Task 1: + * * Create a new Transaction instance from the @mysten/sui/transactions module. */ - /** * Task 2: - * - * Execute the call to the `banana::new` function to the transaction instance. - * - * The target should be in the format {package address}::{module name}::{function name}. The - * package address is provided above. The module name is `banana` and the function name is `new`. - * - * HINT: The arguments and typeArguments arguments are optional since this function does not take + * + * Execute the call to the `sui_nft::new` function to the transaction instance. + * + * The target should be in the format {package address}::{module name}::{function name}. The + * package address is provided above. The module name is `sui_nft` and the function name is `new`. + * + * HINT: The arguments and typeArguments arguments are optional since this function does not take * any arguments or type arguments. */ - /** - * Task 3: - * - * Transfer the newly created banana object to your address. - * + * Task 3: + * + * Transfer the newly created SuiNFT object to your address. + * * Use `tx.transferObjects(objects, address)` - Transfers a list of objects to the specified address. - * + * * HINT: Use `suiAddress`` to transfer the object to your address. */ - - + /** - * Task 4: - * + * Task 4: + * * Sign and execute the transaction using the SuiClient instance created above. - * + * * Print the result to the console. */ - -} +}; -main(); \ No newline at end of file +main(); diff --git a/scripts/src/lessons/scavenger_hunt/exercise.ts b/scripts/src/lessons/scavenger_hunt/exercise.ts new file mode 100644 index 0000000..6b76caf --- /dev/null +++ b/scripts/src/lessons/scavenger_hunt/exercise.ts @@ -0,0 +1,61 @@ +import { Transaction } from "@mysten/sui/transactions"; +import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519"; +import { getFullnodeUrl, SuiClient } from "@mysten/sui/client"; +import { decodeSuiPrivateKey } from "@mysten/sui/cryptography"; +import keyPairJson from "../../../keypair.json"; + +/** + * + * Global variables + * + * These variables are used throughout the exercise below. + * + */ +const { secretKey } = decodeSuiPrivateKey(keyPairJson.privateKey); +const keypair = Ed25519Keypair.fromSecretKey(secretKey); + +const PACKAGE_ADDRESS = `0x25dfcadb5927395b463a426e8d63425d654a6057affc368f4dc176e587f489a5`; +const TEST_BUCK_TYPE = `0x25dfcadb5927395b463a426e8d63425d654a6057affc368f4dc176e587f489a5::test_buck::TEST_BUCK`; + +const rpcUrl = getFullnodeUrl("testnet"); +const suiClient = new SuiClient({ url: rpcUrl }); + +/** + * Scavenger Hunt: Exercise 3 + * + * In this exercise, you use Sui objects as inputs in a PTB to update the value of a shared object. + * + * When finished, run the following command in the scripts directory to test your solution: + * + * yarn scavenger-hunt + * + * RESOURCES: + * - https://sdk.mystenlabs.com/typescript/transaction-building/basics#transactions + */ +const main = async () => { + /** + * Task 1: + * + * Create a new key using the `key::new` function. + */ + + /** + * Task 2: + * + * Set the key code correctly using the `key::set_code` function. + */ + + /** + * Task 3: + * + * Use the key to withdraw the `Bucket USD` coin from the vault using the `vault::withdraw` function. + */ + + /** + * Task 4: + * + * Transfer the `Bucket USD` coin to your account. + */ +}; + +main(); From e26801cc9ecf1aa3b357b891c3514407213b8629 Mon Sep 17 00:00:00 2001 From: EasonC13 Date: Wed, 2 Apr 2025 16:50:16 -0400 Subject: [PATCH 04/21] update README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7c0edac..c28c0a3 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# Sui Object Model Workshop +# Sui Object Model and Programmable Transaction Blocks (PTBs) Workshop When learning Sui Move, developers are encouraged to use best practices to utilize the Sui object model and ensure on-chain object composability. Developers learn to write composable move code in a timely manner, but struggle to verify their code by deploying and executing the functionality on chain. The key to mastering the Sui object model is to pair your Sui move development sessions with interacting with on-chain objects via PTBs (Programmable Transaction Blocks). This workshop will guide you through the process of writing Sui Move code, deploying it to the Sui blockchain, and interacting with on-chain objects via PTBs. # Table of Contents -- [Sui Object Model Workshop](#sui-object-model-workshop) +- [Sui Object Model and Programmable Transaction Blocks (PTBs) Workshop](#sui-object-model-and-programmable-transaction-blocks-ptbs-workshop) - [Table of Contents](#table-of-contents) - [Environment Setup](#environment-setup) - [Lessons](#lessons) From 3c48ca556ba680cb5190658b007d4dcb1abff1df Mon Sep 17 00:00:00 2001 From: EasonC13 Date: Wed, 2 Apr 2025 16:58:44 -0400 Subject: [PATCH 05/21] udpate REDME --- README.md | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index c28c0a3..6a86fea 100644 --- a/README.md +++ b/README.md @@ -7,11 +7,10 @@ When learning Sui Move, developers are encouraged to use best practices to utili - [Table of Contents](#table-of-contents) - [Environment Setup](#environment-setup) - [Lessons](#lessons) - - [Handling Returned Objects](#handling-returned-objects) - - [Exercise](#exercise) - - [Objects as Input](#objects-as-input) - - [Exercise 1: Input Objects - Counter](#exercise-1-input-objects---counter) - - [Exercise 2: Handling Returned Objects with PTBs - SUIIII NFT](#exercise-2-handling-returned-objects-with-ptbs---suiiii-nft) + - [Lesson 1: Handling Returned Objects](#lesson-1-handling-returned-objects) + - [Exercise 1: Handling Returned Sui NFT](#exercise-1-handling-returned-sui-nft) + - [Lesson 2: Objects as Input](#lesson-2-objects-as-input) + - [Exercise 2: Input Objects - Counter](#exercise-2-input-objects---counter) - [Exercise 3: Scavenger Hunting with PTBs](#exercise-3-scavenger-hunting-with-ptbs) # Environment Setup @@ -31,7 +30,7 @@ Sui Faucet: [https://faucet.sui.io/](https://faucet.sui.io/) OR [Discord faucet] # Lessons -## Handling Returned Objects +## Lesson 1: Handling Returned Objects One of the best practices when writing Sui Move packages is to avoid self-transfers. In other words, avoid transferring objects to the sender of the transaction, and instead return the object from the current function. This allows a caller or programmable transaction block to use the object however they see fit. @@ -75,11 +74,22 @@ This is easy enough to do, but in most cases (when the object doesn't have the [ In this lesson, you learn how to handle returned objects properly. -### Exercise -View the contents [`banana.move`](./lessons/returning_objects/banana_without_display/sources/banana_without_display.move). There is a deployed instance of this package on the Sui blockchain. The address of the package is [`0xadfb946c8c887446d284dae80ac8501c02ec9b9157babb96ca884773bfbb7771`](https://suiscan.xyz/testnet/object/0xadfb946c8c887446d284dae80ac8501c02ec9b9157babb96ca884773bfbb7771/txs). Navigate to [`scripts/lessons/return_objects/exercise.ts`](./scripts/src/lessons/return_objects/exercise.ts) and complete the exercise. -## Objects as Input +### Exercise 1: Handling Returned Sui NFT + + +The package of the SUIII NFT is at [`0x83feeef5abcb1d5caca48f5e4e2259f8fbbcac88c10d82cc95ed58ff6f0dcd79`](https://suiscan.xyz/testnet/object/0x83feeef5abcb1d5caca48f5e4e2259f8fbbcac88c10d82cc95ed58ff6f0dcd79/tx-blocks) and the NFT object type is [`0x83feeef5abcb1d5caca48f5e4e2259f8fbbcac88c10d82cc95ed58ff6f0dcd79::sui_nft::SuiNFT`](https://suiscan.xyz/testnet/collection/0x83feeef5abcb1d5caca48f5e4e2259f8fbbcac88c10d82cc95ed58ff6f0dcd79::sui_nft::SuiNFT/items). + + +View the contract at [`sui_nft.move`](./lessons/returning_objects/sui_nft/sources/sui_nft.move). Try to mint an NFT to your account and view it at explorer with PTBs. + +Navigate to [`scripts/lessons/return_objects/exercise.ts`](./scripts/src/lessons/return_objects/exercise.ts) and complete the exercise. + +> Bonus Challenge: Can you deploy the [SUIII NFT package](./lessons/returning_objects/sui_nft) yourself and use different text and images for the NFT? +> [Install the Sui CLI](https://docs.sui.io/guides/developer/getting-started/sui-install), [Create Deployer Address](https://docs.sui.io/guides/developer/getting-started/get-address), and deposit gas coins from faucet, then use `sui client publish --skip-dependency-verification` to deploy! + +## Lesson 2: Objects as Input There are a lot of situations where one will want to interact with objects on Sui. Referencing and using objects in Sui Move is simple but nuanced. To reference an object in Sui Move, make the object a function parameter. For example, @@ -109,23 +119,13 @@ The `delete` function receives the actual instance of the `SimpleObject` and del This usage is straightforward, but tends to leave developers wondering what this looks out in a wider context. In this lesson, you learn how to use objects as inputs in PTBs. -### Exercise 1: Input Objects - Counter +### Exercise 2: Input Objects - Counter View the contents [`counter.move`](./lessons/input_objects/counter/sources/counter.move). There is a deployed instance of this package on the Sui blockchain. The address of the package is [`0xad3225e7d4827f81dc0686177067e1b458e8468ceabcff3456888ce3d806eb8c`](https://suiscan.xyz/testnet/object/0xad3225e7d4827f81dc0686177067e1b458e8468ceabcff3456888ce3d806eb8c/txs) and the counter object is [0x1feb03541d20064d1876c26cfa44514f2e029c8201a2fe12a60589842b9d391d](https://suiscan.xyz/testnet/object/0x1feb03541d20064d1876c26cfa44514f2e029c8201a2fe12a60589842b9d391d/fields). Navigate to [`scripts/lessons/input_objects/exercise.ts`](./scripts/src/lessons/input_objects/exercise.ts) and complete the exercise. -### Exercise 2: Handling Returned Objects with PTBs - SUIIII NFT - -The package of the SUIII NFT is at [`0x83feeef5abcb1d5caca48f5e4e2259f8fbbcac88c10d82cc95ed58ff6f0dcd79`](https://suiscan.xyz/testnet/object/0x83feeef5abcb1d5caca48f5e4e2259f8fbbcac88c10d82cc95ed58ff6f0dcd79/tx-blocks) and the NFT object type is [`0x83feeef5abcb1d5caca48f5e4e2259f8fbbcac88c10d82cc95ed58ff6f0dcd79::sui_nft::SuiNFT`](https://suiscan.xyz/testnet/collection/0x83feeef5abcb1d5caca48f5e4e2259f8fbbcac88c10d82cc95ed58ff6f0dcd79::sui_nft::SuiNFT/items). - - -View the contract at [`sui_nft.move`](./lessons/returning_objects/sui_nft/sources/sui_nft.move). Try to mint an NFT to your account and view it at explorer with PTBs. - -Navigate to [`scripts/lessons/return_objects/exercise.ts`](./scripts/src/lessons/return_objects/exercise.ts) and complete the exercise. - -> Bonus Challenge: Can you deploy the [SUIII NFT package](./lessons/returning_objects/sui_nft) yourself and use different text and images for the NFT? ### Exercise 3: Scavenger Hunting with PTBs From 7bd48a212c2bff4203eca823eeb309d7f18d7c36 Mon Sep 17 00:00:00 2001 From: EasonC13 Date: Wed, 2 Apr 2025 17:00:07 -0400 Subject: [PATCH 06/21] update README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6a86fea..ff280dc 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# Sui Object Model and Programmable Transaction Blocks (PTBs) Workshop +# Sui Object Model and PTBs Workshop When learning Sui Move, developers are encouraged to use best practices to utilize the Sui object model and ensure on-chain object composability. Developers learn to write composable move code in a timely manner, but struggle to verify their code by deploying and executing the functionality on chain. The key to mastering the Sui object model is to pair your Sui move development sessions with interacting with on-chain objects via PTBs (Programmable Transaction Blocks). This workshop will guide you through the process of writing Sui Move code, deploying it to the Sui blockchain, and interacting with on-chain objects via PTBs. # Table of Contents -- [Sui Object Model and Programmable Transaction Blocks (PTBs) Workshop](#sui-object-model-and-programmable-transaction-blocks-ptbs-workshop) +- [Sui Object Model and PTBs Workshop](#sui-object-model-and-ptbs-workshop) - [Table of Contents](#table-of-contents) - [Environment Setup](#environment-setup) - [Lessons](#lessons) From 20ac44df0df3ffb218942de3c629f352a9433c31 Mon Sep 17 00:00:00 2001 From: Eason Chen <43432631+EasonC13@users.noreply.github.com> Date: Thu, 3 Apr 2025 08:17:46 +0900 Subject: [PATCH 07/21] Update README.md --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ff280dc..2561027 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,10 @@ When learning Sui Move, developers are encouraged to use best practices to utili Before we start, we need to set up our environment. +```bash +yarn install +``` + Navigate to the `scripts` directory and run the following command: ```bash @@ -139,4 +143,4 @@ You will need to create a PTB to: 3. Use the key to withdraw the `Bucket USD` coin from the vault 4. Transfer the `Bucket USD` coin to your account -Navigate to [`scripts/lessons/scavenger_hunt/exercise.ts`](./scripts/src/lessons/scavenger_hunt/exercise.ts) and complete the exercise. \ No newline at end of file +Navigate to [`scripts/lessons/scavenger_hunt/exercise.ts`](./scripts/src/lessons/scavenger_hunt/exercise.ts) and complete the exercise. From 89aa1295b8fac675a44f73ec4207fda79460213f Mon Sep 17 00:00:00 2001 From: Eason Chen <43432631+EasonC13@users.noreply.github.com> Date: Thu, 3 Apr 2025 08:17:58 +0900 Subject: [PATCH 08/21] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2561027..ae44775 100644 --- a/README.md +++ b/README.md @@ -18,13 +18,13 @@ When learning Sui Move, developers are encouraged to use best practices to utili Before we start, we need to set up our environment. ```bash -yarn install +npm install ``` Navigate to the `scripts` directory and run the following command: ```bash -yarn init-keypair +npm run init-keypair ``` This will generate and fund a new keypair for you to use in the workshop. Make sure not to use this keypair in any production environments. From 9151d992192b1c5180865d6118751c3e1db5c2e3 Mon Sep 17 00:00:00 2001 From: EasonC13 Date: Wed, 2 Apr 2025 19:20:50 -0400 Subject: [PATCH 09/21] update README --- scripts/package-lock.json | 424 ++++++++++++++++++++++++++++++++++++++ scripts/yarn.lock | 84 ++++---- 2 files changed, 466 insertions(+), 42 deletions(-) create mode 100644 scripts/package-lock.json diff --git a/scripts/package-lock.json b/scripts/package-lock.json new file mode 100644 index 0000000..fd4335d --- /dev/null +++ b/scripts/package-lock.json @@ -0,0 +1,424 @@ +{ + "name": "scripts", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "scripts", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "@mysten/sui": "^1.8.0", + "dotenv": "^16.4.5" + }, + "devDependencies": { + "@types/node": "^22.5.2", + "ts-node": "^10.9.2", + "typescript": "^5.5.4" + } + }, + "node_modules/@0no-co/graphql.web": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@0no-co/graphql.web/-/graphql.web-1.1.2.tgz", + "integrity": "sha512-N2NGsU5FLBhT8NZ+3l2YrzZSHITjNXNuDhC4iDiikv0IujaJ0Xc6xIxQZ/Ek3Cb+rgPjnLHYyJm11tInuJn+cw==", + "peerDependencies": { + "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0" + }, + "peerDependenciesMeta": { + "graphql": { + "optional": true + } + } + }, + "node_modules/@0no-co/graphqlsp": { + "version": "1.12.16", + "resolved": "https://registry.npmjs.org/@0no-co/graphqlsp/-/graphqlsp-1.12.16.tgz", + "integrity": "sha512-B5pyYVH93Etv7xjT6IfB7QtMBdaaC07yjbhN6v8H7KgFStMkPvi+oWYBTibMFRMY89qwc9H8YixXg8SXDVgYWw==", + "dependencies": { + "@gql.tada/internal": "^1.0.0", + "graphql": "^15.5.0 || ^16.0.0 || ^17.0.0" + }, + "peerDependencies": { + "graphql": "^15.5.0 || ^16.0.0 || ^17.0.0", + "typescript": "^5.0.0" + } + }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@gql.tada/cli-utils": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/@gql.tada/cli-utils/-/cli-utils-1.6.3.tgz", + "integrity": "sha512-jFFSY8OxYeBxdKi58UzeMXG1tdm4FVjXa8WHIi66Gzu9JWtCE6mqom3a8xkmSw+mVaybFW5EN2WXf1WztJVNyQ==", + "dependencies": { + "@0no-co/graphqlsp": "^1.12.13", + "@gql.tada/internal": "1.0.8", + "graphql": "^15.5.0 || ^16.0.0 || ^17.0.0" + }, + "peerDependencies": { + "@0no-co/graphqlsp": "^1.12.13", + "@gql.tada/svelte-support": "1.0.1", + "@gql.tada/vue-support": "1.0.1", + "graphql": "^15.5.0 || ^16.0.0 || ^17.0.0", + "typescript": "^5.0.0" + }, + "peerDependenciesMeta": { + "@gql.tada/svelte-support": { + "optional": true + }, + "@gql.tada/vue-support": { + "optional": true + } + } + }, + "node_modules/@gql.tada/internal": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@gql.tada/internal/-/internal-1.0.8.tgz", + "integrity": "sha512-XYdxJhtHC5WtZfdDqtKjcQ4d7R1s0d1rnlSs3OcBEUbYiPoJJfZU7tWsVXuv047Z6msvmr4ompJ7eLSK5Km57g==", + "dependencies": { + "@0no-co/graphql.web": "^1.0.5" + }, + "peerDependencies": { + "graphql": "^15.5.0 || ^16.0.0 || ^17.0.0", + "typescript": "^5.0.0" + } + }, + "node_modules/@graphql-typed-document-node/core": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@graphql-typed-document-node/core/-/core-3.2.0.tgz", + "integrity": "sha512-mB9oAsNCm9aM3/SOv4YtBMqZbYj10R7dkq8byBqxGY/ncFwhf2oQzMV+LCRlWoDSEBJ3COiR1yeDvMtsoOsuFQ==", + "peerDependencies": { + "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", + "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", + "dev": true + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, + "node_modules/@mysten/bcs": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@mysten/bcs/-/bcs-1.6.0.tgz", + "integrity": "sha512-ydDRYdIkIFCpHCcPvAkMC91fVwumjzbTgjqds0KsphDQI3jUlH3jFG5lfYNTmV6V3pkhOiRk1fupLBcsQsiszg==", + "dependencies": { + "@scure/base": "^1.2.4" + } + }, + "node_modules/@mysten/sui": { + "version": "1.26.1", + "resolved": "https://registry.npmjs.org/@mysten/sui/-/sui-1.26.1.tgz", + "integrity": "sha512-bBVvn2wZKipAvuUkKzHwGhs1JiIM33+b97d0uIWg3T6dJH/n1nfnGrzkBQsMGpoBAFOIUnKQAZmDwT4qvJbKkg==", + "dependencies": { + "@graphql-typed-document-node/core": "^3.2.0", + "@mysten/bcs": "1.6.0", + "@noble/curves": "^1.8.1", + "@noble/hashes": "^1.7.1", + "@scure/base": "^1.2.4", + "@scure/bip32": "^1.6.2", + "@scure/bip39": "^1.5.4", + "gql.tada": "^1.8.2", + "graphql": "^16.9.0", + "poseidon-lite": "^0.2.0", + "valibot": "^0.36.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@noble/curves": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.8.1.tgz", + "integrity": "sha512-warwspo+UYUPep0Q+vtdVB4Ugn8GGQj8iyB3gnRWsztmUHTI3S1nhdiWNsPUGL0vud7JlRRk1XEu7Lq1KGTnMQ==", + "dependencies": { + "@noble/hashes": "1.7.1" + }, + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@noble/hashes": { + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.7.1.tgz", + "integrity": "sha512-B8XBPsn4vT/KJAGqDzbwztd+6Yte3P4V7iafm24bxgDe/mlRuK6xmWPuCNrKt2vDafZ8MfJLlchDG/vYafQEjQ==", + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@scure/base": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.2.4.tgz", + "integrity": "sha512-5Yy9czTO47mqz+/J8GM6GIId4umdCk1wc1q8rKERQulIoc8VP9pzDcghv10Tl2E7R96ZUx/PhND3ESYUQX8NuQ==", + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@scure/bip32": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/@scure/bip32/-/bip32-1.6.2.tgz", + "integrity": "sha512-t96EPDMbtGgtb7onKKqxRLfE5g05k7uHnHRM2xdE6BP/ZmxaLtPek4J4KfVn/90IQNrU1IOAqMgiDtUdtbe3nw==", + "dependencies": { + "@noble/curves": "~1.8.1", + "@noble/hashes": "~1.7.1", + "@scure/base": "~1.2.2" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@scure/bip39": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/@scure/bip39/-/bip39-1.5.4.tgz", + "integrity": "sha512-TFM4ni0vKvCfBpohoh+/lY05i9gRbSwXWngAsF4CABQxoaOHijxuaZ2R6cStDQ5CHtHO9aGJTr4ksVJASRRyMA==", + "dependencies": { + "@noble/hashes": "~1.7.1", + "@scure/base": "~1.2.4" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@tsconfig/node10": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", + "integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==", + "dev": true + }, + "node_modules/@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", + "dev": true + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", + "dev": true + }, + "node_modules/@tsconfig/node16": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", + "dev": true + }, + "node_modules/@types/node": { + "version": "22.14.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.14.0.tgz", + "integrity": "sha512-Kmpl+z84ILoG+3T/zQFyAJsU6EPTmOCj8/2+83fSN6djd6I4o7uOuGIH6vq3PrjY5BGitSbFuMN18j3iknubbA==", + "dev": true, + "dependencies": { + "undici-types": "~6.21.0" + } + }, + "node_modules/acorn": { + "version": "8.14.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.1.tgz", + "integrity": "sha512-OvQ/2pUDKmgfCg++xsTX1wGxfTaszcHVcTctW4UJB4hibJx2HXxxO5UmVgyjMa+ZDsiaf5wWLXYpRWMmBI0QHg==", + "dev": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-walk": { + "version": "8.3.4", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.4.tgz", + "integrity": "sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==", + "dev": true, + "dependencies": { + "acorn": "^8.11.0" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true + }, + "node_modules/create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true + }, + "node_modules/diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/dotenv": { + "version": "16.4.7", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.7.tgz", + "integrity": "sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/gql.tada": { + "version": "1.8.10", + "resolved": "https://registry.npmjs.org/gql.tada/-/gql.tada-1.8.10.tgz", + "integrity": "sha512-FrvSxgz838FYVPgZHGOSgbpOjhR+yq44rCzww3oOPJYi0OvBJjAgCiP6LEokZIYND2fUTXzQAyLgcvgw1yNP5A==", + "dependencies": { + "@0no-co/graphql.web": "^1.0.5", + "@0no-co/graphqlsp": "^1.12.13", + "@gql.tada/cli-utils": "1.6.3", + "@gql.tada/internal": "1.0.8" + }, + "bin": { + "gql-tada": "bin/cli.js", + "gql.tada": "bin/cli.js" + }, + "peerDependencies": { + "typescript": "^5.0.0" + } + }, + "node_modules/graphql": { + "version": "16.10.0", + "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.10.0.tgz", + "integrity": "sha512-AjqGKbDGUFRKIRCP9tCKiIGHyriz2oHEbPIbEtcSLSs4YjReZOIPQQWek4+6hjw62H9QShXHyaGivGiYVLeYFQ==", + "engines": { + "node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0" + } + }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true + }, + "node_modules/poseidon-lite": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/poseidon-lite/-/poseidon-lite-0.2.1.tgz", + "integrity": "sha512-xIr+G6HeYfOhCuswdqcFpSX47SPhm0EpisWJ6h7fHlWwaVIvH3dLnejpatrtw6Xc6HaLrpq05y7VRfvDmDGIog==" + }, + "node_modules/ts-node": { + "version": "10.9.2", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", + "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", + "dev": true, + "dependencies": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-esm": "dist/bin-esm.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "peerDependencies": { + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", + "@types/node": "*", + "typescript": ">=2.7" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "@swc/wasm": { + "optional": true + } + } + }, + "node_modules/typescript": { + "version": "5.8.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.2.tgz", + "integrity": "sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ==", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "dev": true + }, + "node_modules/v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "dev": true + }, + "node_modules/valibot": { + "version": "0.36.0", + "resolved": "https://registry.npmjs.org/valibot/-/valibot-0.36.0.tgz", + "integrity": "sha512-CjF1XN4sUce8sBK9TixrDqFM7RwNkuXdJu174/AwmQUB62QbCQADg5lLe8ldBalFgtj1uKj+pKwDJiNo4Mn+eQ==" + }, + "node_modules/yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true, + "engines": { + "node": ">=6" + } + } + } +} diff --git a/scripts/yarn.lock b/scripts/yarn.lock index b15c397..1957b47 100644 --- a/scripts/yarn.lock +++ b/scripts/yarn.lock @@ -4,12 +4,12 @@ "@0no-co/graphql.web@^1.0.5": version "1.1.2" - resolved "https://registry.yarnpkg.com/@0no-co/graphql.web/-/graphql.web-1.1.2.tgz#9af8deaf3f236c1c6ee99cc5349051475e5dcc83" + resolved "https://registry.npmjs.org/@0no-co/graphql.web/-/graphql.web-1.1.2.tgz" integrity sha512-N2NGsU5FLBhT8NZ+3l2YrzZSHITjNXNuDhC4iDiikv0IujaJ0Xc6xIxQZ/Ek3Cb+rgPjnLHYyJm11tInuJn+cw== "@0no-co/graphqlsp@^1.12.13": version "1.12.16" - resolved "https://registry.yarnpkg.com/@0no-co/graphqlsp/-/graphqlsp-1.12.16.tgz#58fe7bad53b3ad9fdf2d5f41ddeb9b418d289a03" + resolved "https://registry.npmjs.org/@0no-co/graphqlsp/-/graphqlsp-1.12.16.tgz" integrity sha512-B5pyYVH93Etv7xjT6IfB7QtMBdaaC07yjbhN6v8H7KgFStMkPvi+oWYBTibMFRMY89qwc9H8YixXg8SXDVgYWw== dependencies: "@gql.tada/internal" "^1.0.0" @@ -17,45 +17,45 @@ "@cspotcode/source-map-support@^0.8.0": version "0.8.1" - resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz#00629c35a688e05a88b1cda684fb9d5e73f000a1" + resolved "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz" integrity sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw== dependencies: "@jridgewell/trace-mapping" "0.3.9" "@gql.tada/cli-utils@1.6.3": version "1.6.3" - resolved "https://registry.yarnpkg.com/@gql.tada/cli-utils/-/cli-utils-1.6.3.tgz#b893cec74908da4df0602691e2e0b1497fda8cda" + resolved "https://registry.npmjs.org/@gql.tada/cli-utils/-/cli-utils-1.6.3.tgz" integrity sha512-jFFSY8OxYeBxdKi58UzeMXG1tdm4FVjXa8WHIi66Gzu9JWtCE6mqom3a8xkmSw+mVaybFW5EN2WXf1WztJVNyQ== dependencies: "@0no-co/graphqlsp" "^1.12.13" "@gql.tada/internal" "1.0.8" graphql "^15.5.0 || ^16.0.0 || ^17.0.0" -"@gql.tada/internal@1.0.8", "@gql.tada/internal@^1.0.0": +"@gql.tada/internal@^1.0.0", "@gql.tada/internal@1.0.8": version "1.0.8" - resolved "https://registry.yarnpkg.com/@gql.tada/internal/-/internal-1.0.8.tgz#3ba9fa6534809788bbbe103492f70b8e9d754027" + resolved "https://registry.npmjs.org/@gql.tada/internal/-/internal-1.0.8.tgz" integrity sha512-XYdxJhtHC5WtZfdDqtKjcQ4d7R1s0d1rnlSs3OcBEUbYiPoJJfZU7tWsVXuv047Z6msvmr4ompJ7eLSK5Km57g== dependencies: "@0no-co/graphql.web" "^1.0.5" "@graphql-typed-document-node/core@^3.2.0": version "3.2.0" - resolved "https://registry.yarnpkg.com/@graphql-typed-document-node/core/-/core-3.2.0.tgz#5f3d96ec6b2354ad6d8a28bf216a1d97b5426861" + resolved "https://registry.npmjs.org/@graphql-typed-document-node/core/-/core-3.2.0.tgz" integrity sha512-mB9oAsNCm9aM3/SOv4YtBMqZbYj10R7dkq8byBqxGY/ncFwhf2oQzMV+LCRlWoDSEBJ3COiR1yeDvMtsoOsuFQ== "@jridgewell/resolve-uri@^3.0.3": version "3.1.2" - resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz#7a0ee601f60f99a20c7c7c5ff0c80388c1189bd6" + resolved "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz" integrity sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw== "@jridgewell/sourcemap-codec@^1.4.10": version "1.5.0" - resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz#3188bcb273a414b0d215fd22a58540b989b9409a" + resolved "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz" integrity sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ== "@jridgewell/trace-mapping@0.3.9": version "0.3.9" - resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz#6534fd5933a53ba7cbf3a17615e273a0d1273ff9" + resolved "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz" integrity sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ== dependencies: "@jridgewell/resolve-uri" "^3.0.3" @@ -63,14 +63,14 @@ "@mysten/bcs@1.6.0": version "1.6.0" - resolved "https://registry.yarnpkg.com/@mysten/bcs/-/bcs-1.6.0.tgz#ccd7153cef7a83a402724c8fb3b2603323a4aedc" + resolved "https://registry.npmjs.org/@mysten/bcs/-/bcs-1.6.0.tgz" integrity sha512-ydDRYdIkIFCpHCcPvAkMC91fVwumjzbTgjqds0KsphDQI3jUlH3jFG5lfYNTmV6V3pkhOiRk1fupLBcsQsiszg== dependencies: "@scure/base" "^1.2.4" "@mysten/sui@^1.8.0": version "1.26.1" - resolved "https://registry.yarnpkg.com/@mysten/sui/-/sui-1.26.1.tgz#1f60709fe310868f051635940fe545e2e2ce2a2f" + resolved "https://registry.npmjs.org/@mysten/sui/-/sui-1.26.1.tgz" integrity sha512-bBVvn2wZKipAvuUkKzHwGhs1JiIM33+b97d0uIWg3T6dJH/n1nfnGrzkBQsMGpoBAFOIUnKQAZmDwT4qvJbKkg== dependencies: "@graphql-typed-document-node/core" "^3.2.0" @@ -87,24 +87,24 @@ "@noble/curves@^1.8.1", "@noble/curves@~1.8.1": version "1.8.1" - resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.8.1.tgz#19bc3970e205c99e4bdb1c64a4785706bce497ff" + resolved "https://registry.npmjs.org/@noble/curves/-/curves-1.8.1.tgz" integrity sha512-warwspo+UYUPep0Q+vtdVB4Ugn8GGQj8iyB3gnRWsztmUHTI3S1nhdiWNsPUGL0vud7JlRRk1XEu7Lq1KGTnMQ== dependencies: "@noble/hashes" "1.7.1" -"@noble/hashes@1.7.1", "@noble/hashes@^1.7.1", "@noble/hashes@~1.7.1": +"@noble/hashes@^1.7.1", "@noble/hashes@~1.7.1", "@noble/hashes@1.7.1": version "1.7.1" - resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.7.1.tgz#5738f6d765710921e7a751e00c20ae091ed8db0f" + resolved "https://registry.npmjs.org/@noble/hashes/-/hashes-1.7.1.tgz" integrity sha512-B8XBPsn4vT/KJAGqDzbwztd+6Yte3P4V7iafm24bxgDe/mlRuK6xmWPuCNrKt2vDafZ8MfJLlchDG/vYafQEjQ== "@scure/base@^1.2.4", "@scure/base@~1.2.2", "@scure/base@~1.2.4": version "1.2.4" - resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.2.4.tgz#002eb571a35d69bdb4c214d0995dff76a8dcd2a9" + resolved "https://registry.npmjs.org/@scure/base/-/base-1.2.4.tgz" integrity sha512-5Yy9czTO47mqz+/J8GM6GIId4umdCk1wc1q8rKERQulIoc8VP9pzDcghv10Tl2E7R96ZUx/PhND3ESYUQX8NuQ== "@scure/bip32@^1.6.2": version "1.6.2" - resolved "https://registry.yarnpkg.com/@scure/bip32/-/bip32-1.6.2.tgz#093caa94961619927659ed0e711a6e4bf35bffd0" + resolved "https://registry.npmjs.org/@scure/bip32/-/bip32-1.6.2.tgz" integrity sha512-t96EPDMbtGgtb7onKKqxRLfE5g05k7uHnHRM2xdE6BP/ZmxaLtPek4J4KfVn/90IQNrU1IOAqMgiDtUdtbe3nw== dependencies: "@noble/curves" "~1.8.1" @@ -113,7 +113,7 @@ "@scure/bip39@^1.5.4": version "1.5.4" - resolved "https://registry.yarnpkg.com/@scure/bip39/-/bip39-1.5.4.tgz#07fd920423aa671be4540d59bdd344cc1461db51" + resolved "https://registry.npmjs.org/@scure/bip39/-/bip39-1.5.4.tgz" integrity sha512-TFM4ni0vKvCfBpohoh+/lY05i9gRbSwXWngAsF4CABQxoaOHijxuaZ2R6cStDQ5CHtHO9aGJTr4ksVJASRRyMA== dependencies: "@noble/hashes" "~1.7.1" @@ -121,66 +121,66 @@ "@tsconfig/node10@^1.0.7": version "1.0.11" - resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.11.tgz#6ee46400685f130e278128c7b38b7e031ff5b2f2" + resolved "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz" integrity sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw== "@tsconfig/node12@^1.0.7": version "1.0.11" - resolved "https://registry.yarnpkg.com/@tsconfig/node12/-/node12-1.0.11.tgz#ee3def1f27d9ed66dac6e46a295cffb0152e058d" + resolved "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz" integrity sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag== "@tsconfig/node14@^1.0.0": version "1.0.3" - resolved "https://registry.yarnpkg.com/@tsconfig/node14/-/node14-1.0.3.tgz#e4386316284f00b98435bf40f72f75a09dabf6c1" + resolved "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz" integrity sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow== "@tsconfig/node16@^1.0.2": version "1.0.4" - resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.4.tgz#0b92dcc0cc1c81f6f306a381f28e31b1a56536e9" + resolved "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz" integrity sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA== -"@types/node@^22.5.2": +"@types/node@*", "@types/node@^22.5.2": version "22.14.0" - resolved "https://registry.yarnpkg.com/@types/node/-/node-22.14.0.tgz#d3bfa3936fef0dbacd79ea3eb17d521c628bb47e" + resolved "https://registry.npmjs.org/@types/node/-/node-22.14.0.tgz" integrity sha512-Kmpl+z84ILoG+3T/zQFyAJsU6EPTmOCj8/2+83fSN6djd6I4o7uOuGIH6vq3PrjY5BGitSbFuMN18j3iknubbA== dependencies: undici-types "~6.21.0" acorn-walk@^8.1.1: version "8.3.4" - resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.3.4.tgz#794dd169c3977edf4ba4ea47583587c5866236b7" + resolved "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.4.tgz" integrity sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g== dependencies: acorn "^8.11.0" acorn@^8.11.0, acorn@^8.4.1: version "8.14.1" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.14.1.tgz#721d5dc10f7d5b5609a891773d47731796935dfb" + resolved "https://registry.npmjs.org/acorn/-/acorn-8.14.1.tgz" integrity sha512-OvQ/2pUDKmgfCg++xsTX1wGxfTaszcHVcTctW4UJB4hibJx2HXxxO5UmVgyjMa+ZDsiaf5wWLXYpRWMmBI0QHg== arg@^4.1.0: version "4.1.3" - resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" + resolved "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz" integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== create-require@^1.1.0: version "1.1.1" - resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333" + resolved "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz" integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ== diff@^4.0.1: version "4.0.2" - resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" + resolved "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz" integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== dotenv@^16.4.5: version "16.4.7" - resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.4.7.tgz#0e20c5b82950140aa99be360a8a5f52335f53c26" + resolved "https://registry.npmjs.org/dotenv/-/dotenv-16.4.7.tgz" integrity sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ== gql.tada@^1.8.2: version "1.8.10" - resolved "https://registry.yarnpkg.com/gql.tada/-/gql.tada-1.8.10.tgz#096a1b30d3c6fc74212fe07d507f01a4095f7f67" + resolved "https://registry.npmjs.org/gql.tada/-/gql.tada-1.8.10.tgz" integrity sha512-FrvSxgz838FYVPgZHGOSgbpOjhR+yq44rCzww3oOPJYi0OvBJjAgCiP6LEokZIYND2fUTXzQAyLgcvgw1yNP5A== dependencies: "@0no-co/graphql.web" "^1.0.5" @@ -188,24 +188,24 @@ gql.tada@^1.8.2: "@gql.tada/cli-utils" "1.6.3" "@gql.tada/internal" "1.0.8" -"graphql@^15.5.0 || ^16.0.0 || ^17.0.0", graphql@^16.9.0: +"graphql@^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0", "graphql@^14.0.0 || ^15.0.0 || ^16.0.0", "graphql@^15.5.0 || ^16.0.0 || ^17.0.0", graphql@^16.9.0: version "16.10.0" - resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.10.0.tgz#24c01ae0af6b11ea87bf55694429198aaa8e220c" + resolved "https://registry.npmjs.org/graphql/-/graphql-16.10.0.tgz" integrity sha512-AjqGKbDGUFRKIRCP9tCKiIGHyriz2oHEbPIbEtcSLSs4YjReZOIPQQWek4+6hjw62H9QShXHyaGivGiYVLeYFQ== make-error@^1.1.1: version "1.3.6" - resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" + resolved "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz" integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== poseidon-lite@^0.2.0: version "0.2.1" - resolved "https://registry.yarnpkg.com/poseidon-lite/-/poseidon-lite-0.2.1.tgz#7ad98e3a3aa5b91a1fd3a61a87460e9e46fd76d6" + resolved "https://registry.npmjs.org/poseidon-lite/-/poseidon-lite-0.2.1.tgz" integrity sha512-xIr+G6HeYfOhCuswdqcFpSX47SPhm0EpisWJ6h7fHlWwaVIvH3dLnejpatrtw6Xc6HaLrpq05y7VRfvDmDGIog== ts-node@^10.9.2: version "10.9.2" - resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.2.tgz#70f021c9e185bccdca820e26dc413805c101c71f" + resolved "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz" integrity sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ== dependencies: "@cspotcode/source-map-support" "^0.8.0" @@ -222,27 +222,27 @@ ts-node@^10.9.2: v8-compile-cache-lib "^3.0.1" yn "3.1.1" -typescript@^5.5.4: +typescript@^5.0.0, typescript@^5.5.4, typescript@>=2.7: version "5.8.2" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.8.2.tgz#8170b3702f74b79db2e5a96207c15e65807999e4" + resolved "https://registry.npmjs.org/typescript/-/typescript-5.8.2.tgz" integrity sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ== undici-types@~6.21.0: version "6.21.0" - resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.21.0.tgz#691d00af3909be93a7faa13be61b3a5b50ef12cb" + resolved "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz" integrity sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ== v8-compile-cache-lib@^3.0.1: version "3.0.1" - resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz#6336e8d71965cb3d35a1bbb7868445a7c05264bf" + resolved "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz" integrity sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg== valibot@^0.36.0: version "0.36.0" - resolved "https://registry.yarnpkg.com/valibot/-/valibot-0.36.0.tgz#74e746694b1abcc1879e4393db551d4ce1e10578" + resolved "https://registry.npmjs.org/valibot/-/valibot-0.36.0.tgz" integrity sha512-CjF1XN4sUce8sBK9TixrDqFM7RwNkuXdJu174/AwmQUB62QbCQADg5lLe8ldBalFgtj1uKj+pKwDJiNo4Mn+eQ== yn@3.1.1: version "3.1.1" - resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" + resolved "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz" integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q== From f84c6708a1a9ec3e460d1d8ff404aa2e7c2d1935 Mon Sep 17 00:00:00 2001 From: EasonC13 Date: Wed, 2 Apr 2025 19:20:58 -0400 Subject: [PATCH 10/21] update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ae44775..a5175c7 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ When learning Sui Move, developers are encouraged to use best practices to utili Before we start, we need to set up our environment. ```bash -npm install +cd scripts && npm install ``` Navigate to the `scripts` directory and run the following command: From bae88a7917e92b00e3a7d84b2d76b5ec73a480a9 Mon Sep 17 00:00:00 2001 From: EasonC13 Date: Wed, 2 Apr 2025 19:42:26 -0400 Subject: [PATCH 11/21] update exercise 1 answer --- scripts/src/lessons/return_objects/exercise.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/scripts/src/lessons/return_objects/exercise.ts b/scripts/src/lessons/return_objects/exercise.ts index 95533e7..50fb3ba 100644 --- a/scripts/src/lessons/return_objects/exercise.ts +++ b/scripts/src/lessons/return_objects/exercise.ts @@ -40,6 +40,7 @@ const main = async () => { * * Create a new Transaction instance from the @mysten/sui/transactions module. */ + const tx = new Transaction(); /** * Task 2: @@ -53,6 +54,10 @@ const main = async () => { * any arguments or type arguments. */ + const nft = tx.moveCall({ + target: `${PACKAGE_ADDRESS}::sui_nft::new`, + }); + /** * Task 3: * @@ -62,7 +67,9 @@ const main = async () => { * * HINT: Use `suiAddress`` to transfer the object to your address. */ - + + tx.transferObjects([nft], suiAddress); + /** * Task 4: * @@ -70,6 +77,12 @@ const main = async () => { * * Print the result to the console. */ + + const result = await suiClient.signAndExecuteTransaction({ + transaction: tx, + signer: keypair, + }); + console.log(result); }; main(); From 4e21290c543c77f635c63fe51cc237f328771f71 Mon Sep 17 00:00:00 2001 From: Eason Chen <43432631+EasonC13@users.noreply.github.com> Date: Thu, 3 Apr 2025 10:11:57 +0900 Subject: [PATCH 12/21] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a5175c7..bbbb118 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ When learning Sui Move, developers are encouraged to use best practices to utili # Environment Setup -Before we start, we need to set up our environment. +Before we start, we need to set up our environment for our scripts. ```bash cd scripts && npm install From 0565e19bcdedba5fdd8c07387e05f80921f4d43b Mon Sep 17 00:00:00 2001 From: EasonC13 Date: Wed, 2 Apr 2025 21:44:36 -0400 Subject: [PATCH 13/21] update tasks --- .../counter/sources/counter.move | 110 +++++++++++------- scripts/src/lessons/input_objects/exercise.ts | 90 +++++++++----- .../src/lessons/return_objects/exercise.ts | 12 +- .../src/lessons/scavenger_hunt/exercise.ts | 54 ++++++++- 4 files changed, 187 insertions(+), 79 deletions(-) diff --git a/lessons/input_objects/counter/sources/counter.move b/lessons/input_objects/counter/sources/counter.move index 7f89cc8..a5fd135 100644 --- a/lessons/input_objects/counter/sources/counter.move +++ b/lessons/input_objects/counter/sources/counter.move @@ -1,41 +1,73 @@ module counter::counter { + use sui::sui::SUI; + use sui::coin; + use sui::balance; - /* - Struct for defining the Counter object type - - Abilities: - - key: allows this type to be an object on Sui - - Attributes: - - id: The object id of this object (required when using key ability) - - count: The current value of the counter - - Further reading: - - key ability: https://move-book.com/storage/key-ability.html?highlight=key#the-key-ability - */ - public struct Counter has key { - id: UID, - count: u64, - } - - /* - Init function that creates and shares a Counter object. - - This function will be called once and only once during the package deployment. - - Further reading: - - Shared objects: https://docs.sui.io/concepts/object-ownership/shared - */ - fun init(ctx: &mut TxContext) { - transfer::share_object( - Counter { - id: object::new(ctx), - count: 0, - } - ); - } - - public fun increment(counter: &mut Counter) { - counter.count = counter.count + 1; - } -} \ No newline at end of file + /* + Struct for defining the Counter object type + + Abilities: + - key: allows this type to be an object on Sui + + Attributes: + - id: The object id of this object (required when using key ability) + - count: The current value of the counter + - collected_fees: Balance of SUI tokens collected as fees + - creator: Address of the creator of the counter + - min_fee: Minimum fee required to increment the counter + + Further reading: + - key ability: https://docs.sui.ioonceptsbject-modelbject#object-capabilities + */ + public struct Counter has key { + id: UID, + count: u64, + collected_fees: balance::Balance, + creator: address, + min_fee: u64, + } + + /* + Init function that creates and shares a Counter object. + + This function will be called once and only once during the package deployment. + + Further reading: + - Shared objects: https://docs.sui.ioonceptsbject-ownershiphared + */ + fun init(ctx: &mut TxContext) { + transfer::share_object( + Counter { + id: object::new(ctx), + count: 0, + collected_fees: balance::zero(), + creator: ctx.sender(), + min_fee: 10, + } + ); + } + + /* + Increment function that increases the counter value by 1. + + This function takes a mutable reference to a Counter object and a SUI coin as fee. + The fee must be at least equal to the minimum fee set in the Counter object. + The fee is added to the collected_fees balance in the Counter. + + Parameters: + - counter: Mutable reference to the Counter object to increment + - fee: SUI coin to pay as fee for incrementing + + Aborts: + - If the fee is less than the minimum required fee + */ + + public fun increment( + counter: &mut Counter, + fee: coin::Coin + ) { + counter.count = counter.count + 1; + assert!(fee.value() >= counter.min_fee, 0); + counter.collected_fees.join(fee.into_balance()); + } +} diff --git a/scripts/src/lessons/input_objects/exercise.ts b/scripts/src/lessons/input_objects/exercise.ts index c069825..90f8f15 100644 --- a/scripts/src/lessons/input_objects/exercise.ts +++ b/scripts/src/lessons/input_objects/exercise.ts @@ -1,68 +1,96 @@ -import { Transaction } from '@mysten/sui/transactions'; +import { Transaction } from "@mysten/sui/transactions"; import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519"; -import { getFullnodeUrl, SuiClient } from '@mysten/sui/client'; -import { decodeSuiPrivateKey } from '@mysten/sui/cryptography'; -import keyPairJson from '../../../keypair.json'; - +import { getFullnodeUrl, SuiClient } from "@mysten/sui/client"; +import { decodeSuiPrivateKey } from "@mysten/sui/cryptography"; +import keyPairJson from "../../../keypair.json"; /** - * + * * Global variables - * + * * These variables are used throughout the exercise below. - * + * */ const { secretKey } = decodeSuiPrivateKey(keyPairJson.privateKey); const keypair = Ed25519Keypair.fromSecretKey(secretKey); -const PACKAGE_ADDRESS = `0xad3225e7d4827f81dc0686177067e1b458e8468ceabcff3456888ce3d806eb8c`; +const PACKAGE_ID = `0xad3225e7d4827f81dc0686177067e1b458e8468ceabcff3456888ce3d806eb8c`; -const COUNTER_ADDRESS = `0x1feb03541d20064d1876c26cfa44514f2e029c8201a2fe12a60589842b9d391d` +const COUNTER_OBJECT_ID = `0x1feb03541d20064d1876c26cfa44514f2e029c8201a2fe12a60589842b9d391d`; const rpcUrl = getFullnodeUrl("testnet"); const suiClient = new SuiClient({ url: rpcUrl }); /** * Objects as input: Exercise 1 - * + * * In this exercise, you use Sui objects as inputs in a PTB to update the value of a shared object. - * + * * When finished, run the following command in the scripts directory to test your solution: - * + * * yarn input-objects - * - * RESOURCES: + * + * RESOURCES: * - https://sdk.mystenlabs.com/typescript/transaction-building/basics#transactions */ const main = async () => { - /** - * Task 1: - * + * Task 1: + * * Create a new Transaction instance from the @mysten/sui/transactions module. */ - + const tx = new Transaction(); + /** * Task 2: - * + * + * Create a coin to pay the fee for incrementing the counter. + * Based on the counter.move file, we need to provide a SUI coin with at least the minimum fee (10). + * We use the `splitCoins` function to create a coin with the minimum fee from our gas fee. + * + * Resources: + * - SplitCoins: https://sdk.mystenlabs.com/typescript/transaction-building/basics + */ + const [coin] = tx.splitCoins(tx.gas, [tx.pure.u64(10)]); + + /** + * Task 3: + * * Execute the call to the `counter::increment` function to the transaction instance. - * - * The target should be in the format {package address}::{module name}::{function name}. The - * package address is provided above. The module name is `counter` and the function name is + * + * The target should be in the format {package address}::{module name}::{function name}. The + * package address is provided above. The module name is `counter` and the function name is * `increment`. - * - * Resources: + * + * Resources: * - Object inputs: https://sdk.mystenlabs.com/typescript/transaction-building/basics#object-references */ + tx.moveCall({ + target: `${PACKAGE_ID}::counter::increment`, + arguments: [tx.object(COUNTER_OBJECT_ID), coin], + }); + /** - * Task 3: - * + * Task 4: + * * Sign and execute the transaction using the SuiClient instance created above. - * + * * Print the result to the console. + * + * Resources: + * - Observing transaction results: https://sdk.mystenlabs.com/typescript/transaction-building/basics#observing-the-results-of-a-transaction */ - -} + const result = await suiClient.signAndExecuteTransaction({ + transaction: tx, + signer: keypair, + }); + await suiClient.waitForTransaction({ + digest: result.digest, + }); + console.log( + `[Success] view your transaction result at: https://suiscan.xyz/testnet/tx/${result.digest}` + ); +}; -main(); \ No newline at end of file +main(); diff --git a/scripts/src/lessons/return_objects/exercise.ts b/scripts/src/lessons/return_objects/exercise.ts index 50fb3ba..98f8423 100644 --- a/scripts/src/lessons/return_objects/exercise.ts +++ b/scripts/src/lessons/return_objects/exercise.ts @@ -15,8 +15,7 @@ const { secretKey } = decodeSuiPrivateKey(keyPairJson.privateKey); const keypair = Ed25519Keypair.fromSecretKey(secretKey); const suiAddress = keypair.getPublicKey().toSuiAddress(); -const PACKAGE_ADDRESS = `0x83feeef5abcb1d5caca48f5e4e2259f8fbbcac88c10d82cc95ed58ff6f0dcd79`; -const NFT_TYPE = `0x83feeef5abcb1d5caca48f5e4e2259f8fbbcac88c10d82cc95ed58ff6f0dcd79::sui_nft::SuiNFT`; +const PACKAGE_ID = `0x83feeef5abcb1d5caca48f5e4e2259f8fbbcac88c10d82cc95ed58ff6f0dcd79`; const rpcUrl = getFullnodeUrl("testnet"); const suiClient = new SuiClient({ url: rpcUrl }); @@ -55,7 +54,7 @@ const main = async () => { */ const nft = tx.moveCall({ - target: `${PACKAGE_ADDRESS}::sui_nft::new`, + target: `${PACKAGE_ID}::sui_nft::new`, }); /** @@ -82,7 +81,12 @@ const main = async () => { transaction: tx, signer: keypair, }); - console.log(result); + await suiClient.waitForTransaction({ + digest: result.digest, + }); + console.log( + `[Success] view your transaction result at: https://suiscan.xyz/testnet/tx/${result.digest}` + ); }; main(); diff --git a/scripts/src/lessons/scavenger_hunt/exercise.ts b/scripts/src/lessons/scavenger_hunt/exercise.ts index 6b76caf..88da7c3 100644 --- a/scripts/src/lessons/scavenger_hunt/exercise.ts +++ b/scripts/src/lessons/scavenger_hunt/exercise.ts @@ -14,8 +14,9 @@ import keyPairJson from "../../../keypair.json"; const { secretKey } = decodeSuiPrivateKey(keyPairJson.privateKey); const keypair = Ed25519Keypair.fromSecretKey(secretKey); -const PACKAGE_ADDRESS = `0x25dfcadb5927395b463a426e8d63425d654a6057affc368f4dc176e587f489a5`; +const PACKAGE_ID = `0x25dfcadb5927395b463a426e8d63425d654a6057affc368f4dc176e587f489a5`; const TEST_BUCK_TYPE = `0x25dfcadb5927395b463a426e8d63425d654a6057affc368f4dc176e587f489a5::test_buck::TEST_BUCK`; +const VAULT_ID = `0x46aad790c2b0ffe7951cab440641ea6a08169aac9e8e843899fd0a2d15aaa0e1`; const rpcUrl = getFullnodeUrl("testnet"); const suiClient = new SuiClient({ url: rpcUrl }); @@ -36,26 +37,69 @@ const main = async () => { /** * Task 1: * + * Create a new Transaction instance from the @mysten/sui/transactions module. + */ + const tx = new Transaction(); + /** + * Task 2: + * * Create a new key using the `key::new` function. */ + const key = tx.moveCall({ + target: `${PACKAGE_ID}::key::new`, + }); + /** - * Task 2: + * Task 3: * * Set the key code correctly using the `key::set_code` function. */ + tx.moveCall({ + target: `${PACKAGE_ID}::key::set_code`, + arguments: [key, tx.pure.u64(777)], + }); + /** - * Task 3: + * Task 4: * * Use the key to withdraw the `Bucket USD` coin from the vault using the `vault::withdraw` function. */ - + + const coin = tx.moveCall({ + target: `${PACKAGE_ID}::vault::withdraw`, + arguments: [tx.object(VAULT_ID), key], + }); + /** - * Task 4: + * Task 5: * * Transfer the `Bucket USD` coin to your account. */ + + tx.transferObjects([coin], keypair.toSuiAddress()); + + /** + * Task 6: + * + * Sign and execute the transaction using the SuiClient instance created above. + * + * Print the result to the console. + * + * Resources: + * - Observing transaction results: https://sdk.mystenlabs.com/typescript/transaction-building/basics#observing-the-results-of-a-transaction + */ + const result = await suiClient.signAndExecuteTransaction({ + transaction: tx, + signer: keypair, + }); + await suiClient.waitForTransaction({ + digest: result.digest, + }); + console.log( + `[Success] view your transaction result at: https://suiscan.xyz/testnet/tx/${result.digest}` + ); }; main(); From c5b19f5f3700b73faacce1ed45b8f1b2b614a7ff Mon Sep 17 00:00:00 2001 From: EasonC13 Date: Wed, 2 Apr 2025 21:49:37 -0400 Subject: [PATCH 14/21] update init script --- scripts/src/init.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/src/init.ts b/scripts/src/init.ts index 13bf4b6..5822b3b 100644 --- a/scripts/src/init.ts +++ b/scripts/src/init.ts @@ -21,6 +21,9 @@ const main = async () => { console.log( `\nView your Sui account at https://suiscan.xyz/testnet/account/${publicAddress}` ); + console.log("\nTry requesting tokens from alternative faucets:"); + console.log("- https://faucet.n1stake.com/"); + console.log("- https://faucet.sui.io/"); }; main(); From 627140fc955dc2f92dac9f406b09790e13bd3107 Mon Sep 17 00:00:00 2001 From: EasonC13 Date: Wed, 2 Apr 2025 21:53:04 -0400 Subject: [PATCH 15/21] update: scripts --- scripts/package.json | 6 +++--- scripts/src/helpers.ts | 6 +++--- scripts/src/init.ts | 2 +- .../input_objects/exercise.ts => input_objects_exercise.ts} | 2 +- .../exercise.ts => return_objects_exercise.ts} | 2 +- .../exercise.ts => scavenger_hunt_exercise.ts} | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) rename scripts/src/{lessons/input_objects/exercise.ts => input_objects_exercise.ts} (98%) rename scripts/src/{lessons/return_objects/exercise.ts => return_objects_exercise.ts} (98%) rename scripts/src/{lessons/scavenger_hunt/exercise.ts => scavenger_hunt_exercise.ts} (98%) diff --git a/scripts/package.json b/scripts/package.json index 562cc41..8d97382 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -10,9 +10,9 @@ }, "scripts": { "init-keypair": "ts-node src/init.ts", - "return-objects": "ts-node src/lessons/return_objects/exercise.ts", - "input-objects": "ts-node src/lessons/input_objects/exercise.ts", - "scavenger-hunt": "ts-node src/lessons/scavenger_hunt/exercise.ts" + "return-objects": "ts-node src/return_objects_exercise.ts", + "input-objects": "ts-node src/input_objects_exercise.ts", + "scavenger-hunt": "ts-node src/scavenger_hunt_exercise.ts" }, "dependencies": { "@mysten/sui": "^1.8.0", diff --git a/scripts/src/helpers.ts b/scripts/src/helpers.ts index 7c4dba9..70687f5 100644 --- a/scripts/src/helpers.ts +++ b/scripts/src/helpers.ts @@ -1,7 +1,7 @@ import { writeFile } from "fs/promises"; export async function sleep(ms: number): Promise { - return new Promise(resolve => setTimeout(resolve, ms)); + return new Promise((resolve) => setTimeout(resolve, ms)); } // Asynchronous example @@ -9,6 +9,6 @@ export async function writeToFile(filename: string, content: string) { try { await writeFile(filename, content); } catch (error) { - console.error('Error writing file:', error); + console.error("Error writing file:", error); } -} \ No newline at end of file +} diff --git a/scripts/src/init.ts b/scripts/src/init.ts index 5822b3b..5da25a8 100644 --- a/scripts/src/init.ts +++ b/scripts/src/init.ts @@ -21,7 +21,7 @@ const main = async () => { console.log( `\nView your Sui account at https://suiscan.xyz/testnet/account/${publicAddress}` ); - console.log("\nTry requesting tokens from alternative faucets:"); + console.log("\nNext, please request tokens from alternative faucets:"); console.log("- https://faucet.n1stake.com/"); console.log("- https://faucet.sui.io/"); }; diff --git a/scripts/src/lessons/input_objects/exercise.ts b/scripts/src/input_objects_exercise.ts similarity index 98% rename from scripts/src/lessons/input_objects/exercise.ts rename to scripts/src/input_objects_exercise.ts index 90f8f15..1124c5f 100644 --- a/scripts/src/lessons/input_objects/exercise.ts +++ b/scripts/src/input_objects_exercise.ts @@ -2,7 +2,7 @@ import { Transaction } from "@mysten/sui/transactions"; import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519"; import { getFullnodeUrl, SuiClient } from "@mysten/sui/client"; import { decodeSuiPrivateKey } from "@mysten/sui/cryptography"; -import keyPairJson from "../../../keypair.json"; +import keyPairJson from "../keypair.json"; /** * diff --git a/scripts/src/lessons/return_objects/exercise.ts b/scripts/src/return_objects_exercise.ts similarity index 98% rename from scripts/src/lessons/return_objects/exercise.ts rename to scripts/src/return_objects_exercise.ts index 98f8423..e97ca8d 100644 --- a/scripts/src/lessons/return_objects/exercise.ts +++ b/scripts/src/return_objects_exercise.ts @@ -2,7 +2,7 @@ import { Transaction } from "@mysten/sui/transactions"; import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519"; import { getFullnodeUrl, SuiClient } from "@mysten/sui/client"; import { decodeSuiPrivateKey } from "@mysten/sui/cryptography"; -import keyPairJson from "../../../keypair.json"; +import keyPairJson from "../keypair.json"; /** * diff --git a/scripts/src/lessons/scavenger_hunt/exercise.ts b/scripts/src/scavenger_hunt_exercise.ts similarity index 98% rename from scripts/src/lessons/scavenger_hunt/exercise.ts rename to scripts/src/scavenger_hunt_exercise.ts index 88da7c3..5675d28 100644 --- a/scripts/src/lessons/scavenger_hunt/exercise.ts +++ b/scripts/src/scavenger_hunt_exercise.ts @@ -2,7 +2,7 @@ import { Transaction } from "@mysten/sui/transactions"; import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519"; import { getFullnodeUrl, SuiClient } from "@mysten/sui/client"; import { decodeSuiPrivateKey } from "@mysten/sui/cryptography"; -import keyPairJson from "../../../keypair.json"; +import keyPairJson from "../keypair.json"; /** * From fa2e42a2eb08c5032ddff8d9a20bf96d79a900e1 Mon Sep 17 00:00:00 2001 From: EasonC13 Date: Wed, 2 Apr 2025 21:58:32 -0400 Subject: [PATCH 16/21] fix counter --- README.md | 2 +- lessons/input_objects/counter/Move.lock | 16 ++++++++-------- scripts/src/input_objects_exercise.ts | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index bbbb118..69f99b1 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ This usage is straightforward, but tends to leave developers wondering what this ### Exercise 2: Input Objects - Counter -View the contents [`counter.move`](./lessons/input_objects/counter/sources/counter.move). There is a deployed instance of this package on the Sui blockchain. The address of the package is [`0xad3225e7d4827f81dc0686177067e1b458e8468ceabcff3456888ce3d806eb8c`](https://suiscan.xyz/testnet/object/0xad3225e7d4827f81dc0686177067e1b458e8468ceabcff3456888ce3d806eb8c/txs) and the counter object is [0x1feb03541d20064d1876c26cfa44514f2e029c8201a2fe12a60589842b9d391d](https://suiscan.xyz/testnet/object/0x1feb03541d20064d1876c26cfa44514f2e029c8201a2fe12a60589842b9d391d/fields). +View the contents [`counter.move`](./lessons/input_objects/counter/sources/counter.move). There is a deployed instance of this package on the Sui blockchain. The address of the package is [`0x8f0b6cbef998d26f03daa8a9e90d17d57bce8d4b45cb90911662a828f903d323`](https://suiscan.xyz/testnet/object/0x8f0b6cbef998d26f03daa8a9e90d17d57bce8d4b45cb90911662a828f903d323/txs) and the counter object is [0x33a950ff57b782bc66f6416bf3fdf7d44de94a84fa823b9b9291f49d4b0270da](https://suiscan.xyz/testnet/object/0x33a950ff57b782bc66f6416bf3fdf7d44de94a84fa823b9b9291f49d4b0270da/fields). Navigate to [`scripts/lessons/input_objects/exercise.ts`](./scripts/src/lessons/input_objects/exercise.ts) and complete the exercise. diff --git a/lessons/input_objects/counter/Move.lock b/lessons/input_objects/counter/Move.lock index ee51ac2..fe55f4a 100644 --- a/lessons/input_objects/counter/Move.lock +++ b/lessons/input_objects/counter/Move.lock @@ -1,27 +1,27 @@ # @generated by Move, please check-in and do not edit manually. [move] -version = 2 +version = 3 manifest_digest = "10944AA0F1590CA15650646C66BA027B77D532E5295D19E52CD4671090E69164" deps_digest = "F8BBB0CCB2491CA29A3DF03D6F92277A4F3574266507ACD77214D37ECA3F3082" dependencies = [ - { name = "Sui" }, + { id = "Sui", name = "Sui" }, ] [[move.package]] -name = "MoveStdlib" +id = "MoveStdlib" source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/testnet", subdir = "crates/sui-framework/packages/move-stdlib" } [[move.package]] -name = "Sui" +id = "Sui" source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/testnet", subdir = "crates/sui-framework/packages/sui-framework" } dependencies = [ - { name = "MoveStdlib" }, + { id = "MoveStdlib", name = "MoveStdlib" }, ] [move.toolchain-version] -compiler-version = "1.30.3" +compiler-version = "1.40.3" edition = "2024.beta" flavor = "sui" @@ -29,6 +29,6 @@ flavor = "sui" [env.testnet] chain-id = "4c78adac" -original-published-id = "0xad3225e7d4827f81dc0686177067e1b458e8468ceabcff3456888ce3d806eb8c" -latest-published-id = "0xad3225e7d4827f81dc0686177067e1b458e8468ceabcff3456888ce3d806eb8c" +original-published-id = "0x8f0b6cbef998d26f03daa8a9e90d17d57bce8d4b45cb90911662a828f903d323" +latest-published-id = "0x8f0b6cbef998d26f03daa8a9e90d17d57bce8d4b45cb90911662a828f903d323" published-version = "1" diff --git a/scripts/src/input_objects_exercise.ts b/scripts/src/input_objects_exercise.ts index 1124c5f..0058fa1 100644 --- a/scripts/src/input_objects_exercise.ts +++ b/scripts/src/input_objects_exercise.ts @@ -14,9 +14,9 @@ import keyPairJson from "../keypair.json"; const { secretKey } = decodeSuiPrivateKey(keyPairJson.privateKey); const keypair = Ed25519Keypair.fromSecretKey(secretKey); -const PACKAGE_ID = `0xad3225e7d4827f81dc0686177067e1b458e8468ceabcff3456888ce3d806eb8c`; +const PACKAGE_ID = `0x8f0b6cbef998d26f03daa8a9e90d17d57bce8d4b45cb90911662a828f903d323`; -const COUNTER_OBJECT_ID = `0x1feb03541d20064d1876c26cfa44514f2e029c8201a2fe12a60589842b9d391d`; +const COUNTER_OBJECT_ID = `0x33a950ff57b782bc66f6416bf3fdf7d44de94a84fa823b9b9291f49d4b0270da`; const rpcUrl = getFullnodeUrl("testnet"); const suiClient = new SuiClient({ url: rpcUrl }); From cb54b056271806ed800a3c0ce028405ed79749c1 Mon Sep 17 00:00:00 2001 From: EasonC13 Date: Wed, 2 Apr 2025 22:04:37 -0400 Subject: [PATCH 17/21] update: finish all answer --- lessons/scavenger/sources/vault.move | 10 +++++----- scripts/src/scavenger_hunt_exercise.ts | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lessons/scavenger/sources/vault.move b/lessons/scavenger/sources/vault.move index cfcf875..a5d5fbd 100644 --- a/lessons/scavenger/sources/vault.move +++ b/lessons/scavenger/sources/vault.move @@ -40,11 +40,13 @@ module scavenger::vault { } public fun withdraw( - vault: &mut Vault, key: key::Key, + vault: &mut Vault, + key: key::Key, ctx: &mut TxContext ): coin::Coin { - - assert_valid_key_code(vault, &key);key.delete(); + assert_valid_key_code(vault, &key); + key.delete(); + let new_coin = coin::from_balance( balance::split( &mut vault.balance, @@ -52,9 +54,7 @@ module scavenger::vault { ), ctx ); - new_coin - } public fun empty( diff --git a/scripts/src/scavenger_hunt_exercise.ts b/scripts/src/scavenger_hunt_exercise.ts index 5675d28..18820a0 100644 --- a/scripts/src/scavenger_hunt_exercise.ts +++ b/scripts/src/scavenger_hunt_exercise.ts @@ -69,6 +69,7 @@ const main = async () => { const coin = tx.moveCall({ target: `${PACKAGE_ID}::vault::withdraw`, + typeArguments: [TEST_BUCK_TYPE], arguments: [tx.object(VAULT_ID), key], }); From b44338e890fae5947f72a665e1a08506a9aeb334 Mon Sep 17 00:00:00 2001 From: EasonC13 Date: Thu, 3 Apr 2025 18:19:47 -0400 Subject: [PATCH 18/21] update version with todo --- scripts/src/input_objects_exercise.ts | 6 ++-- scripts/src/return_objects_exercise.ts | 2 +- scripts/src/scavenger_hunt_exercise.ts | 38 ++++---------------------- 3 files changed, 11 insertions(+), 35 deletions(-) diff --git a/scripts/src/input_objects_exercise.ts b/scripts/src/input_objects_exercise.ts index 0058fa1..1f660d5 100644 --- a/scripts/src/input_objects_exercise.ts +++ b/scripts/src/input_objects_exercise.ts @@ -67,8 +67,10 @@ const main = async () => { */ tx.moveCall({ - target: `${PACKAGE_ID}::counter::increment`, - arguments: [tx.object(COUNTER_OBJECT_ID), coin], + target: ``, // TODO: Add target here + arguments: [ + // TODO: Add arguments here + ], }); /** diff --git a/scripts/src/return_objects_exercise.ts b/scripts/src/return_objects_exercise.ts index e97ca8d..d833a0c 100644 --- a/scripts/src/return_objects_exercise.ts +++ b/scripts/src/return_objects_exercise.ts @@ -67,7 +67,7 @@ const main = async () => { * HINT: Use `suiAddress`` to transfer the object to your address. */ - tx.transferObjects([nft], suiAddress); + // TODO: Add transferObjects call here /** * Task 4: diff --git a/scripts/src/scavenger_hunt_exercise.ts b/scripts/src/scavenger_hunt_exercise.ts index 18820a0..2d28b82 100644 --- a/scripts/src/scavenger_hunt_exercise.ts +++ b/scripts/src/scavenger_hunt_exercise.ts @@ -39,48 +39,31 @@ const main = async () => { * * Create a new Transaction instance from the @mysten/sui/transactions module. */ - const tx = new Transaction(); + // TODO: Create a new Transaction instance here /** * Task 2: * * Create a new key using the `key::new` function. */ - - const key = tx.moveCall({ - target: `${PACKAGE_ID}::key::new`, - }); - + // TODO: Create a new key here by calling the `key::new` function /** * Task 3: * * Set the key code correctly using the `key::set_code` function. */ - - tx.moveCall({ - target: `${PACKAGE_ID}::key::set_code`, - arguments: [key, tx.pure.u64(777)], - }); - + // TODO: Set the key code correctly here by calling the `key::set_code` function /** * Task 4: * * Use the key to withdraw the `Bucket USD` coin from the vault using the `vault::withdraw` function. */ - - const coin = tx.moveCall({ - target: `${PACKAGE_ID}::vault::withdraw`, - typeArguments: [TEST_BUCK_TYPE], - arguments: [tx.object(VAULT_ID), key], - }); - + // TODO: Use the key to withdraw the `Bucket USD` coin from the vault using the `vault::withdraw` function /** * Task 5: * * Transfer the `Bucket USD` coin to your account. */ - - tx.transferObjects([coin], keypair.toSuiAddress()); - + // TODO: Transfer the `Bucket USD` coin to your account /** * Task 6: * @@ -91,16 +74,7 @@ const main = async () => { * Resources: * - Observing transaction results: https://sdk.mystenlabs.com/typescript/transaction-building/basics#observing-the-results-of-a-transaction */ - const result = await suiClient.signAndExecuteTransaction({ - transaction: tx, - signer: keypair, - }); - await suiClient.waitForTransaction({ - digest: result.digest, - }); - console.log( - `[Success] view your transaction result at: https://suiscan.xyz/testnet/tx/${result.digest}` - ); + // TODO: Sign and execute the transaction here }; main(); From b32221c283262fe8f79409600a87a969ded64915 Mon Sep 17 00:00:00 2001 From: Eason Chen <43432631+EasonC13@users.noreply.github.com> Date: Fri, 4 Apr 2025 08:11:23 +0900 Subject: [PATCH 19/21] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 69f99b1..a1f2f19 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ npm run init-keypair This will generate and fund a new keypair for you to use in the workshop. Make sure not to use this keypair in any production environments. -Sui Faucet: [https://faucet.sui.io/](https://faucet.sui.io/) OR [Discord faucet](https://discord.gg/cKx75xrRMq) +Sui Faucet: [https://faucet.n1stake.com](https://faucet.n1stake.com), [https://faucet.sui.io/](https://faucet.sui.io/) OR [Discord faucet](https://discord.gg/cKx75xrRMq) # Lessons From 0e9de9d6ba1a9fe2472550114b8f82cf6bf86b66 Mon Sep 17 00:00:00 2001 From: EasonC13 Date: Thu, 3 Apr 2025 22:20:54 -0400 Subject: [PATCH 20/21] update README --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a1f2f19..7f666f2 100644 --- a/README.md +++ b/README.md @@ -29,8 +29,10 @@ npm run init-keypair This will generate and fund a new keypair for you to use in the workshop. Make sure not to use this keypair in any production environments. -Sui Faucet: [https://faucet.n1stake.com](https://faucet.n1stake.com), [https://faucet.sui.io/](https://faucet.sui.io/) OR [Discord faucet](https://discord.gg/cKx75xrRMq) - +Sui Faucet options: +- [n1stake faucet](https://faucet.n1stake.com) +- [Official Sui faucet](https://faucet.sui.io/) +- [Discord faucet](https://discord.gg/cKx75xrRMq) # Lessons @@ -88,7 +90,7 @@ The package of the SUIII NFT is at [`0x83feeef5abcb1d5caca48f5e4e2259f8fbbcac88c View the contract at [`sui_nft.move`](./lessons/returning_objects/sui_nft/sources/sui_nft.move). Try to mint an NFT to your account and view it at explorer with PTBs. -Navigate to [`scripts/lessons/return_objects/exercise.ts`](./scripts/src/lessons/return_objects/exercise.ts) and complete the exercise. +Navigate to [`scripts/src/return_objects_exercise.ts`](./scripts/src/return_objects_exercise.ts) and complete the exercise. > Bonus Challenge: Can you deploy the [SUIII NFT package](./lessons/returning_objects/sui_nft) yourself and use different text and images for the NFT? > [Install the Sui CLI](https://docs.sui.io/guides/developer/getting-started/sui-install), [Create Deployer Address](https://docs.sui.io/guides/developer/getting-started/get-address), and deposit gas coins from faucet, then use `sui client publish --skip-dependency-verification` to deploy! @@ -128,7 +130,7 @@ This usage is straightforward, but tends to leave developers wondering what this View the contents [`counter.move`](./lessons/input_objects/counter/sources/counter.move). There is a deployed instance of this package on the Sui blockchain. The address of the package is [`0x8f0b6cbef998d26f03daa8a9e90d17d57bce8d4b45cb90911662a828f903d323`](https://suiscan.xyz/testnet/object/0x8f0b6cbef998d26f03daa8a9e90d17d57bce8d4b45cb90911662a828f903d323/txs) and the counter object is [0x33a950ff57b782bc66f6416bf3fdf7d44de94a84fa823b9b9291f49d4b0270da](https://suiscan.xyz/testnet/object/0x33a950ff57b782bc66f6416bf3fdf7d44de94a84fa823b9b9291f49d4b0270da/fields). -Navigate to [`scripts/lessons/input_objects/exercise.ts`](./scripts/src/lessons/input_objects/exercise.ts) and complete the exercise. +Navigate to [`scripts/src/input_objects_exercise.ts`](./scripts/src/input_objects_exercise.ts) and complete the exercise. ### Exercise 3: Scavenger Hunting with PTBs @@ -143,4 +145,4 @@ You will need to create a PTB to: 3. Use the key to withdraw the `Bucket USD` coin from the vault 4. Transfer the `Bucket USD` coin to your account -Navigate to [`scripts/lessons/scavenger_hunt/exercise.ts`](./scripts/src/lessons/scavenger_hunt/exercise.ts) and complete the exercise. +Navigate to [`scripts/src/scavenger_hunt_exercise.ts`](./scripts/src/scavenger_hunt_exercise.ts) and complete the exercise. From 722da957d332434f7da0c6a9a003e04d5633d9b1 Mon Sep 17 00:00:00 2001 From: EasonC13 Date: Thu, 3 Apr 2025 22:23:02 -0400 Subject: [PATCH 21/21] refactor by formatter --- .../counter/sources/counter.move | 61 ++++---- .../sui_nft/sources/sui_nft.move | 65 ++++---- lessons/scavenger/sources/key.move | 29 ++-- lessons/scavenger/sources/test_buck.move | 121 +++++++-------- lessons/scavenger/sources/vault.move | 141 ++++++++---------- 5 files changed, 195 insertions(+), 222 deletions(-) diff --git a/lessons/input_objects/counter/sources/counter.move b/lessons/input_objects/counter/sources/counter.move index a5fd135..8fcd111 100644 --- a/lessons/input_objects/counter/sources/counter.move +++ b/lessons/input_objects/counter/sources/counter.move @@ -1,9 +1,10 @@ -module counter::counter { - use sui::sui::SUI; - use sui::coin; - use sui::balance; +module counter::counter; - /* +use sui::balance; +use sui::coin; +use sui::sui::SUI; + +/* Struct for defining the Counter object type Abilities: @@ -19,15 +20,15 @@ module counter::counter { Further reading: - key ability: https://docs.sui.ioonceptsbject-modelbject#object-capabilities */ - public struct Counter has key { - id: UID, - count: u64, - collected_fees: balance::Balance, - creator: address, - min_fee: u64, - } +public struct Counter has key { + id: UID, + count: u64, + collected_fees: balance::Balance, + creator: address, + min_fee: u64, +} - /* +/* Init function that creates and shares a Counter object. This function will be called once and only once during the package deployment. @@ -35,19 +36,17 @@ module counter::counter { Further reading: - Shared objects: https://docs.sui.ioonceptsbject-ownershiphared */ - fun init(ctx: &mut TxContext) { - transfer::share_object( - Counter { - id: object::new(ctx), - count: 0, - collected_fees: balance::zero(), - creator: ctx.sender(), - min_fee: 10, - } - ); - } +fun init(ctx: &mut TxContext) { + transfer::share_object(Counter { + id: object::new(ctx), + count: 0, + collected_fees: balance::zero(), + creator: ctx.sender(), + min_fee: 10, + }); +} - /* +/* Increment function that increases the counter value by 1. This function takes a mutable reference to a Counter object and a SUI coin as fee. @@ -62,12 +61,8 @@ module counter::counter { - If the fee is less than the minimum required fee */ - public fun increment( - counter: &mut Counter, - fee: coin::Coin - ) { - counter.count = counter.count + 1; - assert!(fee.value() >= counter.min_fee, 0); - counter.collected_fees.join(fee.into_balance()); - } +public fun increment(counter: &mut Counter, fee: coin::Coin) { + counter.count = counter.count + 1; + assert!(fee.value() >= counter.min_fee, 0); + counter.collected_fees.join(fee.into_balance()); } diff --git a/lessons/returning_objects/sui_nft/sources/sui_nft.move b/lessons/returning_objects/sui_nft/sources/sui_nft.move index 64dfc70..cda135b 100644 --- a/lessons/returning_objects/sui_nft/sources/sui_nft.move +++ b/lessons/returning_objects/sui_nft/sources/sui_nft.move @@ -1,9 +1,9 @@ -module sui_nft::sui_nft { +module sui_nft::sui_nft; - use sui::display; // https://docs.sui.io/references/framework/sui-framework/display - use sui::package; // https://docs.sui.io/references/framework/sui-framework/package +use sui::display; +use sui::package; - /* +/* Struct for defining the Sui NFT object type Abilities: @@ -17,53 +17,52 @@ module sui_nft::sui_nft { - key ability: https://move-book.comtorageey-ability.html?highlight=key#the-key-ability - store ability: https://move-book.comtoragetore-ability.html?highlight=store#ability-store */ - public struct SuiNFT has key, store { - id: UID, - } +public struct SuiNFT has key, store { + id: UID, +} - /* +/* Module's one-time witness to be used for setting up the display standard for the Sui NFT type https://move-book.comrogrammabilityitness-pattern.html?highlight=one%20time#one-time-witness */ - public struct SUI_NFT has drop {} +public struct SUI_NFT has drop {} - /* +/* Init function that sets up the display standard for the Sui NFT object. This function will be called once and only once during the package deployment. Further reading: - Sui object display standard: https://docs.sui.iotandardsisplay */ - fun init(otw: SUI_NFT, ctx: &mut TxContext) { - let keys = vector[ - b"name".to_string(), - b"image_url".to_string(), - b"description".to_string(), - b"project_url".to_string(), - ]; +fun init(otw: SUI_NFT, ctx: &mut TxContext) { + let keys = vector[ + b"name".to_string(), + b"image_url".to_string(), + b"description".to_string(), + b"project_url".to_string(), + ]; - let values = vector[ - b"SUIIIII".to_string(), - b"https://media.tenor.com/t3eKwU-odDgAAAAM/sui-siu.gif".to_string(), - b"SUIIIII it out!".to_string(), - b"https://github.com/sui-foundation/sui-object-model-workshop".to_string(), - ]; + let values = vector[ + b"SUIIIII".to_string(), + b"https://media.tenor.com/t3eKwU-odDgAAAAM/sui-siu.gif".to_string(), + b"SUIIIII it out!".to_string(), + b"https://github.com/sui-foundation/sui-object-model-workshop".to_string(), + ]; - let publisher = package::claim(otw, ctx); + let publisher = package::claim(otw, ctx); - let mut display = display::new_with_fields(&publisher, keys, values, ctx); + let mut display = display::new_with_fields(&publisher, keys, values, ctx); - display::update_version(&mut display); + display::update_version(&mut display); - transfer::public_transfer(publisher, ctx.sender()); - transfer::public_transfer(display, ctx.sender()); - } + transfer::public_transfer(publisher, ctx.sender()); + transfer::public_transfer(display, ctx.sender()); +} - /* +/* Creates and returns a new SuiNFT object. */ - public fun new(ctx: &mut TxContext): SuiNFT { - SuiNFT {id: object::new(ctx)} - } +public fun new(ctx: &mut TxContext): SuiNFT { + SuiNFT { id: object::new(ctx) } } diff --git a/lessons/scavenger/sources/key.move b/lessons/scavenger/sources/key.move index 516a470..473290c 100644 --- a/lessons/scavenger/sources/key.move +++ b/lessons/scavenger/sources/key.move @@ -1,26 +1,25 @@ -module scavenger::key { +module scavenger::key; - public struct Key { - code: u64 - } +public struct Key { + code: u64, +} - public fun new(): Key { +public fun new(): Key { Key { - code: 0 + code: 0, } - } +} - public fun set_code(key: &mut Key, new_code: u64) { +public fun set_code(key: &mut Key, new_code: u64) { key.code = new_code; - } +} - public fun get_code(key: &Key): u64 { +public fun get_code(key: &Key): u64 { key.code - } +} - public(package) fun delete(key: Key) { +public(package) fun delete(key: Key) { let Key { - code: _, + code: _, } = key; - } -} \ No newline at end of file +} diff --git a/lessons/scavenger/sources/test_buck.move b/lessons/scavenger/sources/test_buck.move index 631b99c..fa9b45d 100644 --- a/lessons/scavenger/sources/test_buck.move +++ b/lessons/scavenger/sources/test_buck.move @@ -1,65 +1,60 @@ -module scavenger::test_buck { - - // ----- Use Statements ----- - - use sui::coin::{ Self }; - use sui::url; - use scavenger::vault; - - // ----- Structs ----- - - /// One-time witness type for the TEST_BUCK coin - /// The 'drop' ability allows this type to be dropped after the init function completes - public struct TEST_BUCK has drop {} - - // ----- Init Functions ----- - - /// Module initializer, called once when the module is published - /// @param test_buck - One-time witness for the TEST_BUCK currency - /// @param ctx - Transaction context for accessing sender and creating objects - fun init( - test_buck: TEST_BUCK, - ctx: &mut tx_context::TxContext, - ) { - // Create a new currency with the following parameters: - // - 9 decimals of precision - // - Symbol: BUCK - // - Name: Bucket USD - // - Description: Test token for the testnet - // - Icon URL: Link to the token's SVG image - let (mut treasury_cap, coin_metadata) = coin::create_currency( - test_buck, - 9, - b"BUCK", - b"Bucket USD", - b"Bucket USD at testnet for testing", - option::some( - url::new_unsafe_from_bytes( - b"https://bucket-cdn-eason.s3.us-west-1.amazonaws.com/BUCK.svg" - ) +module scavenger::test_buck; + +use scavenger::vault; +use sui::coin; +use sui::url; + +// ----- Use Statements ----- + +// ----- Structs ----- + +/// One-time witness type for the TEST_BUCK coin +/// The 'drop' ability allows this type to be dropped after the init function completes +public struct TEST_BUCK has drop {} + +// ----- Init Functions ----- + +/// Module initializer, called once when the module is published +/// @param test_buck - One-time witness for the TEST_BUCK currency +/// @param ctx - Transaction context for accessing sender and creating objects +fun init(test_buck: TEST_BUCK, ctx: &mut tx_context::TxContext) { + // Create a new currency with the following parameters: + // - 9 decimals of precision + // - Symbol: BUCK + // - Name: Bucket USD + // - Description: Test token for the testnet + // - Icon URL: Link to the token's SVG image + let (mut treasury_cap, coin_metadata) = coin::create_currency( + test_buck, + 9, + b"BUCK", + b"Bucket USD", + b"Bucket USD at testnet for testing", + option::some( + url::new_unsafe_from_bytes( + b"https://bucket-cdn-eason.s3.us-west-1.amazonaws.com/BUCK.svg", ), - ctx - ); - // Freeze the metadata to make it immutable - transfer::public_freeze_object(coin_metadata); - - // Mint 10^19 tokens (10 billion tokens with 9 decimal places) - let coin = coin::mint( - &mut treasury_cap, - 10000000000000000000, - ctx - ); - // Freeze the treasury cap to prevent further minting - transfer::public_freeze_object(treasury_cap); - - // Create a new vault with: - // - The newly minted coins - // - Withdrawal amount of 10 billion (10^10) - // - Access code of 777 - let admin_cap = vault::new(coin, 10000000000, 777, ctx); - - // Transfer the admin capability to the transaction sender - transfer::public_transfer(admin_cap, tx_context::sender(ctx)); - } - + ), + ctx, + ); + // Freeze the metadata to make it immutable + transfer::public_freeze_object(coin_metadata); + + // Mint 10^19 tokens (10 billion tokens with 9 decimal places) + let coin = coin::mint( + &mut treasury_cap, + 10000000000000000000, + ctx, + ); + // Freeze the treasury cap to prevent further minting + transfer::public_freeze_object(treasury_cap); + + // Create a new vault with: + // - The newly minted coins + // - Withdrawal amount of 10 billion (10^10) + // - Access code of 777 + let admin_cap = vault::new(coin, 10000000000, 777, ctx); + + // Transfer the admin capability to the transaction sender + transfer::public_transfer(admin_cap, tx_context::sender(ctx)); } diff --git a/lessons/scavenger/sources/vault.move b/lessons/scavenger/sources/vault.move index a5d5fbd..093cc1f 100644 --- a/lessons/scavenger/sources/vault.move +++ b/lessons/scavenger/sources/vault.move @@ -1,94 +1,79 @@ -module scavenger::vault { +module scavenger::vault; - use sui::coin; - use sui::balance; - use scavenger::key; +use scavenger::key; +use sui::balance; +use sui::coin; - public struct Vault has key { - id: UID, - balance: balance::Balance, - withdrawal_amount: u64, - code: u64 - } +public struct Vault has key { + id: UID, + balance: balance::Balance, + withdrawal_amount: u64, + code: u64, +} - public struct AdminCap has key, store { - id: UID, - vault_id: ID - } +public struct AdminCap has key, store { + id: UID, + vault_id: ID, +} - public fun new( - coins: coin::Coin, - withdrawal_amount: u64, - code: u64, - ctx: &mut TxContext - ): AdminCap { - let new_vault = Vault { - id: object::new(ctx), - balance: coin::into_balance(coins), - withdrawal_amount, - code - }; +public fun new( + coins: coin::Coin, + withdrawal_amount: u64, + code: u64, + ctx: &mut TxContext, +): AdminCap { + let new_vault = Vault { + id: object::new(ctx), + balance: coin::into_balance(coins), + withdrawal_amount, + code, + }; - let new_admin_cap = AdminCap { - id: object::new(ctx), - vault_id: new_vault.id.to_inner() - }; + let new_admin_cap = AdminCap { + id: object::new(ctx), + vault_id: new_vault.id.to_inner(), + }; - transfer::share_object(new_vault); + transfer::share_object(new_vault); - new_admin_cap - } + new_admin_cap +} - public fun withdraw( - vault: &mut Vault, - key: key::Key, - ctx: &mut TxContext - ): coin::Coin { - assert_valid_key_code(vault, &key); - key.delete(); - - let new_coin = coin::from_balance( - balance::split( - &mut vault.balance, - vault.withdrawal_amount - ), - ctx - ); - new_coin - } +public fun withdraw(vault: &mut Vault, key: key::Key, ctx: &mut TxContext): coin::Coin { + assert_valid_key_code(vault, &key); + key.delete(); - public fun empty( - vault: Vault, - admin_cap: AdminCap, - ctx: &mut TxContext - ): coin::Coin { - assert_valid_admin_cap(&vault, &admin_cap); + let new_coin = coin::from_balance( + balance::split( + &mut vault.balance, + vault.withdrawal_amount, + ), + ctx, + ); + new_coin +} - let AdminCap {id: admin_cap_id, vault_id: _} = admin_cap; - admin_cap_id.delete(); +public fun empty(vault: Vault, admin_cap: AdminCap, ctx: &mut TxContext): coin::Coin { + assert_valid_admin_cap(&vault, &admin_cap); - let Vault { - id, - balance, - withdrawal_amount: _, - code: _ - } = vault; - id.delete(); + let AdminCap { id: admin_cap_id, vault_id: _ } = admin_cap; + admin_cap_id.delete(); - coin::from_balance(balance, ctx) - } + let Vault { + id, + balance, + withdrawal_amount: _, + code: _, + } = vault; + id.delete(); - fun assert_valid_key_code(vault: &Vault, key: &key::Key) { - assert!(vault.code == key.get_code()); - } + coin::from_balance(balance, ctx) +} - fun assert_valid_admin_cap( - vault: &Vault, - admin_cap: &AdminCap - ) { - assert!( - vault.id.to_inner() == admin_cap.vault_id - ); - } +fun assert_valid_key_code(vault: &Vault, key: &key::Key) { + assert!(vault.code == key.get_code()); +} +fun assert_valid_admin_cap(vault: &Vault, admin_cap: &AdminCap) { + assert!(vault.id.to_inner() == admin_cap.vault_id); }