-
Notifications
You must be signed in to change notification settings - Fork 11.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Description - Wire SwapPageForm Flag https://app.growthbook.io/features/wallet-fee-address  ## Test Plan How did you test the new or updated feature? --- If your changes are not user-facing and not a breaking change, you can skip the following section. Otherwise, please indicate what changed, and then add to the Release Notes section as highlighted during the release process. ### Type of Change (Check all that apply) - [ ] protocol change - [ ] user-visible impact - [ ] breaking change for a client SDKs - [ ] breaking change for FNs (FN binary must upgrade) - [ ] breaking change for validators or node operators (must upgrade binaries) - [ ] breaking change for on-chain data layout - [ ] necessitate either a data wipe or data migration ### Release notes --------- Co-authored-by: mamos-mysten <122397493+mamos-mysten@users.noreply.github.com>
- Loading branch information
1 parent
9e9b57b
commit 7d997ae
Showing
19 changed files
with
1,525 additions
and
161 deletions.
There are no files selected for viewing
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,58 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
import { useActiveAccount } from '_app/hooks/useActiveAccount'; | ||
import { useGetOwnedObjects } from '@mysten/core'; | ||
import { useSuiClient } from '@mysten/dapp-kit'; | ||
import { DeepBookClient } from '@mysten/deepbook'; | ||
import { createContext, useContext, useMemo, type ReactNode } from 'react'; | ||
|
||
type DeepBookContextProps = { | ||
client: DeepBookClient; | ||
accountCapId: string; | ||
}; | ||
|
||
const DeepBookContext = createContext<DeepBookContextProps | null>(null); | ||
|
||
interface DeepBookContextProviderProps { | ||
children: ReactNode; | ||
} | ||
|
||
export function useDeepBookContext() { | ||
const context = useContext(DeepBookContext); | ||
if (!context) { | ||
throw new Error('useDeepBookContext must be used within a DeepBookContextProvider'); | ||
} | ||
return context; | ||
} | ||
|
||
export function DeepBookContextProvider({ children }: DeepBookContextProviderProps) { | ||
const suiClient = useSuiClient(); | ||
const activeAccount = useActiveAccount(); | ||
const activeAccountAddress = activeAccount?.address; | ||
|
||
const { data } = useGetOwnedObjects( | ||
activeAccountAddress, | ||
{ | ||
MatchAll: [{ StructType: '0xdee9::custodian_v2::AccountCap' }], | ||
}, | ||
1, | ||
); | ||
|
||
const objectContent = data?.pages?.[0]?.data?.[0]?.data?.content; | ||
const objectFields = objectContent?.dataType === 'moveObject' ? objectContent?.fields : null; | ||
|
||
const accountCapId = (objectFields as Record<string, string | number | object>)?.owner as string; | ||
|
||
const deepBookClient = useMemo(() => { | ||
return new DeepBookClient(suiClient, accountCapId); | ||
}, [accountCapId, suiClient]); | ||
|
||
const contextValue = useMemo(() => { | ||
return { | ||
client: deepBookClient, | ||
accountCapId, | ||
}; | ||
}, [accountCapId, deepBookClient]); | ||
|
||
return <DeepBookContext.Provider value={contextValue}>{children}</DeepBookContext.Provider>; | ||
} |
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.
7d997ae
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.
Successfully deployed to the following URLs:
sui-typescript-docs – ./sdk/docs
sui-wallet-kit.vercel.app
sui-typescript-docs-mysten-labs.vercel.app
sui-typescript-docs.vercel.app
sui-typescript-docs-git-main-mysten-labs.vercel.app