-
Notifications
You must be signed in to change notification settings - Fork 3
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
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6b4c3ae
feat: query smart wallet auto-provision fee
samsiegart f9c1cc3
fix: remove extra purse updates and swingset query
samsiegart 7df695e
feat: onboard IST with elements button
samsiegart 65132f5
Merge branch 'main' into provision-dialog
samsiegart 464f61d
build: patch xsnap to separate from yarn project
turadg 1871176
test(rpc): use legacy endo to fix test
samsiegart 41108a0
build: add prepack script
samsiegart 825769a
build: fix some types
samsiegart d361d5f
chore: add comment for IST icon
samsiegart a79ebb2
Merge branch 'main' into provision-dialog
samsiegart File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
.yarn/patches/@agoric-xsnap-npm-0.14.3-u14.0-768ce73dba.patch
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
diff --git a/package.json b/package.json | ||
index 25ddb12bf728223569f4e53ed8cca20e51813725..876d249fa2584d748f6da234d5104c42090b5f34 100644 | ||
--- a/package.json | ||
+++ b/package.json | ||
@@ -12,11 +12,11 @@ | ||
}, | ||
"scripts": { | ||
"repl": "node src/xsrepl.js", | ||
- "build:bin": "if test -d ./test; then node src/build.js; else yarn build:from-env; fi", | ||
+ "build:bin": "if test -d ./test; then node src/build.js; else npm run build:from-env; fi", | ||
"build:env": "test -d ./test && node src/build.js --show-env > build.env", | ||
"build:from-env": "{ cat build.env; echo node src/build.js; } | xargs env", | ||
- "build": "yarn build:bin && yarn build:env", | ||
- "postinstall": "yarn build:from-env", | ||
+ "build": "npm run build:bin && npm run build:env", | ||
+ "postinstall": "npm run build:from-env", | ||
"clean": "rm -rf xsnap-native/xsnap/build", | ||
"lint": "run-s --continue-on-error lint:*", | ||
"lint:js": "eslint 'src/**/*.js' 'test/**/*.js' api.js", |
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 |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
"type": "module", | ||
"packageManager": "[email protected]", | ||
"scripts": { | ||
"prepack": "yarn workspaces foreach --all --topological run prepack", | ||
"docs": "typedoc --excludeInternal", | ||
"format": "yarn prettier --write packages", | ||
"lint": "yarn workspaces foreach --all run lint", | ||
|
@@ -45,7 +46,9 @@ | |
"typescript": "~5.3.3" | ||
}, | ||
"resolutions": { | ||
"@agoric/swingset-liveslots": "0.10.3-dev-8c14632.0" | ||
"@agoric/swingset-liveslots": "0.10.3-dev-8c14632.0", | ||
"@agoric/xsnap@npm:^0.14.3-u14.0": "patch:@agoric/xsnap@npm%3A0.14.3-u14.0#~/.yarn/patches/@agoric-xsnap-npm-0.14.3-u14.0-768ce73dba.patch", | ||
"@agoric/xsnap@npm:^0.14.2": "patch:@agoric/xsnap@npm%3A0.14.3-u14.0#~/.yarn/patches/@agoric-xsnap-npm-0.14.3-u14.0-768ce73dba.patch" | ||
}, | ||
"ava": { | ||
"files": [ | ||
|
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
76 changes: 76 additions & 0 deletions
76
packages/react-components/src/lib/components/OnboardIstModal.tsx
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 |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { type AssetSelector, LiquidityModal, Tabs } from '@leapwallet/elements'; | ||
import { useElementsWalletClient } from '../utils'; | ||
import { useAgoric } from '../hooks'; | ||
import { Ist } from '../icons/Ist'; | ||
import { Button } from '@interchain-ui/react'; | ||
|
||
import '@leapwallet/elements/styles.css'; | ||
|
||
const agoricChainId = 'agoric-3'; | ||
const istSelector: AssetSelector = ['symbol', 'IST']; | ||
const bldSelector: AssetSelector = ['symbol', 'BLD']; | ||
|
||
export const OnboardIstModal = () => { | ||
const { address } = useAgoric(); | ||
const elementsWalletClient = useElementsWalletClient(); | ||
|
||
const renderLiquidityButton = ({ onClick }: { onClick: () => void }) => { | ||
return ( | ||
<Button onClick={onClick} leftIcon="walletFilled"> | ||
Deposit IST | ||
</Button> | ||
); | ||
}; | ||
|
||
return ( | ||
<LiquidityModal | ||
renderLiquidityButton={renderLiquidityButton} | ||
theme="light" | ||
walletClientConfig={{ | ||
userAddress: address, | ||
walletClient: elementsWalletClient, | ||
connectWallet: (chainId?: string) => { | ||
return elementsWalletClient.enable(chainId ?? []); | ||
}, | ||
}} | ||
defaultActiveTab={Tabs.SWAP} | ||
config={{ | ||
icon: Ist, | ||
title: 'Deposit IST', | ||
subtitle: '', | ||
tabsConfig: { | ||
[Tabs.BRIDGE_USDC]: { | ||
enabled: false, | ||
}, | ||
[Tabs.FIAT_ON_RAMP]: { | ||
enabled: false, | ||
}, | ||
[Tabs.CROSS_CHAIN_SWAPS]: { | ||
enabled: true, | ||
defaults: { | ||
destinationChainId: agoricChainId, | ||
destinationAssetSelector: istSelector, | ||
}, | ||
}, | ||
[Tabs.SWAP]: { | ||
enabled: true, | ||
defaults: { | ||
sourceChainId: agoricChainId, | ||
sourceAssetSelector: bldSelector, | ||
destinationChainId: agoricChainId, | ||
destinationAssetSelector: istSelector, | ||
}, | ||
}, | ||
[Tabs.TRANSFER]: { | ||
enabled: true, | ||
defaults: { | ||
destinationChainId: agoricChainId, | ||
sourceChainId: agoricChainId, | ||
sourceAssetSelector: istSelector, | ||
}, | ||
}, | ||
}, | ||
}} | ||
/> | ||
); | ||
}; |
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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './leapElementsClient'; |
53 changes: 53 additions & 0 deletions
53
packages/react-components/src/lib/utils/leapElementsClient.ts
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import type { WalletClient } from '@leapwallet/elements'; | ||
import { useWalletClient } from '@cosmos-kit/react'; | ||
import { useMemo } from 'react'; | ||
|
||
export const useElementsWalletClient = (): WalletClient => { | ||
const { client } = useWalletClient(); | ||
|
||
// @ts-expect-error Mismatch between `Long` type in `signDoc` | ||
const walletClient: WalletClient = useMemo(() => { | ||
return { | ||
enable: (chainIds: string | string[]) => { | ||
return client!.enable!(chainIds); | ||
}, | ||
getAccount: async (chainId: string) => { | ||
await client!.enable!(chainId); | ||
const result = await client!.getAccount!(chainId); | ||
return { | ||
bech32Address: result.address, | ||
pubKey: result.pubkey, | ||
isNanoLedger: !!result.isNanoLedger, | ||
}; | ||
}, | ||
getSigner: async (chainId: string) => { | ||
const signer = client!.getOfflineSignerDirect!(chainId); | ||
const aminoSigner = client!.getOfflineSignerAmino!(chainId); | ||
|
||
return { | ||
signDirect: async (address, signDoc) => { | ||
// @ts-expect-error Mismatch between `Long` type in `signDoc` | ||
const result = await signer.signDirect(address, signDoc); | ||
return { | ||
signature: new Uint8Array( | ||
Buffer.from(result.signature.signature, 'base64'), | ||
), | ||
signed: result.signed, | ||
}; | ||
}, | ||
signAmino: async (address, signDoc) => { | ||
const result = await aminoSigner.signAmino(address, signDoc); | ||
return { | ||
signature: new Uint8Array( | ||
Buffer.from(result.signature.signature, 'base64'), | ||
), | ||
signed: result.signed, | ||
}; | ||
}, | ||
}; | ||
}, | ||
}; | ||
}, [client]); | ||
|
||
return walletClient; | ||
}; |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back 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.
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
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.
This is without the expect-errors, I needed to put them in both places:
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.