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: expose ledger-icp converters #716

Merged
merged 2 commits into from
Sep 11, 2024
Merged

Conversation

peterpeterparker
Copy link
Member

@peterpeterparker peterpeterparker commented Sep 9, 2024

Motivation

The ICRC signer standards require developers to pass the payload as a Candid Uint8Array. Such an array can be generated using @dfinity/candid which I find it somewhat cumbersome to use when you are not used to it. Moreover, the IDL declarations required for this conversion are not currently exposed by the types generated by Candid and didc, which means that each developer has to manually copy the data. Long story short, it's not the best DX.

That's why, in our implementation of the Oisy standard, we discussed providing an opinionated client library that can be used to interact with Oisy, or wallet.

Given that most JavaScript developers are likely more familiar with using the types exposed by ic-js to interact with well-known canisters of the Internet Computer (IC), such as ledgers, rather than those generated by Candid, this PR aims to expose the "converters" of ledger-icp to allow the client library to obfuscate this complexity.

In short, this Oisy client library needs to be able to transform IC-js types into Candid types the same way ic-js do. Therefore, to avoid code duplication, this PR exposes the converters.

Notes

Oisy signer lib is currently not open source as in development and not yet reviewed by security but, happy to jump in a call to share more details if anything is unclear.

Changes

  • Expose @dfinity/ledger-icp converters
  • Generate test. For "consent message" I extracted a mock from existing data as I knew this one existed since it was recently added.

Signed-off-by: David Dal Busco <david.dalbusco@dfinity.org>
Copy link
Contributor

github-actions bot commented Sep 9, 2024

size-limit report 📦

Path Size
@dfinity/ckbtc 7.99 KB (0%)
@dfinity/cketh 3.45 KB (0%)
@dfinity/cmc 1.29 KB (0%)
@dfinity/ledger-icrc 4.17 KB (0%)
@dfinity/ledger-icp 15.43 KB (-0.01% 🔽)
@dfinity/nns 36.25 KB (0%)
@dfinity/nns-proto 140.98 KB (0%)
@dfinity/sns 15.85 KB (0%)
@dfinity/utils 4.5 KB (0%)
@dfinity/ic-management 2.87 KB (0%)

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.

This PR looks good to me. I don't see a problem with exposing the converters.

However, let's discuss offline the rest of the feature because I'm not sure I follow exactly what will be done.

@peterpeterparker peterpeterparker enabled auto-merge (squash) September 11, 2024 13:49
@peterpeterparker peterpeterparker merged commit 1b6baa3 into main Sep 11, 2024
11 checks passed
@peterpeterparker peterpeterparker deleted the feat/expose-converters branch September 11, 2024 13:50
peterpeterparker added a commit that referenced this pull request Sep 30, 2024
# Motivation

Similarly to #716 for ICP, we also need to exposes the ICRC
`ledger.converters` for the signer standards library.

# Changes

- Expose module in `index.ts`

---------

Signed-off-by: David Dal Busco <david.dalbusco@dfinity.org>
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