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(create-market): Add create market client call #1139

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"@cosmjs/tendermint-rpc": "^0.32.1",
"@datadog/browser-logs": "^5.23.3",
"@dydxprotocol/v4-abacus": "1.12.23",
"@dydxprotocol/v4-client-js": "1.10.0",
"@dydxprotocol/v4-client-js": "1.11.0",
"@dydxprotocol/v4-localization": "^1.1.217",
"@dydxprotocol/v4-proto": "^7.0.0-dev.0",
"@emotion/is-prop-valid": "^1.3.0",
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions src/hooks/useSubaccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,22 @@ const useSubaccountContext = ({ localDydxWallet }: { localDydxWallet?: LocalWall
[compositeClient, localDydxWallet, newMarketProposal]
);

// ------ Listing Method ------ //
const createPermissionlessMarket = useCallback(
async (ticker: string) => {
if (!compositeClient) {
throw new Error('client not initialized');
} else if (!subaccountClient?.address) {
throw new Error('wallet not initialized');
}

const response = await compositeClient.createMarketPermissionless(subaccountClient, ticker);

return response;
},
[compositeClient, subaccountClient]
);

// ------ Staking Methods ------ //
const delegate = useCallback(
async (validator: string, amount: number) => {
Expand Down Expand Up @@ -1051,6 +1067,9 @@ const useSubaccountContext = ({ localDydxWallet }: { localDydxWallet?: LocalWall
// Governance Methods
submitNewMarketProposal,

// Listing Methods
createPermissionlessMarket,

// Staking methods
delegate,
getDelegateFee,
Expand Down
7 changes: 6 additions & 1 deletion src/views/forms/NewMarketForm/v7/NewMarketPreviewStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { STRING_KEYS } from '@/constants/localization';

import { useMetadataServiceAssetFromId } from '@/hooks/useLaunchableMarkets';
import { useStringGetter } from '@/hooks/useStringGetter';
import { useSubaccount } from '@/hooks/useSubaccount';

import { formMixins } from '@/styles/formMixins';
import { layoutMixins } from '@/styles/layoutMixins';
Expand Down Expand Up @@ -46,6 +47,7 @@ export const NewMarketPreviewStep = ({
const [showAgreement, setShowAgreement] = useState(false);
const baseAsset = getDisplayableAssetFromTicker(ticker);
const launchableAsset = useMetadataServiceAssetFromId(ticker);
const { createPermissionlessMarket } = useSubaccount();

const alertMessage = useMemo(() => {
let alert;
Expand Down Expand Up @@ -161,9 +163,12 @@ export const NewMarketPreviewStep = ({
setErrorMessage(undefined);

try {
const response = await createPermissionlessMarket(ticker);
// eslint-disable-next-line no-console
console.log('debug:createPermissionlessMarket', response);
onSuccess(ticker);
} catch (error) {
log('NewMarketPreviewForm/submitNewMarketProposal', error);
log('NewMarketPreviewForm/createPermissionlessMarket', error);
setErrorMessage(error.message);
} finally {
setIsLoading(false);
Expand Down
Loading