Skip to content

Commit

Permalink
0.3.22
Browse files Browse the repository at this point in the history
0.3.22
  • Loading branch information
andreespirela authored Mar 27, 2023
1 parent d75e2e6 commit ebf412b
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 9 deletions.
10 changes: 9 additions & 1 deletion crates/executor/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub async fn simulate_contract(
maybe_cache: Option<bool>,
maybe_bundled_contract: Option<bool>,
maybe_settings: Option<HashMap<String, deno_core::serde_json::Value>>,
maybe_exm_context: Option<deno_core::serde_json::Value>,
maybe_exm_context_str: Option<String>,
maybe_contract_source: Option<ManualLoadedContract>,
) -> Result<ExecuteResult, AnyError> {
let shared_id = contract_id.clone();
Expand Down Expand Up @@ -80,6 +80,14 @@ pub async fn simulate_contract(
);

if loaded_contract.is_ok() {
let maybe_exm_context = {
if let Some(context_str) = maybe_exm_context_str {
Some(deno_core::serde_json::from_str(&context_str[..]).unwrap())
} else {
None
}
};

let execute = raw_execute_contract(
contract_id,
loaded_contract.unwrap(),
Expand Down
2 changes: 1 addition & 1 deletion js/napi/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export interface SimulateExecutionContext {
maybeCache?: boolean | undefined | null
maybeBundledContract?: boolean | undefined | null
maybeSettings?: Record<string, any> | undefined | null
maybeExmContext?: any | undefined | null
maybeExmContext?: string | undefined | null
}
export function simulateContract(context: SimulateExecutionContext): Promise<ExecuteContractResult>
export function executeContract(tx: string, maybeHeight?: number | undefined | null, maybeConfig?: ExecuteConfig | undefined | null): Promise<ExecuteContractResult>
38 changes: 38 additions & 0 deletions js/napi/napi.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,42 @@ export async function handle(state, action) {
});
expect(simulate.errors["ABCD"]).toContain("Ups")
});

test("Deterministic fetch lazy evaluation", async () => {
const buffer = new TextEncoder().encode("export async function handle(state, action) {\n" +
" const ethTxId = action.input.id;\n" +
" const fetchTx = await EXM.deterministicFetch(`https://api.blockcypher.com/v1/eth/main/txs/${ethTxId}`);\n" +
"EXM.print(fetchTx);" +
" const txJson = fetchTx.asJSON();\n" +
" state[ethTxId] = txJson.fees;\n" +
" return {\n" +
" state,\n" +
" result: txJson\n" +
" }\n" +
"}");

const simulate = await simulateContract({
contractId: "",
maybeContractSource: {
contractType: SimulateContractType.JAVASCRIPT,
contractSrc: buffer
},
interactions: [{
id: "ABCD",
owner: "2asdaskdsapdk012",
quantity: "1000",
reward: "203123921",
target: "none",
tags: [],
input: JSON.stringify({"id":"8f39fb4940c084460da00a876a521ef2ba84ad6ea8d2f5628c9f1f8aeb395342"})
}],
contractInitState: JSON.stringify({}),
maybeSettings: {
'LAZY_EVALUATION': true
},
maybeExmContext: `{"requests":{"d1b57dac5f734a8831b808bdd5dfdb9cd0d12a56014190982ce744d99a9a661c":{"type":"basic","url":"https://api.blockcypher.com/v1/eth/main/txs/8f39fb4940c084460da00a876a521ef2ba84ad6ea8d2f5628c9f1f8aeb395342","statusText":"OK","status":127,"redirected":false,"ok":true,"headers":{"x-ratelimit-remaining":"99","access-control-allow-methods":"GET, POST, PUT, DELETE","server":"cloudflare","cf-cache-status":"DYNAMIC","access-control-allow-origin":"*","content-type":"application/json","date":"Tue, 21 Mar 2023 18:14:43 GMT","access-control-allow-headers":"Origin, X-Requested-With, Content-Type, Accept","cf-ray":"7ab82d1aed372937-ORD-X"},"vector":[123,10,32,32,34,98,108,111,99,107,95,104,97,115,104,34,58,32,34,98,51,53,50,54,53,57,54,53,102,54,102,49,52,99,53,100,54,57,50,98,50,48,51,48,57,50,50,102,99,101,53,51,48,54,55,102,99,48,101,57,100,56,99,56,52,57,48,99,51,49,100,52,101,99,100,51,101,52,54,53,48,48,99,34,44,10,32,32,34,98,108,111,99,107,95,104,101,105,103,104,116,34,58,32,49,53,54,52,48,52,48,44,10,32,32,34,98,108,111,99,107,95,105,110,100,101,120,34,58,32,48,44,10,32,32,34,104,97,115,104,34,58,32,34,56,102,51,57,102,98,52,57,52,48,99,48,56,52,52,54,48,100,97,48,48,97,56,55,54,97,53,50,49,101,102,50,98,97,56,52,97,100,54,101,97,56,100,50,102,53,54,50,56,99,57,102,49,102,56,97,101,98,51,57,53,51,52,50,34,44,10,32,32,34,97,100,100,114,101,115,115,101,115,34,58,32,91,10,32,32,32,32,34,52,101,57,100,56,98,52,102,49,56,100,57,56,52,102,54,102,48,99,56,56,100,48,55,101,52,98,51,57,50,48,49,101,56,50,53,99,100,49,55,34,44,10,32,32,32,32,34,55,51,56,100,49,52,53,102,97,97,98,98,49,101,48,48,99,102,53,97,48,49,55,53,56,56,97,57,99,48,102,57,57,56,51,49,56,48,49,50,34,10,32,32,93,44,10,32,32,34,116,111,116,97,108,34,58,32,49,48,49,53,51,49,53,51,51,53,57,52,51,55,51,50,54,44,10,32,32,34,102,101,101,115,34,58,32,49,53,57,53,53,56,48,48,48,48,48,48,48,48,48,48,44,10,32,32,34,115,105,122,101,34,58,32,49,49,54,44,10,32,32,34,103,97,115,95,108,105,109,105,116,34,58,32,53,48,48,48,48,48,44,10,32,32,34,103,97,115,95,117,115,101,100,34,58,32,55,57,55,55,57,44,10,32,32,34,103,97,115,95,112,114,105,99,101,34,58,32,50,48,48,48,48,48,48,48,48,48,48,44,10,32,32,34,103,97,115,95,116,105,112,95,99,97,112,34,58,32,50,48,48,48,48,48,48,48,48,48,48,44,10,32,32,34,103,97,115,95,102,101,101,95,99,97,112,34,58,32,50,48,48,48,48,48,48,48,48,48,48,44,10,32,32,34,99,111,110,102,105,114,109,101,100,34,58,32,34,50,48,49,54,45,48,53,45,50,50,84,49,50,58,52,51,58,48,48,90,34,44,10,32,32,34,114,101,99,101,105,118,101,100,34,58,32,34,50,48,49,54,45,48,53,45,50,50,84,49,50,58,52,51,58,48,48,90,34,44,10,32,32,34,118,101,114,34,58,32,48,44,10,32,32,34,100,111,117,98,108,101,95,115,112,101,110,100,34,58,32,102,97,108,115,101,44,10,32,32,34,118,105,110,95,115,122,34,58,32,49,44,10,32,32,34,118,111,117,116,95,115,122,34,58,32,49,44,10,32,32,34,105,110,116,101,114,110,97,108,95,116,120,105,100,115,34,58,32,91,10,32,32,32,32,34,100,100,49,48,55,99,56,52,56,56,56,54,55,102,100,53,51,99,48,97,97,51,98,102,49,100,56,97,52,55,56,97,48,55,55,101,99,54,55,97,102,55,53,56,52,50,100,50,52,102,49,97,54,52,101,98,52,52,101,52,100,57,48,50,34,44,10,32,32,32,32,34,57,97,57,56,54,55,56,100,50,48,57,57,49,48,102,55,48,98,100,101,100,54,50,52,102,50,99,53,99,49,56,101,100,49,55,100,52,49,55,55,53,50,48,55,50,100,52,49,99,53,100,54,49,98,52,50,99,50,55,55,51,52,56,99,34,44,10,32,32,32,32,34,97,100,57,53,57,57,54,49,102,52,54,54,54,51,102,55,56,53,101,49,101,48,97,48,98,50,54,53,54,57,54,48,98,53,100,50,55,48,54,49,48,57,55,99,53,48,57,50,99,52,101,54,56,57,54,52,98,102,97,102,48,48,52,49,34,44,10,32,32,32,32,34,53,97,50,51,100,55,52,97,52,56,52,101,99,53,56,98,50,49,49,50,54,52,56,56,56,56,52,54,98,101,54,100,55,52,50,56,99,51,51,98,101,57,51,50,50,51,51,57,54,101,102,102,51,54,50,54,101,48,51,54,97,55,102,52,34,44,10,32,32,32,32,34,55,51,57,48,54,98,50,102,49,97,49,100,55,102,100,49,55,99,55,55,54,56,52,101,53,101,56,49,49,97,101,56,55,49,48,101,52,97,48,51,50,53,48,49,48,57,48,100,97,50,54,52,55,49,50,100,98,55,97,52,56,101,55,97,34,44,10,32,32,32,32,34,53,51,99,101,56,56,101,49,99,102,57,56,98,51,55,102,98,54,52,99,49,54,49,50,49,98,52,54,52,49,100,100,101,54,53,50,57,48,56,51,56,99,101,48,98,100,101,54,99,98,49,99,51,49,57,100,102,51,101,102,56,102,102,57,34,44,10,32,32,32,32,34,50,57,98,99,52,101,55,102,97,50,100,98,50,56,98,48,97,50,101,102,57,101,55,97,53,101,48,55,51,99,99,55,53,51,50,101,54,48,57,102,55,53,50,98,50,101,98,48,98,53,55,51,49,98,48,99,54,98,57,50,54,97,50,99,34,44,10,32,32,32,32,34,52,97,57,97,102,99,53,97,54,56,48,57,49,55,57,53,53,101,55,56,49,98,56,57,48,54,56,56,49,52,51,102,53,54,98,97,100,99,55,54,55,56,53,97,102,57,56,55,53,51,100,53,50,54,55,50,55,48,100,55,100,56,48,57,34,10,32,32,93,44,10,32,32,34,99,111,110,102,105,114,109,97,116,105,111,110,115,34,58,32,49,53,51,49,51,54,56,48,44,10,32,32,34,99,111,110,102,105,100,101,110,99,101,34,58,32,49,44,10,32,32,34,105,110,112,117,116,115,34,58,32,91,10,32,32,32,32,123,10,32,32,32,32,32,32,34,115,101,113,117,101,110,99,101,34,58,32,50,55,51,44,10,32,32,32,32,32,32,34,97,100,100,114,101,115,115,101,115,34,58,32,91,10,32,32,32,32,32,32,32,32,34,55,51,56,100,49,52,53,102,97,97,98,98,49,101,48,48,99,102,53,97,48,49,55,53,56,56,97,57,99,48,102,57,57,56,51,49,56,48,49,50,34,10,32,32,32,32,32,32,93,10,32,32,32,32,125,10,32,32,93,44,10,32,32,34,111,117,116,112,117,116,115,34,58,32,91,10,32,32,32,32,123,10,32,32,32,32,32,32,34,118,97,108,117,101,34,58,32,49,48,49,53,51,49,53,51,51,53,57,52,51,55,51,50,54,44,10,32,32,32,32,32,32,34,115,99,114,105,112,116,34,58,32,34,52,101,55,49,100,57,50,100,34,44,10,32,32,32,32,32,32,34,97,100,100,114,101,115,115,101,115,34,58,32,91,10,32,32,32,32,32,32,32,32,34,52,101,57,100,56,98,52,102,49,56,100,57,56,52,102,54,102,48,99,56,56,100,48,55,101,52,98,51,57,50,48,49,101,56,50,53,99,100,49,55,34,10,32,32,32,32,32,32,93,10,32,32,32,32,125,10,32,32,93,10,125]}}}`
});
expect(simulate.state).toEqual({"8f39fb4940c084460da00a876a521ef2ba84ad6ea8d2f5628c9f1f8aeb395342":1595580000000000});
});

})
2 changes: 1 addition & 1 deletion js/napi/npm/darwin-arm64/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@three-em/node-darwin-arm64",
"version": "0.3.21",
"version": "0.3.22",
"os": [
"darwin"
],
Expand Down
2 changes: 1 addition & 1 deletion js/napi/npm/darwin-x64/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@three-em/node-darwin-x64",
"version": "0.3.21",
"version": "0.3.22",
"os": [
"darwin"
],
Expand Down
2 changes: 1 addition & 1 deletion js/napi/npm/linux-x64-gnu/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@three-em/node-linux-x64-gnu",
"version": "0.3.21",
"version": "0.3.22",
"os": [
"linux"
],
Expand Down
2 changes: 1 addition & 1 deletion js/napi/npm/win32-x64-msvc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@three-em/node-win32-x64-msvc",
"version": "0.3.21",
"version": "0.3.22",
"os": [
"win32"
],
Expand Down
2 changes: 1 addition & 1 deletion js/napi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@three-em/node",
"version": "0.3.21",
"version": "0.3.22",
"author": "Divy Srivastava <[email protected]>",
"license": "MIT",
"napi": {
Expand Down
42 changes: 40 additions & 2 deletions js/napi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub struct SimulateExecutionContext {
pub maybe_cache: Option<bool>,
pub maybe_bundled_contract: Option<bool>,
pub maybe_settings: Option<HashMap<String, serde_json::Value>>,
pub maybe_exm_context: Option<serde_json::Value>,
pub maybe_exm_context: Option<String>,
}

// Convert the ValidityTable from an IndexMap to HashMap
Expand Down Expand Up @@ -315,6 +315,7 @@ mod tests {
ExecuteConfig, SimulateContractType, SimulateExecutionContext,
SimulateInput,
};
use std::collections::HashMap;
use three_em_arweave::arweave::get_cache;

// #[tokio::test(flavor = "multi_thread", worker_threads = 1)]
Expand Down Expand Up @@ -557,7 +558,7 @@ mod tests {
#[tokio::test]
pub async fn simulate_contract_ark() {
let contract_source_bytes =
include_bytes!("../../../testdata/contracts/ark.js");
include_bytes!("../../../testdata/contracts/ark.js");
let contract_source_vec = contract_source_bytes.to_vec();
let execution_context: SimulateExecutionContext =
SimulateExecutionContext {
Expand Down Expand Up @@ -595,4 +596,41 @@ mod tests {
let contract_result = contract.state;
let str_state = contract_result.to_string();
}

#[tokio::test]
pub async fn simulate_deterministic_fetch_lazy() {
let mut sets: HashMap<String, serde_json::Value> = HashMap::new();
sets.insert("LAZY_EVALUATION".to_string(), serde_json::Value::Bool(true));

let contract_source_bytes =
include_bytes!("../../../testdata/contracts/deterministic-fetch.js");
let contract_source_vec = contract_source_bytes.to_vec();
let execution_context: SimulateExecutionContext =
SimulateExecutionContext {
contract_id: String::new(),
interactions: vec![SimulateInput {
id: String::from("abcd"),
owner: String::from("210392sdaspd-asdm-asd_sa0d1293-lc"),
quantity: String::from("12301"),
reward: String::from("12931293"),
target: None,
tags: vec![],
block: None,
input: serde_json::json!({"id":"8f39fb4940c084460da00a876a521ef2ba84ad6ea8d2f5628c9f1f8aeb395342"}).to_string(),
}],
contract_init_state: Some(String::from(include_str!("../../../testdata/contracts/deterministic-fetch.json"))),
maybe_config: None,
maybe_cache: Some(false),
maybe_bundled_contract: None,
maybe_settings: Some(sets),
maybe_exm_context: Some((r#"{"requests":{"d1b57dac5f734a8831b808bdd5dfdb9cd0d12a56014190982ce744d99a9a661c":{"type":"basic","url":"https://api.blockcypher.com/v1/eth/main/txs/8f39fb4940c084460da00a876a521ef2ba84ad6ea8d2f5628c9f1f8aeb395342","statusText":"OK","status":127,"redirected":false,"ok":true,"headers":{"x-ratelimit-remaining":"99","access-control-allow-methods":"GET, POST, PUT, DELETE","server":"cloudflare","cf-cache-status":"DYNAMIC","access-control-allow-origin":"*","content-type":"application/json","date":"Tue, 21 Mar 2023 18:14:43 GMT","access-control-allow-headers":"Origin, X-Requested-With, Content-Type, Accept","cf-ray":"7ab82d1aed372937-ORD-X"},"vector":[123,10,32,32,34,98,108,111,99,107,95,104,97,115,104,34,58,32,34,98,51,53,50,54,53,57,54,53,102,54,102,49,52,99,53,100,54,57,50,98,50,48,51,48,57,50,50,102,99,101,53,51,48,54,55,102,99,48,101,57,100,56,99,56,52,57,48,99,51,49,100,52,101,99,100,51,101,52,54,53,48,48,99,34,44,10,32,32,34,98,108,111,99,107,95,104,101,105,103,104,116,34,58,32,49,53,54,52,48,52,48,44,10,32,32,34,98,108,111,99,107,95,105,110,100,101,120,34,58,32,48,44,10,32,32,34,104,97,115,104,34,58,32,34,56,102,51,57,102,98,52,57,52,48,99,48,56,52,52,54,48,100,97,48,48,97,56,55,54,97,53,50,49,101,102,50,98,97,56,52,97,100,54,101,97,56,100,50,102,53,54,50,56,99,57,102,49,102,56,97,101,98,51,57,53,51,52,50,34,44,10,32,32,34,97,100,100,114,101,115,115,101,115,34,58,32,91,10,32,32,32,32,34,52,101,57,100,56,98,52,102,49,56,100,57,56,52,102,54,102,48,99,56,56,100,48,55,101,52,98,51,57,50,48,49,101,56,50,53,99,100,49,55,34,44,10,32,32,32,32,34,55,51,56,100,49,52,53,102,97,97,98,98,49,101,48,48,99,102,53,97,48,49,55,53,56,56,97,57,99,48,102,57,57,56,51,49,56,48,49,50,34,10,32,32,93,44,10,32,32,34,116,111,116,97,108,34,58,32,49,48,49,53,51,49,53,51,51,53,57,52,51,55,51,50,54,44,10,32,32,34,102,101,101,115,34,58,32,49,53,57,53,53,56,48,48,48,48,48,48,48,48,48,48,44,10,32,32,34,115,105,122,101,34,58,32,49,49,54,44,10,32,32,34,103,97,115,95,108,105,109,105,116,34,58,32,53,48,48,48,48,48,44,10,32,32,34,103,97,115,95,117,115,101,100,34,58,32,55,57,55,55,57,44,10,32,32,34,103,97,115,95,112,114,105,99,101,34,58,32,50,48,48,48,48,48,48,48,48,48,48,44,10,32,32,34,103,97,115,95,116,105,112,95,99,97,112,34,58,32,50,48,48,48,48,48,48,48,48,48,48,44,10,32,32,34,103,97,115,95,102,101,101,95,99,97,112,34,58,32,50,48,48,48,48,48,48,48,48,48,48,44,10,32,32,34,99,111,110,102,105,114,109,101,100,34,58,32,34,50,48,49,54,45,48,53,45,50,50,84,49,50,58,52,51,58,48,48,90,34,44,10,32,32,34,114,101,99,101,105,118,101,100,34,58,32,34,50,48,49,54,45,48,53,45,50,50,84,49,50,58,52,51,58,48,48,90,34,44,10,32,32,34,118,101,114,34,58,32,48,44,10,32,32,34,100,111,117,98,108,101,95,115,112,101,110,100,34,58,32,102,97,108,115,101,44,10,32,32,34,118,105,110,95,115,122,34,58,32,49,44,10,32,32,34,118,111,117,116,95,115,122,34,58,32,49,44,10,32,32,34,105,110,116,101,114,110,97,108,95,116,120,105,100,115,34,58,32,91,10,32,32,32,32,34,100,100,49,48,55,99,56,52,56,56,56,54,55,102,100,53,51,99,48,97,97,51,98,102,49,100,56,97,52,55,56,97,48,55,55,101,99,54,55,97,102,55,53,56,52,50,100,50,52,102,49,97,54,52,101,98,52,52,101,52,100,57,48,50,34,44,10,32,32,32,32,34,57,97,57,56,54,55,56,100,50,48,57,57,49,48,102,55,48,98,100,101,100,54,50,52,102,50,99,53,99,49,56,101,100,49,55,100,52,49,55,55,53,50,48,55,50,100,52,49,99,53,100,54,49,98,52,50,99,50,55,55,51,52,56,99,34,44,10,32,32,32,32,34,97,100,57,53,57,57,54,49,102,52,54,54,54,51,102,55,56,53,101,49,101,48,97,48,98,50,54,53,54,57,54,48,98,53,100,50,55,48,54,49,48,57,55,99,53,48,57,50,99,52,101,54,56,57,54,52,98,102,97,102,48,48,52,49,34,44,10,32,32,32,32,34,53,97,50,51,100,55,52,97,52,56,52,101,99,53,56,98,50,49,49,50,54,52,56,56,56,56,52,54,98,101,54,100,55,52,50,56,99,51,51,98,101,57,51,50,50,51,51,57,54,101,102,102,51,54,50,54,101,48,51,54,97,55,102,52,34,44,10,32,32,32,32,34,55,51,57,48,54,98,50,102,49,97,49,100,55,102,100,49,55,99,55,55,54,56,52,101,53,101,56,49,49,97,101,56,55,49,48,101,52,97,48,51,50,53,48,49,48,57,48,100,97,50,54,52,55,49,50,100,98,55,97,52,56,101,55,97,34,44,10,32,32,32,32,34,53,51,99,101,56,56,101,49,99,102,57,56,98,51,55,102,98,54,52,99,49,54,49,50,49,98,52,54,52,49,100,100,101,54,53,50,57,48,56,51,56,99,101,48,98,100,101,54,99,98,49,99,51,49,57,100,102,51,101,102,56,102,102,57,34,44,10,32,32,32,32,34,50,57,98,99,52,101,55,102,97,50,100,98,50,56,98,48,97,50,101,102,57,101,55,97,53,101,48,55,51,99,99,55,53,51,50,101,54,48,57,102,55,53,50,98,50,101,98,48,98,53,55,51,49,98,48,99,54,98,57,50,54,97,50,99,34,44,10,32,32,32,32,34,52,97,57,97,102,99,53,97,54,56,48,57,49,55,57,53,53,101,55,56,49,98,56,57,48,54,56,56,49,52,51,102,53,54,98,97,100,99,55,54,55,56,53,97,102,57,56,55,53,51,100,53,50,54,55,50,55,48,100,55,100,56,48,57,34,10,32,32,93,44,10,32,32,34,99,111,110,102,105,114,109,97,116,105,111,110,115,34,58,32,49,53,51,49,51,54,56,48,44,10,32,32,34,99,111,110,102,105,100,101,110,99,101,34,58,32,49,44,10,32,32,34,105,110,112,117,116,115,34,58,32,91,10,32,32,32,32,123,10,32,32,32,32,32,32,34,115,101,113,117,101,110,99,101,34,58,32,50,55,51,44,10,32,32,32,32,32,32,34,97,100,100,114,101,115,115,101,115,34,58,32,91,10,32,32,32,32,32,32,32,32,34,55,51,56,100,49,52,53,102,97,97,98,98,49,101,48,48,99,102,53,97,48,49,55,53,56,56,97,57,99,48,102,57,57,56,51,49,56,48,49,50,34,10,32,32,32,32,32,32,93,10,32,32,32,32,125,10,32,32,93,44,10,32,32,34,111,117,116,112,117,116,115,34,58,32,91,10,32,32,32,32,123,10,32,32,32,32,32,32,34,118,97,108,117,101,34,58,32,49,48,49,53,51,49,53,51,51,53,57,52,51,55,51,50,54,44,10,32,32,32,32,32,32,34,115,99,114,105,112,116,34,58,32,34,52,101,55,49,100,57,50,100,34,44,10,32,32,32,32,32,32,34,97,100,100,114,101,115,115,101,115,34,58,32,91,10,32,32,32,32,32,32,32,32,34,52,101,57,100,56,98,52,102,49,56,100,57,56,52,102,54,102,48,99,56,56,100,48,55,101,52,98,51,57,50,48,49,101,56,50,53,99,100,49,55,34,10,32,32,32,32,32,32,93,10,32,32,32,32,125,10,32,32,93,10,125]}}}"#).to_string()),
maybe_contract_source: Some(ContractSource {
contract_src: contract_source_vec.into(),
contract_type: SimulateContractType::JAVASCRIPT,
}),
};

let contract = simulate_contract(execution_context).await.unwrap();
println!("{}", contract.state);
}
}
10 changes: 10 additions & 0 deletions testdata/contracts/deterministic-fetch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export async function handle(state, action) {
const ethTxId = action.input.id;
const fetchTx = await EXM.deterministicFetch(`https://api.blockcypher.com/v1/eth/main/txs/${ethTxId}`);
const txJson = fetchTx.asJSON();
state[ethTxId] = txJson.fees;
return {
state,
result: txJson
}
}
1 change: 1 addition & 0 deletions testdata/contracts/deterministic-fetch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}

0 comments on commit ebf412b

Please sign in to comment.