Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #63 from AntelopeIO/larryk85/docs
Browse files Browse the repository at this point in the history
Docs changes and a couple of small fixes.
  • Loading branch information
Bucky Kittinger authored May 4, 2023
2 parents 9955a4c + 159b72f commit 8fb86d2
Show file tree
Hide file tree
Showing 27 changed files with 306 additions and 1,287 deletions.
6 changes: 6 additions & 0 deletions docs/examples/hello-world/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This example project houses a simple 'hello world' project and smart contract.

To build run the command `antler-proj build`,
this should create the hello_world.wasm and hello_world.abi file needed for deployment.

Look at documentation for DUNE or cleos for how to deploy and call the actions.
8 changes: 8 additions & 0 deletions docs/examples/hello-world/apps/hello/hello.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <hello.hpp>

[[eosio::action]]
void hello::hi( name nm ) {
/* generated example action */
print_f("Hello, world : %", nm);
}

13 changes: 13 additions & 0 deletions docs/examples/hello-world/include/hello/hello.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <eosio/eosio.hpp>

using namespace eosio;

class [[eosio::contract]] hello: public contract {
public:
using contract::contract;

[[eosio::action]]
void hi( name nm );
using hi_action = action_wrapper<"hi"_n, &hello::hi>;
};

7 changes: 7 additions & 0 deletions docs/examples/hello-world/project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
project: hello-world
version: 1.0.0
apps:
- name: hello
lang: CXX
compile_options: ""
link_options: ""
10 changes: 10 additions & 0 deletions docs/examples/lib_usage_example/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
This project houses a simple project that creates and utilizes C and C++ libraries for smart contract development.

The `print_number` C++ library houses a small function that will print a number of type `int`.
The `print_float` C library houses a small function that will print a number of type float.

The smart contract app `lib_usage` depends on the two above libraries.

The `lib_usage.wasm` and `lib_usage.abi` should be produced by this project for deployment.

Look at documentation for DUNE or cleos for how to deploy and call the actions.
10 changes: 10 additions & 0 deletions docs/examples/lib_usage_example/apps/lib_usage/lib_usage.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <lib_usage.hpp>

#include <print_number.hpp>
#include <print_float.h>

[[eosio::action]]
void lib_usage::exec(int inum, float fnum) {
print_num(inum); // C++ library call
print_float(fnum); // C library call
}
13 changes: 13 additions & 0 deletions docs/examples/lib_usage_example/include/lib_usage/lib_usage.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <eosio/eosio.hpp>

using namespace eosio;

class [[eosio::contract]] lib_usage: public contract {
public:
using contract::contract;

[[eosio::action]]
void exec(int, float);
using exec_action = action_wrapper<"exec"_n, &lib_usage::exec>;
};

11 changes: 11 additions & 0 deletions docs/examples/lib_usage_example/include/print_float/print_float.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

void print_float(float);

#ifdef __cplusplus
}
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

void print_num(int);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include <stdio.h>

void print_float(float f) {
printf("%f\n", f);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <cstdio>

#include <eosio/print.hpp>

void print_num(int num) {
eosio::print_f("%\n", num);
}
27 changes: 27 additions & 0 deletions docs/examples/lib_usage_example/project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
project: lib_usage
version: 1.0.0
apps:
- name: lib_usage
lang: CXX
compile_options: ""
link_options: ""
depends:
- name: print_float
location: ""
tag: ""
release: ""
hash: ""
- name: print_number
location: ""
tag: ""
release: ""
hash: ""
libs:
- name: print_float
lang: C
compile_options: ""
link_options: ""
- name: print_number
lang: CXX
compile_options: ""
link_options: ""
5 changes: 5 additions & 0 deletions docs/examples/send-inline-example/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This project creates the same `hello-world` contract as the hello-world project and a new `send-inline` project that utilizes that contract.

The `hello_world.wasm`, `send_inline.wasm`, `hello_world.abi`, and `send_inline.abi` should be produced by this project for deployment.

Look at documentation for DUNE or cleos for how to deploy and call the actions.
8 changes: 8 additions & 0 deletions docs/examples/send-inline-example/apps/hello/hello.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <hello.hpp>

[[eosio::action]]
void hello::hi( name nm ) {
/* generated example action */
print_f("Hello : %", nm);
}

12 changes: 12 additions & 0 deletions docs/examples/send-inline-example/apps/send_inline/send_inline.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <send_inline.hpp>

#include <hello.hpp>

[[eosio::action]]
void send_inline::test( name user, name inline_code ) {
// the code the contract is deployed on and a set of permissions
hello::hi_action hi (inline_code, {_self, "active"_n});

hi.send(user);
}

13 changes: 13 additions & 0 deletions docs/examples/send-inline-example/include/hello/hello.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <eosio/eosio.hpp>

using namespace eosio;

class [[eosio::contract]] hello: public contract {
public:
using contract::contract;

[[eosio::action]]
void hi( name nm );
using hi_action = action_wrapper<"hi"_n, &hello::hi>;
};

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <eosio/eosio.hpp>

using namespace eosio;

class [[eosio::contract]] send_inline: public contract {
public:
using contract::contract;

[[eosio::action]]
void test( name user, name inline_code );

using test_action = action_wrapper<"test"_n, &send_inline::test>;
};

17 changes: 17 additions & 0 deletions docs/examples/send-inline-example/project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
project: send_inline
version: 0.0.0
apps:
- name: send_inline
lang: CXX
compile_options: ""
link_options: ""
depends:
- name: hello
location: ""
tag: ""
release: ""
hash: ""
- name: hello
lang: CXX
compile_options: ""
link_options: ""
File renamed without changes.
44 changes: 0 additions & 44 deletions docs/sample1.yaml

This file was deleted.

35 changes: 0 additions & 35 deletions docs/sample2.yaml

This file was deleted.

33 changes: 0 additions & 33 deletions docs/sample3.yaml

This file was deleted.

Loading

0 comments on commit 8fb86d2

Please sign in to comment.