Skip to content

Commit

Permalink
Merge pull request #4 from Laina-Protocol/develop
Browse files Browse the repository at this point in the history
Pre-poc product
  • Loading branch information
Teolhyn authored Jul 17, 2024
2 parents f2aab5d + 47e59f3 commit e541e19
Show file tree
Hide file tree
Showing 19 changed files with 2,986 additions and 2,490 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.soroban
target/*
.env
node_modules
packages/*
CONTRIBUTING.md
102 changes: 70 additions & 32 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ resolver = "2"
members = ["contracts/*"]

[workspace.dependencies]
soroban-sdk = "20.3.2"
soroban-token-sdk = { version = "20.0.0"}
soroban-sdk = "21.0.1-preview.3"
soroban-token-sdk = { version = "21.0.1-preview.3"}

[profile.release]
opt-level = "z"
Expand Down
10 changes: 9 additions & 1 deletion astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import { defineConfig } from 'astro/config';
import basicSsl from '@vitejs/plugin-basic-ssl'

// https://astro.build/config
export default defineConfig({});
export default defineConfig({
vite: {
plugins: [basicSsl()],
server: {
https: true,
},
},
});
16 changes: 16 additions & 0 deletions contracts/factory/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "factory"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
crate-type = ["cdylib"]
doctest = false

[dependencies]
soroban-sdk = { workspace = true }

[dev-dependencies]
soroban-sdk = { workspace = true, features = ["testutils"] }
43 changes: 43 additions & 0 deletions contracts/factory/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#![no_std]

use soroban_sdk::{contract, contractimpl, Address, BytesN, Env, Symbol, Val, Vec};

#[contract]
pub struct Deployer;

#[contractimpl]
impl Deployer {
/// Deploy the contract Wasm and after deployment invoke the init function
/// of the contract with the given arguments.
///
/// This has to be authorized by `deployer` (unless the `Deployer` instance
/// itself is used as deployer). This way the whole operation is atomic
/// and it's not possible to frontrun the contract initialization.
///
/// Returns the contract address and result of the init function.
pub fn deploy(
env: Env,
deployer: Address,
wasm_hash: BytesN<32>,
salt: BytesN<32>,
init_fn: Symbol,
init_args: Vec<Val>,
) -> Address {
// Skip authorization if deployer is the current contract.
if deployer != env.current_contract_address() {
deployer.require_auth();
}

// Deploy the contract using the uploaded Wasm with given hash.
let deployed_address = env
.deployer()
.with_address(deployer, salt)
.deploy(wasm_hash);

// Invoke the init function with the given arguments.
let _res: Val = env.invoke_contract(&deployed_address, &init_fn, init_args);
// Return the contract ID of the deployed contract and the result of
// invoking the init result.
deployed_address
}
}
16 changes: 16 additions & 0 deletions contracts/loan/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "loan"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
crate-type = ["cdylib"]
doctest = false

[dependencies]
soroban-sdk = { workspace = true }

[dev-dependencies]
soroban-sdk = { workspace = true, features = ["testutils"] }
Loading

0 comments on commit e541e19

Please sign in to comment.