An example of generic data type, providing different types of pool. We can implement new type of pool without do migrating.
#[derive(BorshSerialize, BorshDeserialize, Debug)]
pub enum Pool {
SimplePool(SimplePool),
// Comment this line for the first deployment
// ComplexPool(ComplexPool),
}
// Comment this function for the first deployment
// pub fn create_complex_pool(&mut self) {
// let pool_id = self.pools.len() + 1;
// self.pools.insert(&pool_id, &Pool::ComplexPool(ComplexPool {prop_b: pool_id as u32}));
// }
build.sh
deploy.sh
near call dev-1647959336462-77896213135645 create_simple_pool --accountId dev-1647959336462-77896213135645
near view dev-1647959336462-77896213135645 get_pools
near call dev-1647959336462-77896213135645 create_simple_pool --accountId dev-1647959336462-77896213135645
near view dev-1647959336462-77896213135645 get_pools