Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions BaseDeDatos/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
build/*
traces/*
.trace
.coverage*
36 changes: 36 additions & 0 deletions BaseDeDatos/Move.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[package]
name = "BaseDeDatos"
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]

# 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]
basededatos = "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"

88 changes: 88 additions & 0 deletions BaseDeDatos/sources/basededatos.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
module basededatos::basededatos {
use sui::vec_map::{VecMap, Self};
use std::string::{utf8, String};



public struct Informacion has key, store {
id:UID,
nombre: String,
usuarios:VecMap<String, Usuario>
}

public struct Usuario has store, copy, drop {
nombre: String,
edad: u8,
tipo: TipoUsuario
}

public enum TipoUsuario has store, copy, drop {
Basico(Basico),
Pro(Pro),
}

public struct Basico has store, copy, drop{
mensaje: String,
}

public struct Pro has store, copy, drop {
mensaje: String,
}

#[error]
const ERROR_NOMBRE_EXISTE: vector<u8> = b"ERROR, EL NOMBRE DE USUARIO YA EXISTE EN LA BASE DE DATOS, INTENTA CON OTRO NUEVO";
#[error]
const ERROR_USUARIO_NO_EXISTE: u16 = 404;

public fun crear_bd(nombre: String, ctx: &mut TxContext) {
let base = Informacion {
id: object::new(ctx),
nombre,
usuarios: vec_map::empty()
};

transfer::transfer(base, tx_context::sender(ctx));
}

public fun crear_usuario(informacion: &mut Informacion, nombre: String, edad: u8, tipo: u8){
assert!(!informacion.usuarios.contains(&nombre), ERROR_NOMBRE_EXISTE);

let tipo_usuario =
if (tipo == 0) {
TipoUsuario::Basico(Basico { mensaje: utf8(b"Usuario Basico") })
} else {
TipoUsuario::Pro(Pro { mensaje: utf8(b"Usuario Pro") })
};

let usuario = Usuario {
nombre,
edad,
tipo: tipo_usuario
};

informacion.usuarios.insert(nombre, usuario);

}

public fun modificar_usuario(informacion: &mut Informacion, nombre: String, edad: u8, tipo: u8) {
assert!(informacion.usuarios.contains(&nombre), ERROR_USUARIO_NO_EXISTE);

let tipo_usuario =
if (tipo == 0) {
TipoUsuario::Basico(Basico { mensaje: utf8(b"Usuario Basico") })
} else {
TipoUsuario::Pro(Pro { mensaje: utf8(b"Usuario Pro") })
};

let info_usuario = informacion.usuarios.get_mut(&nombre);

info_usuario.edad = edad;
info_usuario.tipo = tipo_usuario;
}

public fun eliminar_usuario(informacion: &mut Informacion, nombre: String, edad: u8, tipo: u8) {
assert!(informacion.usuarios.contains(&nombre), ERROR_USUARIO_NO_EXISTE);

informacion.usuarios.remove(&nombre);
}
}
18 changes: 18 additions & 0 deletions BaseDeDatos/tests/basededatos_tests.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
#[test_only]
module basededatos::basededatos_tests;
// uncomment this line to import the module
// use basededatos::basededatos;

const ENotImplemented: u64 = 0;

#[test]
fun test_basededatos() {
// pass
}

#[test, expected_failure(abort_code = ::basededatos::basededatos_tests::ENotImplemented)]
fun test_basededatos_fail() {
abort ENotImplemented
}
*/
4 changes: 4 additions & 0 deletions PrimerDia/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
build/*
traces/*
.trace
.coverage*
36 changes: 36 additions & 0 deletions PrimerDia/Move.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[package]
name = "PrimerDia"
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]

# 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]
primerdia = "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"

56 changes: 56 additions & 0 deletions PrimerDia/sources/primerdia.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
module primerdia::modulo {
use std::debug::print;
use std::string::utf8;

const CONSTANTE: u16 = 10;

fun suma() {
let conversion: u8 = CONSTANTE as u8;
let mut numero: u8 = 10;
numero = 15u8;
//print(&(numero + conversion));
//print(&(numero - conversion));
//print(&(numero * conversion));
//print(&(numero / conversion));
//print(&(numero == conversion));
print(&(numero != conversion));
//print(&(numero > conversion));
//print(&(numero < conversion));
//print(&(numero >= conversion));
//print(&(numero <= conversion));

//if(numero > conversion) {
//print(&(utf8(b"numero es mayor")))
//}else if (numero < conversion) {
//print(&(utf8(b"numero es menor")))
//}else {
//print(&(utf8(b"el numero es igual a al convercion")))
//}
}

fun contador(x: u8) {
let mut cuenta: u8 = 0;
//while(x > cuenta) {
//print(&cuenta);
//cuenta = cuenta + 1;
//}

loop {
cuenta = cuenta +1;
if(cuenta > x) {
break
} else if((cuenta % 2) == 1) {
continue
} else {
print(&(utf8(b"numero es par")));
};

print(&cuenta);
}
}

#[test]
fun practica() {
contador(10)
}
}
18 changes: 18 additions & 0 deletions PrimerDia/tests/primerdia_tests.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
#[test_only]
module primerdia::primerdia_tests;
// uncomment this line to import the module
// use primerdia::primerdia;

const ENotImplemented: u64 = 0;

#[test]
fun test_primerdia() {
// pass
}

#[test, expected_failure(abort_code = ::primerdia::primerdia_tests::ENotImplemented)]
fun test_primerdia_fail() {
abort ENotImplemented
}
*/