-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
93 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,11 @@ | ||
type ManualReply = variant { | ||
NoError; | ||
CanisterError; | ||
SysTransient; | ||
DestinationInvalid; | ||
Unknown; | ||
SysFatal; | ||
CanisterReject; | ||
}; | ||
service : () -> { | ||
getRejectionCodeCanisterError : () -> (ManualReply); | ||
getRejectionCodeCanisterReject : () -> (ManualReply); | ||
getRejectionCodeDestinationInvalid : () -> (ManualReply); | ||
getRejectionCodeNoError : () -> (ManualReply); | ||
getRejectionMessage : (text) -> (text); | ||
} | ||
type rec_0 = variant {NoError; CanisterError; SysTransient; DestinationInvalid; Unknown; SysFatal; CanisterReject}; | ||
type rec_1 = variant {NoError; CanisterError; SysTransient; DestinationInvalid; Unknown; SysFatal; CanisterReject}; | ||
type rec_2 = variant {NoError; CanisterError; SysTransient; DestinationInvalid; Unknown; SysFatal; CanisterReject}; | ||
type rec_3 = variant {NoError; CanisterError; SysTransient; DestinationInvalid; Unknown; SysFatal; CanisterReject}; | ||
service: () -> { | ||
getRejectionCodeNoError: () -> (rec_0); | ||
getRejectionCodeDestinationInvalid: () -> (rec_1); | ||
getRejectionCodeCanisterReject: () -> (rec_2); | ||
getRejectionCodeCanisterError: () -> (rec_3); | ||
getRejectionMessage: (text) -> (text); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
service : () -> { | ||
accept : () -> (bool) query; | ||
error : () -> (empty) query; | ||
reject : (text) -> (empty) query; | ||
} | ||
service: () -> { | ||
reject: (text) -> (empty) query; | ||
accept: () -> (bool) query; | ||
error: () -> (empty) query; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/compiler/typescript_to_rust/azle_generate_rearchitecture/src/ic/reject_code.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use proc_macro2::TokenStream; | ||
use quote::quote; | ||
|
||
pub fn generate() -> TokenStream { | ||
quote! { | ||
fn reject_code<'a>( | ||
context: &'a JSContextRef, | ||
_this: &CallbackArg, | ||
_args: &[CallbackArg], | ||
) -> Result<JSValueRef<'a>, anyhow::Error> { | ||
let reject_code = ic_cdk::api::call::reject_code(); | ||
|
||
let reject_code_as_u8 = match reject_code { | ||
ic_cdk::api::call::RejectionCode::NoError => 0, | ||
ic_cdk::api::call::RejectionCode::SysFatal => 1, | ||
ic_cdk::api::call::RejectionCode::SysTransient => 2, | ||
ic_cdk::api::call::RejectionCode::DestinationInvalid => 3, | ||
ic_cdk::api::call::RejectionCode::CanisterReject => 4, | ||
ic_cdk::api::call::RejectionCode::CanisterError => 5, | ||
ic_cdk::api::call::RejectionCode::Unknown => 6, | ||
}; | ||
|
||
let reject_code_as_js_value: JSValue = reject_code_as_u8.into(); | ||
|
||
to_qjs_value(&context, &reject_code_as_js_value) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters