pub fn fulfill_request(&mut self, account: AccountId, nonce: U128, data: Base64String) {
        self._only_authorized_node();

        // TODO: this is probably going to be too low at first, adjust
        assert!(env::prepaid_gas() - env::used_gas() > MINIMUM_CONSUMER_GAS_LIMIT, "Must provide consumer enough gas");

        // Get the request
        let account_requests = self.requests.get(&account);
        if account_requests.is_none() {
            env::panic(b"Did not find the account to fulfill.");
        }
        let nonce_u128: u128 = nonce.into();
        let request_option = account_requests.unwrap().get(&nonce_u128);
        if request_option.is_none() {
            env::panic(b"Did not find the request (nonce) to fulfill.");
        }
        let request = request_option.unwrap();

        let promise_perform_callback = env::promise_create(
            request.callback_address,
            request.callback_method.as_bytes(),
            json!({
                "nonce": nonce.clone(),
                "answer": data
            }).to_string().as_bytes(),
            0,
            SINGLE_CALL_GAS
        );

        let promise_post_callback = env::promise_then(
            promise_perform_callback,
            env::current_account_id(),
            b"fulfillment_post_callback",
            json!({
                "account": account,
                "nonce": nonce
            }).to_string().as_bytes(),
            0,
            SINGLE_CALL_GAS
        );

        env::promise_return(promise_post_callback);
    }
/// Note that the request_id here is String instead of Vec<u8> as might be expected from the Solidity contract
Note that the request_id here is String instead of Vec as might be expected from the Solidity contract
Note that the request_id here is String instead of Vec as might be expected from the Solidity contract
pub fn fulfill_request(&mut self, account: AccountId, nonce: U128, data: Base64String) {
        self._only_authorized_node();
        // TODO: this is probably going to be too low at first, adjust
        assert!(env::prepaid_gas() - env::used_gas() > MINIMUM_CONSUMER_GAS_LIMIT, "Must provide consumer enough gas");
        // Get the request
        let account_requests = self.requests.get(&account);
        if account_requests.is_none() {
            env::panic(b"Did not find the account to fulfill.");
        }
        let nonce_u128: u128 = nonce.into();
        let request_option = account_requests.unwrap().get(&nonce_u128);
        if request_option.is_none() {
            env::panic(b"Did not find the request (nonce) to fulfill.");
        }
        let request = request_option.unwrap();
        let promise_perform_callback = env::promise_create(
            request.callback_address,
            request.callback_method.as_bytes(),
            json!({
                "nonce": nonce.clone(),
                "answer": data
            }).to_string().as_bytes(),
            0,
            SINGLE_CALL_GAS
        );
        let promise_post_callback = env::promise_then(
            promise_perform_callback,
            env::current_account_id(),
            b"fulfillment_post_callback",
            json!({
                "account": account,
                "nonce": nonce
            }).to_string().as_bytes(),
            0,
            SINGLE_CALL_GAS
        );
        env::promise_return(promise_post_callback);
    }
pub fn fulfill_request ( & mut self , account : AccountId , nonce : U128 , data : Base64String ) { self . _only_authorized_node ( ) ; // TODO: this is probably going to be too low at first, adjust assert ! ( env prepaid_gas ( ) env used_gas ( ) MINIMUM_CONSUMER_GAS_LIMIT " " ) ; // Get the request let account_requests = self . requests . get ( & account ) ; if account_requests . is_none ( ) { env :: panic ( b" " ) ; } let nonce_u128 : u128 = nonce . into ( ) ; let request_option = account_requests . unwrap ( ) . get ( & nonce_u128 ) ; if request_option . is_none ( ) { env :: panic ( b" " ) ; } let request = request_option . unwrap ( ) ; let promise_perform_callback = env :: promise_create ( request . callback_address , request . callback_method . as_bytes ( ) , json ! ( { " " nonce clone ( ) " " data } ) . to_string ( ) . as_bytes ( ) , 0 , SINGLE_CALL_GAS ) ; let promise_post_callback = env :: promise_then ( promise_perform_callback , env :: current_account_id ( ) , b" " , json ! ( { " " account " " nonce } ) . to_string ( ) . as_bytes ( ) , 0 , SINGLE_CALL_GAS ) ; env :: promise_return ( promise_post_callback ) ; }
Note that the request_id here is String instead of Vec<u8> as might be expected from the Solidity contract
Note that the request_id here is String instead of Vec<u8 > as might be expected from the Solidity contract
&mut self
account
AccountId
nonce
U128
data
Base64String
&mut self
account
AccountId
nonce
U128
data
Base64String