Skip to content

Commit

Permalink
old version of 21.12 reorg
Browse files Browse the repository at this point in the history
  • Loading branch information
egasimus committed Nov 29, 2021
1 parent f96f8d0 commit cc63eff
Show file tree
Hide file tree
Showing 6,173 changed files with 195 additions and 130 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
53 changes: 25 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,38 @@

Industrial-strength tooling and components for WASM-based smart contracts.

![](https://github.com/hackbg/fadroma/blob/21.08/doc/logo.svg)
![](https://github.com/hackbg/fadroma/blob/21.08/docs/logo.svg)

## Features

In no particular order:

* Auto-generate typed contract APIs from JSON schema
* Build/upload/deploy contracts from TypeScript
* Builder pattern for response messages
* Composable admin authentication
* Composable contract core
* Composable snip20
* Contract links and callbacks
* Declare contract
* Derive contract
* Dispatch traits for handle/query message types
* Hash/checksum (SHA256)
* Humanize/Canonize traits
* Patched SigningCosmWasmClient with async broadcast mode and retries
* Pseudorandom number generator (ChaCha)
* Storage helpers
* Smart contract scaffolding
* Declare contract
* Derive contract
* Builder pattern for response messages
* Dispatch traits for handle/query message types
* Deployment and operations:
* Auto-generate typed contract APIs from JSON schema
* Build/upload/deploy contracts from TypeScript
* Patched SigningCosmWasmClient with async broadcast mode and retries
* Composable contract components:
* Composable contract core
* Composable admin authentication
* Composable SNIP20 token implementation
* Math primitives:
* `Uint256` and `Decimal` types
* Hash/checksum (SHA256)
* Pseudorandom number generator (ChaCha)
* Secret Network-specific:
* Contract links and callbacks
* Viewing key authentication
* Humanize/Canonize traits
* Composable SNIP20 token implementation
* SNIP20 client
* Storage helpers
* TODO: Terra support
* Uint256 and Decimal types
* Viewing key authentication

## Deploying smart contracts with Fadroma

## Contributing to Fadroma

Please see the [contribution guidelines](CONTRIBUTING.md).

## Contents

* `lib/` - Rust components.
* `ops/` - Generic deployment code.
* `ops-scrt/` - SecretNetwork-specific deployment code
* `ops-scrt-1.0/`, `ops-scrt-1.2` - compatibility between holodeck-2/supernova-1
* `tools` - General JS utilities used across the library
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
73 changes: 73 additions & 0 deletions crates/core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Fadroma Support for Secret Network

## Base platform primitives


## Storage

## Migrations

## Addressing

### Overview

Contracts accept API calls in `HumanAddr`
yet they need to store addresses as `CanonicalAddr`
to be resilient against address format changes.

This library handles conversion between the two address types
by implementing the `Humanize` and `Canonize` traits, each of
which has a single corresponding method `humanize`/`canonize`
which takes `&deps.api` and returns a StdResult containing the
converted struct.

### TODO

The `humanize` and `canonize` methods need to be implemented manually,
except for the minimal case (`HumanAddr.canonize`/`CanonicalAddr.humanize`).

* [ ] An attribute macro to mark address fields in structs
and automatically derive the corresponding
`humanize`/`canonize` implementations.

## Admin authentication

Composable and configurable admin functionality
that can be added to an existing Secret Network smart contract.

### Setup

1. Choose one of the two implementations
and add its handle and query messages
to yours as an enum variant with a payload.
2. Call the handle and query functions
of the selected implementation
inside your match statements
in the respective functions.
Pass `DefaultHandleImpl`/`DefaultQueryImpl` as a parameter
if you want the default method implementations.
3. (Optional) The `#[require_admin]` attribute
(found in the root of the crate) is provided
which can be used to annotate functions
that require an admin sender.
The "derive" feature (which is enabled by default) is required for this.

### Customization

If you want to change the implementation of any of the methods,
simply create a zero-sized struct and implement the trait(s)
in your chosen implementation.

Since all the methods are implemented as trait defaults,
it is possible to override only the desired methods in your `impl`.

Then in step 2 above, pass your struct instead of `DefaultHandleImpl`/`DefaultQueryImpl`.

## User authentication

## Inter-contract communication

### SNIP20 token support

## Utilities
Helpful functions and types for CosmWasm based smart contract development.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
74 changes: 74 additions & 0 deletions crates/declare-contract/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Fadroma: Contract scaffolding: Declarative macro

## Contract scaffold

### Overview

This library consists of 3 layers, 1 test helper and 1 deprecated feature.

#### Contract helper: `contract.rs`

Through
The one which defines your API.
* `contract_impl.rs` - The one which defines your API implementation.
* `contract_binding.rs` - The one which automatically implements environment bindings
(i.e. defines entry points for the external environment to call into your contract.

#### Test helper: `contract_harness.rs`

#### State

### Example usage

This contract implements a basic calculator.
Compare it with [the counter implementation in secret-template](https://github.com/enigmampc/secret-template/tree/master/src)
for perspective.

```rust
#[macro_use] extern crate fadroma;
contract!(
[State] {
value: i64
}

[Init] (deps, env, msg: {
initial_value: i64
}) {
State { value: initial_value }
}

[Query] (deps, state, msg) {
Equals () {
state.value
}
}

[Response] {
[Equals] { value: i64 }
}

[Handle] (deps, env, sender, state, msg) {
Add (augend: i64) {
state.value += augend;
ok!(state)
}
Sub (subtrahend: i64) {
state.value -= subtrahend;
ok!(state)
}
Mul (multiplier: i64) {
state.value *= multiplier;
ok!(state)
}
Div (divisor: i64) {
match divisor {
0 => err_msg(state, "division by zero"),
_ => {
state.value /= divisor;
ok!(state)
}
}
}
}
);
```
15 changes: 15 additions & 0 deletions crates/declare-contract/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
pub mod scrt_contract;
pub use scrt_contract::*;

pub mod scrt_contract_api;
pub use scrt_contract_api::*;

pub mod scrt_contract_binding;
pub use scrt_contract_binding::*;

pub mod scrt_contract_harness;
pub use scrt_contract_harness::*;

pub mod scrt_contract_impl;

pub mod scrt_contract_state;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions crates/derive-contract/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Fadroma: Contract scaffolding: Procedural macro
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
80 changes: 1 addition & 79 deletions lib/README.md → crates/scrt/README.md
Original file line number Diff line number Diff line change
@@ -1,86 +1,7 @@
# Fadroma Support for Secret Network

This crate reexports all the other crates
via Cargo feature flags.

This way you can import 1 Fadroma crate
and not have to maintain the version
of each component manually.

## Base platform primitives

## Contract scaffold

### Overview

This library consists of 3 layers, 1 test helper and 1 deprecated feature.

#### Contract helper: `contract.rs`

Through
The one which defines your API.
* `contract_impl.rs` - The one which defines your API implementation.
* `contract_binding.rs` - The one which automatically implements environment bindings
(i.e. defines entry points for the external environment to call into your contract.

#### Test helper: `contract_harness.rs`

#### State

### Example usage

This contract implements a basic calculator.
Compare it with [the counter implementation in secret-template](https://github.com/enigmampc/secret-template/tree/master/src)
for perspective.

```rust
#[macro_use] extern crate fadroma;
contract!(
[State] {
value: i64
}

[Init] (deps, env, msg: {
initial_value: i64
}) {
State { value: initial_value }
}

[Query] (deps, state, msg) {
Equals () {
state.value
}
}

[Response] {
[Equals] { value: i64 }
}

[Handle] (deps, env, sender, state, msg) {
Add (augend: i64) {
state.value += augend;
ok!(state)
}
Sub (subtrahend: i64) {
state.value -= subtrahend;
ok!(state)
}
Mul (multiplier: i64) {
state.value *= multiplier;
ok!(state)
}
Div (divisor: i64) {
match divisor {
0 => err_msg(state, "division by zero"),
_ => {
state.value /= divisor;
ok!(state)
}
}
}
}
);
```

## Storage

Expand Down Expand Up @@ -150,3 +71,4 @@ Then in step 2 above, pass your struct instead of `DefaultHandleImpl`/`DefaultQu

## Utilities
Helpful functions and types for CosmWasm based smart contract development.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 6 additions & 8 deletions lib/scrt_permit.rs → crates/scrt/permit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ use cosmwasm_std::{
Binary, HumanAddr, Uint128, Extern, Storage, Api,
Querier, StdError, StdResult, to_binary
};
#[cfg(not(test))]
use cosmwasm_std::CanonicalAddr;

use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
#[cfg(not(test))]
use ripemd160::{Digest, Ripemd160};
#[cfg(not(test))]
use secp256k1::Secp256k1;
#[cfg(not(test))]
use sha2::Sha256;

#[cfg(not(test))] use cosmwasm_std::CanonicalAddr;
#[cfg(not(test))] use ripemd160::{Digest, Ripemd160};
#[cfg(not(test))] use secp256k1::Secp256k1;
#[cfg(not(test))] use sha2::Sha256;

pub trait Permission: Serialize + JsonSchema + Clone + PartialEq { }

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit cc63eff

Please sign in to comment.