Skip to content
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

feat: decode payment code #354

Merged
merged 21 commits into from
Jun 22, 2023
Merged

feat: decode payment code #354

merged 21 commits into from
Jun 22, 2023

Conversation

peterpeterparker
Copy link
Member

@peterpeterparker peterpeterparker commented Jun 20, 2023

Motivation

In NNS dapp we want to support QR code that provides more information than only an address. We want to be able to read QR code that provides token and amount information as well.

That way a use can scan a QR code and proceed a payment in NNS dapp.

Changes

  • add a new utils function decodePayment to the @dfinity/ledger package

@github-actions
Copy link
Contributor

github-actions bot commented Jun 20, 2023

size-limit report 📦

Path Size
@dfinity/ckbtc 7.84 KB (0%)
@dfinity/cmc 998 B (0%)
@dfinity/ledger 2.13 KB (+6.8% 🔺)
@dfinity/nns 29.24 KB (0%)
@dfinity/nns-proto 76.3 KB (0%)
@dfinity/sns 13.39 KB (0%)
@dfinity/utils 3.27 KB (0%)
@dfinity/rosetta-client -19 B (0%)
@dfinity/ic-management 2.19 KB (0%)

@peterpeterparker peterpeterparker marked this pull request as ready for review June 21, 2023 12:49
@peterpeterparker peterpeterparker changed the title feat: parse payment code feat: decode payment code Jun 21, 2023
Copy link
Contributor

@lmuntaner lmuntaner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of questions, but it's looking good!

packages/ledger/src/utils/payment.utils.ts Show resolved Hide resolved
packages/ledger/src/utils/payment.utils.ts Show resolved Hide resolved
@peterpeterparker peterpeterparker merged commit 43622ad into main Jun 22, 2023
@peterpeterparker peterpeterparker deleted the feat/parse-payment-code branch June 22, 2023 06:18
github-merge-queue bot pushed a commit to dfinity/nns-dapp that referenced this pull request Jun 22, 2023
# Motivation

Extend QR code reader in transaction to extract encoded amount that way
users can proceed payment in NNS dapp.

# PRs

- [x] dfinity/ic-js#354

# Changes

- bump ic-js to use new function `decodePayment`
- use function. if token does not match throw and error, if matches
apply identifier and if provided amount

# Tests

It would need e2e test.

I tried various ways to simulate the `nnsQRCode` custom event in jest
test (as we have to skip the QRCode reader in such context) but, did not
make it. Of course let me know if you know how.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants