pinax-network / antelope.rs Goto Github PK
View Code? Open in Web Editor NEWAntelope Standard Library for Rust
Home Page: https://docs.rs/antelope
License: Apache License 2.0
Antelope Standard Library for Rust
Home Page: https://docs.rs/antelope
License: Apache License 2.0
https://github.com/AntelopeIO/cdt/blob/main/libraries/eosiolib/core/eosio/asset.hpp
new()
from_amount()
is_amount_within_range()
is_valid()
set_amount()
to_string()
(via Display trait)Default
(derived)Copy
(derived)Clone
(derived)Eq
(derived)AsRef
Display
From<&str>
PartialEq
PartialOrd
Neg
Sub
SubAssign
Add
AddAssign
Mul
MulAssign
Div
DivAssign
https://github.com/AntelopeIO/cdt/blob/main/libraries/eosiolib/core/eosio/symbol.hpp
new
as_ref
AsBool
as_bool
std::marker::Copy
Copy
std::clone
Clone
std::fmt
{Result, Formatter, Display}
std::convert::From
From<u64>
From<String>
From<&str>
From<MyType> for bool
PartialEq
Not
PartialOrd
(partial_cmp
& cmp
)
https://github.com/AntelopeIO/cdt/blob/main/libraries/eosiolib/core/eosio/time.hpp
AsRef
Copy
Clone
Display
PartialEq
PartialOrd
(partial_cmp
& cmp
)
Sub
SubAssign
Add
AddAssign
Using example Rust EOSIO library, doesn't produce the right SymbolCode
use eosio::*;
#[test]
fn test_symbol_code() {
assert_eq!(SymbolCode::new(5197638).to_string(), "FOO");
assert_eq!(Name::from_str("........dxboa").unwrap().as_u64(), 5197638);
}
failures:
---- abi::test_symbol_code stdout ----
thread 'abi::test_symbol_code' panicked at 'assertion failed: `(left == right)`
left: `"SOE"`,
right: `"EOS"`', substreams/eosio.token/src/abi.rs:208:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
$ eosc tools names FOO
from \ to hex hex_be hex_rev_u32 name uint64 symbol symbol_code
--------- --- ------ ----------- ---- ------ ------ -----------
name 0000000000000000 0000000000000000 ffffffff 0 0, -
symbol_code 464f4f0000000000 00000000004f4f46 ffb0b0b9 ........dxboa 5197638 70,OO FOO
https://github.com/AntelopeIO/cdt/blob/main/libraries/eosiolib/core/eosio/time.hpp#L106
AsRef
Copy
Clone
Display
From<u32>
PartialEq
PartialOrd
(partial_cmp
& cmp
)
Sub
SubAssign
Add
AddAssign
No response
No response
No response
In some cases we can't just panic when parsing invalid types on chain, due to nodeos bugs.
For example this trx: https://eos.eosq.eosnation.io/tx/ab8690feb4486a030cc16cec6e815108325b292d460b47b8c88b4a75c1959bad
Need a way to parse it into Result
.
In addition to Asset::from() -> Self
add Asset::from_str() -> Result<Self, Err>
N/A
No response
https://github.com/AntelopeIO/cdt/blob/main/libraries/eosiolib/core/eosio/symbol.hpp
new
as_ref
AsBool
as_bool
std::clone
Clone
std::fmt
{Result, Formatter, Display}
std::convert::From
From<u64>
From<String>
From<&str>
From<MyType> for bool
PartialEq
Not
PartialOrd
https://github.com/AntelopeIO/cdt/blob/main/libraries/eosiolib/core/eosio/name.hpp
AsBool
std::clone
std::fmt
{Result, Formatter, Display}
std::cmp
std::convert::From
From<u64>
From<String>
From<&str>
From<MyType> for bool
PartialEq
Not
PartialOrd
Turns out nodeos allows symbols with > 18 precision when insantiated from smart contract.
Example trx: 328fb8765ae167a709390303bc37fa9a0ce5442a29c503f8e8df59ec1c2e2cba
Panic when converting asset into string:
{"severity":"ERROR","timestamp":"2024-03-20T15:38:22.337901079Z","logger":"sink-sql","message":"stream invalid: rpc error: code = InvalidArgument desc = rpc error: code = InvalidArgument desc = step new irr: handler step new: execute modules: running executor \"antelope_tokens:map_accounts\": execute: maps wasm call: block 18777680: module \"antelope_tokens:map_accounts\": general wasm execution panicked: wasm execution failed deterministically: panic in the wasm: \"attempt to divide by zero\" at /Users/work/.cargo/registry/src/index.crates.io-6f17d22bba15001f/antelope-0.1.5/src/asset.rs:86:24","logging.googleapis.com/labels":{},"serviceContext":{"service":"unknown"}}
n/a
assert_eq!(
Asset::from_amount(10000000000000, Symbol::from("69,JIAYOUY")),
Asset::from("0.000000000000000000000000000000000000000000000000000000010000000000000 JIAYOUY")
);
### Screenshots
```bash
![DESCRIPTION](LINK.png)
No response
No response
No response
AsRef
AsBool
Copy
Clone
Display
From<u64>
From<&str>
PartialEq
PartialOrd
(partial_cmp
& cmp
)
Neg
Sub
SubAssign
Add
AddAssign
Mul
MulAssign
Div
DivAssign
https://github.com/AntelopeIO/cdt/blob/main/libraries/eosiolib/core/eosio/asset.hpp#L392
new()
from_amount()
from_asset()
get_extended_symbol()
is_valid()
to_string()
(via Display trait)Default
(derived)Copy
(derived)Clone
(derived)Eq
(derived)AsRef
Display
From<&str>
PartialEq
PartialOrd
Neg
Sub
SubAssign
Add
AddAssign
Mul
MulAssign
Div
DivAssign
Substreams WASM engine doesn't support some things from chrono
Error: rpc error: code = Internal desc = error building pipeline WASM: new wasm module: creating new instance: unknown import: `__wbindgen_placeholder__::__wbindgen_describe` has not been defined
Comes from the chrono dependency in Antelope.rs
chrono = { version = "0.4", features = ["serde"] }
use chrono::{TimeZone, Utc};
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.