Fetch SAFE demonstrates a simple SAFE app, written in Rust using the Yew framework, deployed as WebAssembly and running in SAFE Browser

https://gitlab.com/l4tch/fetchsafe

This project builds upon Hello SAFE demonstrates a simple SAFE app, written in Rust using the Yew framework, deployed as WebAssembly and running in SAFE Browser to demonstrate fetching and deserializing JSON files.

Hopefully this also assists SAFE devs in resolving this issue.

As always, if it can be improved in any way I invite you to reply here or in the repo.

4 Likes

Looks good to me on the shared-vault :slight_smile:

mild amount of footering requiredā€¦
willie@gagarin:~/projects/maidsafe/fetchsafe/scripts$ sh build-develop
build-develop: 2: set: Illegal option -o pipefail
willie@gagarin:~/projects/maidsafe/fetchsafe/scripts$ less build-develop
willie@gagarin:~/projects/maidsafe/fetchsafe/scripts$ chmod +x build-develop
willie@gagarin:~/projects/maidsafe/fetchsafe/scripts$ ./build-develop
[INFO]: Checking for the Wasm targetā€¦
[INFO]: Compiling to Wasmā€¦
Compiling proc-macro2 v1.0.8
Compiling unicode-xid v0.2.0
ā€¦
ā€¦
ā€¦
Compiling fetchsafe v0.1.0 (/home/willie/projects/maidsafe/fetchsafe)
Finished dev [unoptimized + debuginfo] target(s) in 1m 12s
[INFO]: Installing wasm-bindgenā€¦
[INFO]: Optional fields missing from Cargo.toml: ā€˜descriptionā€™, ā€˜repositoryā€™, and ā€˜licenseā€™. These are not necessary, but recommended
[INFO]: :slight_smile: Done in 1m 14s
[INFO]: :slight_smile: Your wasm pkg is ready to publish at /home/willie/projects/maidsafe/fetchsafe/pkg.
:slight_smile: [WARN]: Thereā€™s a newer version of wasm-pack available, the new version is: 0.9.1, you are using: 0.9.0. To update, navigate to: wasm-pack

/home/willie/projects/maidsafe/fetchsafe/scripts/ā€¦/main.js ā†’ dist/fetchsafe.jsā€¦
created dist/fetchsafe.js in 307ms
sed: canā€™t read s/pkg/fetchsafe_bg.wasm/fetchsafe.wasm/g: No such file or directory

I just ignored the last bit and it Just Works :slight_smile:

2 Likes

@southside

Enter that XOR-URL into the text input of the Fetch SAFE app at the XOR-URL of the FilesContainer of the dist directory and press your enter key.

I donā€™t observe the error. After it, what does the init line of fetchsafe.js (790 for me) contain?

await init('/fetchsafe.wasm');

is expected.

When I said ā€œlooks goodā€ that was before I read the code - or tried to - WASM is totally new to me- so I should see a text box that I put the XOR-URL for

willie@gagarin:~/projects/maidsafe/fetchsafe$ safe files put dist/ --recursive
FilesContainer created at: "safe://hnyynyiceqh3f6jwewfaxiibusdzcyahicsqwg596eijkp61pnsdtk8rwnbnc"
+  dist/fetchsafe.css   safe://hbhyyynsxerinwom7o4w5sya8h3giheusihmkq9setpc6d4jti8r3ghxyw 
+  dist/fetchsafe.js    safe://hbkygydn8qe474xgu646fa8yu5tgkjnwae5iumwkcyhbjts7hqs6jtk95c 
+  dist/fetchsafe.json  safe://hbkygony7b8kajf6i9pan37mxa5ujt9regiqg8o93wqtubk9pi8fintf6f 
+  dist/index.html      safe://hbhybyd6hbjyw888949zzdzqxuuszrcpjcs1ob3g9pxapwgmsncuzwcj7b 

3) Run

  1. Open the XOR-URL of the FilesContainer created when deploying with SAFE Browser
    safe://hnyynyiceqh3f6jwewfaxiibusdzcyahicsqwg596eijkp61pnsdtk8rwnbnc

    no content displayed
    should I see an input field?
  2. Enter the XOR-URL of fetchsafe.json to observe failure
  • dist/fetchsafe.json safe://hbkygony7b8kajf6i9pan37mxa5ujt9regiqg8o93wqtubk9pi8fintf6f

    That looked like success to me, no failureā€¦
    until I read the codeā€¦
  1. Enter fetchsafe.json to observe success

not yetā€¦

line 790 of fetchsafe.js

 `   await init('/pkg/fetchsafe_bg.wasm');`

I edited that line and syncd to the shared vault

  • can you see it at ?
    safe://hnyynyiceqh3f6jwewfaxiibusdzcyahicsqwg596eijkp61pnsdtk8rwnbnc

then
safe cat safe://hbkygyn14owrnzwuw4zpi61bdifg3o1a7gbafgzk91orgp5epdwozxwh3m
ā€¦
return wasm;
});
}

    async function main() {
        await init('fetchsafe.wasm');
        run_app();
    }
    main();

    }());

but when I revisit thr Files Container XOR_URL on the browser
safe://hnyynyiceqh3f6jwewfaxiibusdzcyahicsqwg596eijkp61pnsdtk8rwnbnc

I still get a blank page, for each or the versions

1 Like

Should we try to encourage some others to have a try at it with by putting this on the main forum?

1 Like

@southside

What messages does the console contain?

@southside

These projects target developers and as such I donā€™t believe so.


1 Like

One way to get more developers is to ask punters to help solve problems. Iā€™m no dev, just a guy who likes to test things and report back

1 Like

Indeed Willie, and very helpful it is to have you and others willing to poke around.

1 Like

If you can put up with the daft questionsā€¦

1 Like

@southside

Thanks. If you

  1. delete dist
  2. delete pkg
  3. delete the sed -i '' 's/pkg\/fetchsafe_bg.wasm/fetchsafe.wasm/g' $__dir/../dist/fetchsafe.js line from scripts/build-develop
  4. run scripts/build-develop
  5. replace await init('/pkg/fetchsafe_bg.wasm'); with await init('/fetchsafe.wasm'); in dist/fetchsafe.js
  6. run safe files put dist/ --recursive
  7. open the FilesContainer XOR-URL in SAFE Browser v0.16.0-alpha.2

do the results differ?

1 Like

Iā€™ll have a go.
Just opened a beer thoughā€¦

Drowning your sorrows?

1 Like

I donā€™t see that lineā€¦

@southside

~/projects/maidsafe/hellosafe

It would take the output of several breweries and most distilleries west of the Spey to drown my sorrows at the xenophobic idiocy of your countrymen that dragged me out of the EUā€¦

I have failed miserably to find the Ben Elton clip that should go here - but YKWIM

1 Like

OH FFSā€¦ 20 char

1 Like

willie@gagarin:~/projects/maidsafe/fetchsafe$ safe files put dist/ --recursive
FilesContainer created at: ā€œsafe://hnyynyi631tnsh8o5o8bfg8jgk461j79yew4hj5nm9awntihxf3d4whcpgbncā€

  • dist/fetchsafe.css safe://hbhyyynsxerinwom7o4w5sya8h3giheusihmkq9setpc6d4jti8r3ghxyw
  • dist/fetchsafe.js safe://hbkygyn14owrnzwuw4zpi61bdifg3o1a7gbafgzk91orgp5epdwozxwh3m
  • dist/fetchsafe.json safe://hbkygony7b8kajf6i9pan37mxa5ujt9regiqg8o93wqtubk9pi8fintf6f
  • dist/fetchsafe.wasm safe://hbyyyyd89nskmwxm5ypiut3bjruw8fns3c87nb5n9yns8k999bcu4nwjcd
  • dist/index.html safe://hbhybyd6hbjyw888949zzdzqxuuszrcpjcs1ob3g9pxapwgmsncuzwcj7b

looking good so farā€¦

Enter the XOR-URL of fetchsafe.json to observe failure


but when I hit enter, nothing happens

1 Like

@southside

Thatā€™s the issue Iā€™ve reported. If you instead enter ā€œfetchsafe.jsonā€ youā€™ll see its contents displayed in the console.

1 Like