Skip to content

Commit 13dab11

Browse files
committed
Resolve issues mentioned in review
1 parent 6d78d25 commit 13dab11

File tree

3 files changed

+9
-18
lines changed

3 files changed

+9
-18
lines changed

examples/psp22-extension/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "psp22_extension"
3-
version = "3.0.1"
3+
version = "4.0.0-alpha.1"
44
authors = ["Parity Technologies <admin@parity.io>"]
55
edition = "2021"
66
publish = false

examples/psp22-extension/lib.rs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ type DefaultBalance = <ink_env::DefaultEnvironment as Environment>::Balance;
1010

1111
#[ink::chain_extension]
1212
pub trait Psp22Extension {
13-
type ErrorCode = Psp22ErrorCode;
13+
type ErrorCode = Psp22Error;
1414

1515
// PSP22 Metadata interfaces
1616

@@ -77,33 +77,21 @@ pub trait Psp22Extension {
7777
) -> Result<()>;
7878
}
7979

80-
#[derive(scale::Encode, scale::Decode)]
81-
#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))]
82-
pub enum Psp22ErrorCode {
83-
TotalSupplyFailed,
84-
}
85-
8680
#[derive(scale::Encode, scale::Decode)]
8781
#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))]
8882
pub enum Psp22Error {
89-
ErrorCode(Psp22ErrorCode),
83+
TotalSupplyFailed,
9084
}
9185

9286
pub type Result<T> = core::result::Result<T, Psp22Error>;
9387

94-
impl From<Psp22ErrorCode> for Psp22Error {
95-
fn from(error_code: Psp22ErrorCode) -> Self {
96-
Self::ErrorCode(error_code)
97-
}
98-
}
99-
10088
impl From<scale::Error> for Psp22Error {
10189
fn from(_: scale::Error) -> Self {
10290
panic!("encountered unexpected invalid SCALE encoding")
10391
}
10492
}
10593

106-
impl ink_env::chain_extension::FromStatusCode for Psp22ErrorCode {
94+
impl ink_env::chain_extension::FromStatusCode for Psp22Error {
10795
fn from_status_code(status_code: u32) -> core::result::Result<(), Self> {
10896
match status_code {
10997
0 => Ok(()),
@@ -138,10 +126,13 @@ mod psp22_ext {
138126
Vec,
139127
};
140128

129+
/// A chain extension which implements the PSP-22 fungible token standard.
130+
/// For more details see <https://github.com/w3f/PSPs/blob/master/PSPs/psp-22.md>
141131
#[ink(storage)]
142132
pub struct Psp22Extension {}
143133

144134
impl Psp22Extension {
135+
/// Creates a new instance of this contract.
145136
#[ink(constructor)]
146137
pub fn new() -> Self {
147138
Psp22Extension {}

examples/psp22-extension/runtime/psp22-extension-example.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ where
210210
target: "runtime",
211211
"[ChainExtension]|call|transfer"
212212
);
213-
213+
214214
Ok(())
215215
}
216216

@@ -350,7 +350,7 @@ where
350350
target: "runtime",
351351
"[ChainExtension]|call|decrease_allowance"
352352
);
353-
353+
354354
Ok(())
355355
}
356356

0 commit comments

Comments
 (0)