-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
cd7973f
commit 3aae1f5
Showing
4 changed files
with
49 additions
and
49 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
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,58 +1,33 @@ | ||
import {SimplePool} from 'nostr-tools'; | ||
import {V1FormSpec} from '@formstr/sdk/dist/interfaces'; | ||
|
||
const defaultRelays = ['wss://relay.primal.net/', 'wss://relay.hllo.live']; | ||
const relayList = ['wss://relay.primal.net/', 'wss://relay.hllo.live/']; | ||
|
||
export const getFormTemplate = async (formId: string): Promise<{}> => { | ||
console.log('inside getFormTemplate'); | ||
const pool = new SimplePool(); | ||
let formIdPubkey = formId; | ||
let relayList = defaultRelays; | ||
console.log('everything initialised'); | ||
const filter = { | ||
kinds: [0], | ||
authors: [formIdPubkey], //formId is the npub of the form | ||
}; | ||
console.log('getting kind0', filter); | ||
pool | ||
.get(relayList, filter, {maxWait: 10}) | ||
.then( | ||
value => { | ||
console.log('got kind0', value); | ||
return; | ||
}, | ||
reason => { | ||
console.log('failed to get because', reason); | ||
return; | ||
}, | ||
) | ||
.catch(reason => { | ||
console.log('Errored', reason); | ||
return; | ||
}); | ||
console.log('after promise'); | ||
|
||
let kind0 = null | ||
try { | ||
console.log('inside try'); | ||
console.log( | ||
'Event', | ||
await pool.querySync(relayList, filter, {maxWait: 10}), | ||
); | ||
// console.log('fetching...', fetch('https://github.com')); | ||
console.log('Main thread is stuck'); | ||
console.log('inside trydasdsad'); | ||
kind0 = await pool.get(relayList, filter) | ||
console.log('Main thread is working, got event', kind0); | ||
} catch (e) { | ||
console.log('inside catch'); | ||
console.log('error is', e); | ||
} | ||
|
||
console.log('After everything'); | ||
|
||
pool.close(relayList); | ||
let formTemplate; | ||
// if (kind0) { | ||
// formTemplate = JSON.parse(kind0.content); | ||
// } else { | ||
// throw Error('Form template not found'); | ||
// } | ||
return {}; | ||
if (kind0) { | ||
formTemplate = JSON.parse(kind0.content); | ||
} else { | ||
throw Error('Form template not found'); | ||
} | ||
return formTemplate; | ||
}; |
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 |
---|---|---|
|
@@ -2745,7 +2745,7 @@ buffer-from@^1.0.0: | |
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" | ||
integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== | ||
|
||
buffer@^5.5.0: | ||
buffer@^5.4.3, buffer@^5.5.0: | ||
version "5.7.1" | ||
resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0" | ||
integrity sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ== | ||
|
@@ -6155,7 +6155,7 @@ prop-types@^15.5.10, prop-types@^15.7.2, prop-types@^15.8.1: | |
object-assign "^4.1.1" | ||
react-is "^16.13.1" | ||
|
||
punycode@^2.1.0: | ||
punycode@^2.1.0, punycode@^2.1.1: | ||
version "2.3.1" | ||
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.1.tgz#027422e2faec0b25e1549c3e1bd8309b9133b6e5" | ||
integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg== | ||
|
@@ -6254,6 +6254,13 @@ react-native-modal-popover@^2.0.1: | |
lodash ">4.17.0" | ||
prop-types "^15.8.1" | ||
|
||
react-native-url-polyfill@^2.0.0: | ||
version "2.0.0" | ||
resolved "https://registry.yarnpkg.com/react-native-url-polyfill/-/react-native-url-polyfill-2.0.0.tgz#db714520a2985cff1d50ab2e66279b9f91ffd589" | ||
integrity sha512-My330Do7/DvKnEvwQc0WdcBnFPploYKp9CYlefDXzIdEaA+PAhDYllkvGeEroEzvc4Kzzj2O4yVdz8v6fjRvhA== | ||
dependencies: | ||
whatwg-url-without-unicode "8.0.0-3" | ||
|
||
[email protected]: | ||
version "0.73.4" | ||
resolved "https://registry.yarnpkg.com/react-native/-/react-native-0.73.4.tgz#81e07d4e7b6308c4649d5fa24038c0e87b17f2e1" | ||
|
@@ -7404,11 +7411,25 @@ webidl-conversions@^3.0.0: | |
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" | ||
integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ== | ||
|
||
webidl-conversions@^5.0.0: | ||
version "5.0.0" | ||
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-5.0.0.tgz#ae59c8a00b121543a2acc65c0434f57b0fc11aff" | ||
integrity sha512-VlZwKPCkYKxQgeSbH5EyngOmRp7Ww7I9rQLERETtf5ofd9pGeswWiOtogpEO850jziPRarreGxn5QIiTqpb2wA== | ||
|
||
whatwg-fetch@^3.0.0: | ||
version "3.6.20" | ||
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.6.20.tgz#580ce6d791facec91d37c72890995a0b48d31c70" | ||
integrity sha512-EqhiFU6daOA8kpjOWTL0olhVOF3i7OrFzSYiGsEMB8GcXS+RrzauAERX65xMeNWVqxA6HXH2m69Z9LaKKdisfg== | ||
|
||
[email protected]: | ||
version "8.0.0-3" | ||
resolved "https://registry.yarnpkg.com/whatwg-url-without-unicode/-/whatwg-url-without-unicode-8.0.0-3.tgz#ab6df4bf6caaa6c85a59f6e82c026151d4bb376b" | ||
integrity sha512-HoKuzZrUlgpz35YO27XgD28uh/WJH4B0+3ttFqRo//lmq+9T/mIOJ6kqmINI9HpUpz1imRC/nR/lxKpJiv0uig== | ||
dependencies: | ||
buffer "^5.4.3" | ||
punycode "^2.1.1" | ||
webidl-conversions "^5.0.0" | ||
|
||
whatwg-url@^5.0.0: | ||
version "5.0.0" | ||
resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" | ||
|