-
Notifications
You must be signed in to change notification settings - Fork 26
feat: nano contract integration with wallet connect #495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
f5a626b
to
9adfec7
Compare
ea24255
to
7068889
Compare
0d35063
to
2072e15
Compare
7068889
to
e7eaa60
Compare
d4645b2
to
a110a16
Compare
a110a16
to
b2345e7
Compare
b2345e7
to
d79397b
Compare
b236a6f
to
3af6727
Compare
9ef9a80
to
a35a521
Compare
src/components/WalletConnect/NanoContract/NewNanoContractTransactionModal.js
Outdated
Show resolved
Hide resolved
src/components/WalletConnect/NanoContract/NewNanoContractTransactionModal.js
Outdated
Show resolved
Hide resolved
src/components/WalletConnect/NanoContract/NewNanoContractTransactionModal.js
Outdated
Show resolved
Hide resolved
src/components/WalletConnect/NanoContract/NewNanoContractTransactionRequest.js
Outdated
Show resolved
Hide resolved
src/components/WalletConnect/NanoContract/NewNanoContractTransactionRequest.js
Outdated
Show resolved
Hide resolved
src/components/WalletConnect/NanoContract/NewNanoContractTransactionRequest.js
Outdated
Show resolved
Hide resolved
src/sagas/walletConnect.js
Outdated
const tokens = {}; | ||
let someError = false; | ||
for (const uid of uids) { | ||
try { | ||
const { tokenInfo: { symbol, name } } = yield call([wallet, wallet.getTokenDetails], uid); | ||
const token = { uid, symbol, name }; | ||
tokens[uid] = token; | ||
} catch (e) { | ||
log.error(`Fail getting token data for token ${uid}.`, e); | ||
someError = true; | ||
// continue | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use all
to make the requests in parallel, also here goes a suggestion for legibility:
const tokens = {}; | |
let someError = false; | |
for (const uid of uids) { | |
try { | |
const { tokenInfo: { symbol, name } } = yield call([wallet, wallet.getTokenDetails], uid); | |
const token = { uid, symbol, name }; | |
tokens[uid] = token; | |
} catch (e) { | |
log.error(`Fail getting token data for token ${uid}.`, e); | |
someError = true; | |
// continue | |
} | |
} | |
const tokenDetailsRequests = uids.map((uid) => | |
call(function* () { | |
try { | |
const { tokenInfo: { symbol, name } } = yield call([wallet, wallet.getTokenDetails], uid); | |
return [false, { uid, symbol, name }]; | |
} catch (e) { | |
log.error(`Fail getting token data for token ${uid}.`, e); | |
return [true, null]; | |
} | |
}) | |
); | |
const [someError, tokenDetails] = (yield all(tokenDetailsRequests)).reduce( | |
(acc, tokenDetailRequest) => { | |
const [error, tokenObj] = tokenDetailRequest; | |
const [lastError, tokenDetails] = acc; | |
return [ | |
lastError || error, | |
tokenDetail ? { | |
...tokenDetails, | |
[tokenDetail.uid]: tokenDetail | |
} : tokenObj, | |
]; | |
}, [false, {}] | |
); |
Also, can you move this code to src/sagas/tokens.js
and call it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, thank you! Tbh, I have to think more about it. It involves network calls and may have some hidden pitfalls. I have to test it first. I have had some problems with "parallelism" using promises before. Let me do some tests first. I'm opening this issue #531 to work on it later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you'll have any problems here, even with a huge number of tokens
React-native's native HTTP module will queue them for you and only resolve when the request is done
But I agree that this should be tested, so OK to doing it in another PR
src/components/WalletConnect/NanoContract/NanoContractMethodArgs.js
Outdated
Show resolved
Hide resolved
Remarks: The `marginVertical` and `marginHorizontal` are not being applied. Probably this is a bug in ReactNative.
src/components/WalletConnect/NanoContract/NanoContractMethodArgs.js
Outdated
Show resolved
Hide resolved
src/sagas/walletConnect.js
Outdated
const tokens = {}; | ||
let someError = false; | ||
for (const uid of uids) { | ||
try { | ||
const { tokenInfo: { symbol, name } } = yield call([wallet, wallet.getTokenDetails], uid); | ||
const token = { uid, symbol, name }; | ||
tokens[uid] = token; | ||
} catch (e) { | ||
log.error(`Fail getting token data for token ${uid}.`, e); | ||
someError = true; | ||
// continue | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you'll have any problems here, even with a huge number of tokens
React-native's native HTTP module will queue them for you and only resolve when the request is done
But I agree that this should be tested, so OK to doing it in another PR
* feat: implement Nano Contract integration with Wallet Connect * feat: adapt new nc tx to initialize, set result and withdrawal * feat: make ncAddress react to firstAddress change * feat: add name to method arguments * feat: fire sentry error notification for method info not found * feat: improve title of Arguments component * feat: retrieve fallback arg entries when blueprint is loading * feat: add nft check to action token on Actions component * feat: add blueprint download to the tx loading flag and a redundancy
Acceptance Criteria
Blueprint Name
andCaller
oninitialize
call while background requests are being processedBlueprint Name
orCaller
oninitialize
call if any request failsCaller
if request failsCaller
if requests failsPosition $
for each positional argument as a fallback for argument's name when blueprint info fails to loadLoading tx info
wc-nc-loading-tx-info.mp4
Declining tx
wc-nc-declining-tx.mp4
Changing caller address
wc-nc-changing-caller-address.mp4
Accepting tx with failure
wc-nc-accepting-tx-with-failure.mp4
Accepting tx with failure and trying again
wc-nc-accepting-tx-with-failure-try-again.mp4
Accepting tx with success
wc-nc-accepting-tx-with-success.mp4
Handling many types of transactions for Nano Contract registered
fix-initialize-registered-nc.mp4
Handling
initialize
with requests failurefix-initialize-loading-to-error.mp4
Handling requests for Nano Contract not registered
fix-initialize-not-registered-nc.mp4
Argument names
Android
iOS
Showing action token symbol for not registered token
Showing UID cut as fallback for not registered token and feedback error message
Warning
It depends on:
Security Checklist