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: onboard IST with elements button #98

Merged
merged 10 commits into from
Apr 24, 2024
Merged

feat: onboard IST with elements button #98

merged 10 commits into from
Apr 24, 2024

Conversation

samsiegart
Copy link
Contributor

@samsiegart samsiegart commented Mar 27, 2024

refs #78

This PR bases off #97, will move out of draft after that merges.

This will eventually be used in the provision-wallet-notice dialog (future PR), but can also be used standalone.

It uses the interchain-ui button component so it's themeable with the ThemeProvider and looks consistent with the network dropdown and wallet connection modal.

Also exposes leapElementsClient if clients need to use leap elements in a different context.

Testing

Tested with dapp-offer-up in Agoric/dapp-offer-up@55946ae

Screenshots

image

image

@samsiegart samsiegart changed the base branch from main to provision-fee March 27, 2024 19:43
Base automatically changed from provision-fee to main April 17, 2024 00:43
Copy link

cloudflare-workers-and-pages bot commented Apr 19, 2024

Deploying ui-kit with  Cloudflare Pages  Cloudflare Pages

Latest commit: a79ebb2
Status: ✅  Deploy successful!
Preview URL: https://d4ba633d.ui-kit-dwm.pages.dev
Branch Preview URL: https://provision-dialog.ui-kit-dwm.pages.dev

View logs

@samsiegart samsiegart marked this pull request as ready for review April 23, 2024 01:53
@samsiegart samsiegart requested a review from turadg April 23, 2024 01:53
Comment on lines 4 to 5
type Chain = (typeof chains)[number];
type AssetList = (typeof assets)[number];
Copy link
Member

Choose a reason for hiding this comment

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

import { AssetList, Chain } from '@chain-registry/types';

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was seeing some type mismatch and resorted to this, but tried it again and it seems to build 👍

@@ -0,0 +1,2 @@
export const Ist =
Copy link
Member

Choose a reason for hiding this comment

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

how does one generate this? I forget whether that's documented. Either way, please leave some comment in this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can copy the data uri of an image in chrome dev tools or with various web apps. Just added a comment.

export const useElementsWalletClient = (): WalletClient => {
const { client } = useWalletClient();

// @ts-expect-error Mismatch between `Long` type in `signDoc`
Copy link
Member

Choose a reason for hiding this comment

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

isn't that mismatch handled by line 29? this seems like it's about something else. see if you can ignore a smaller scope or use casting to resolve

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is without the expect-errors, I needed to put them in both places:

$ yarn build
src/lib/utils/leapElementsClient.ts:8:9 - error TS2322: Type '{ enable: (chainIds: string | string[]) => Promise<void>; getAccount: (chainId: string) => Promise<{ bech32Address: string; pubKey: Uint8Array; isNanoLedger: boolean; }>; getSigner: (chainId: string) => Promise<...>; }' is not assignable to type 'WalletClient'.
  The types returned by 'getSigner(...)' are incompatible between these types.
    Type 'Promise<{ signDirect: (address: string, signDoc: SignDoc) => Promise<{ signature: Uint8Array; signed: SignDoc; }>; signAmino: (address: string, signDoc: StdSignDoc) => Promise<...>; }>' is not assignable to type 'Promise<Signer>'.
      Type '{ signDirect: (address: string, signDoc: SignDoc) => Promise<{ signature: Uint8Array; signed: SignDoc; }>; signAmino: (address: string, signDoc: StdSignDoc) => Promise<...>; }' is not assignable to type 'Signer'.
        The types returned by 'signDirect(...)' are incompatible between these types.
          Type 'Promise<{ signature: Uint8Array; signed: SignDoc; }>' is not assignable to type 'Promise<SignDirectResponse | TxRaw>'.
            Type '{ signature: Uint8Array; signed: SignDoc; }' is not assignable to type 'SignDirectResponse | TxRaw'.
              Type '{ signature: Uint8Array; signed: SignDoc; }' is not assignable to type 'SignDirectResponse'.
                The types of 'signed.accountNumber' are incompatible between these types.
                  Type 'bigint' is not assignable to type 'Long'.

8   const walletClient: WalletClient = useMemo(() => {
          ~~~~~~~~~~~~

src/lib/utils/leapElementsClient.ts:28:61 - error TS2345: Argument of type 'import("/home/samsiegart/ui-kit/node_modules/@leapwallet/elements-core/node_modules/cosmjs-types/cosmos/tx/v1beta1/tx").SignDoc' is not assignable to parameter of type 'import("/home/samsiegart/ui-kit/node_modules/cosmjs-types/cosmos/tx/v1beta1/tx").SignDoc'.
  Types of property 'accountNumber' are incompatible.
    Type 'Long' is not assignable to type 'bigint'.

28             const result = await signer.signDirect(address, signDoc);
                                                               ~~~~~~~


Found 2 errors in the same file, starting at: src/lib/utils/leapElementsClient.ts:8

So seems like the cosmjs-types in leap and cosmos-kit differ. I'm not sure how to cast in this scenario, but the errors seem inconsequential.

@@ -33,6 +33,8 @@ type VBankAssets = [

/** @typedef {import('@agoric/ertp/src/types.js').Amount<'nat'>['value']} NatValue */

/** @typedef {import('@agoric/ertp/src/types.js').Amount<'nat'>['value']} NatValue */
Copy link
Member

Choose a reason for hiding this comment

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

this is a .ts file so the jsdoc tyepdefs do nothing.

this and the one above should be removed. Line 19 actually imports the type

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yea this seems to be a merge artifact, removed.

@samsiegart samsiegart merged commit c3c837a into main Apr 24, 2024
2 checks passed
@samsiegart samsiegart deleted the provision-dialog branch April 24, 2024 17:43
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