-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
135 additions
and
15 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 |
---|---|---|
@@ -1,6 +1,13 @@ | ||
import { Network } from '../../../shared/types' | ||
|
||
export const Config = { | ||
Urls: { | ||
ApiBase: 'https://api.artcpaclub.com/api', | ||
Marketplace: 'https://marketplace.artcpaclub.com', | ||
ApiBaseUrl: (network: Network) => { | ||
if (network === 'devnet') return 'https://devnet-api.artcpaclub.com/api' | ||
return 'https://api.artcpaclub.com/api' | ||
}, | ||
|
||
MarketplaceUrl: (network: Network) => { | ||
if (network === 'devnet') return 'https://devnet-marketplace.artcpaclub.com' | ||
return 'https://marketplace.artcpaclub.com' | ||
}, | ||
} |
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
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
39 changes: 39 additions & 0 deletions
39
src/extensions/artcpaclub/src/previews/StakeEsdtActionPreview.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,39 @@ | ||
import { Config } from '../config' | ||
import { EsdtPool } from '../types' | ||
import React, { useEffect, useState } from 'react' | ||
import { TokenTransfer } from '@multiversx/sdk-core/out' | ||
import { ExtensionConfig } from '../../../../shared/types' | ||
import { ActionPreviewHighlight } from '../../../../shared/ui/elements' | ||
import { ProposalAction, toFormattedTokenPayment, toTokenPaymentFromProposalPayment } from '@peerme/core-ts' | ||
|
||
type Props = { | ||
action: ProposalAction | ||
config: ExtensionConfig | ||
} | ||
|
||
export function StakeEsdtActionPreview(props: Props) { | ||
const poolId = props.action.arguments[0] as number | ||
const [selectedPool, setSelectedPool] = useState<EsdtPool | null>(null) | ||
|
||
const displayablePayments = | ||
props.action.payments.length > 0 | ||
? props.action.payments | ||
.map((payment) => toFormattedTokenPayment(toTokenPaymentFromProposalPayment(payment))) | ||
.join(', ') | ||
: toFormattedTokenPayment(TokenTransfer.egldFromBigInteger(props.action.value)) | ||
|
||
useEffect(() => { | ||
if (!poolId) return | ||
fetch(Config.ApiBaseUrl(props.config.network) + '/tokenstaking/' + poolId).then(async (res) => { | ||
const data = await res.json() | ||
setSelectedPool(data) | ||
}) | ||
}, [poolId]) | ||
|
||
return ( | ||
<ActionPreviewHighlight> | ||
stake <strong>{displayablePayments}</strong>{' '} | ||
{selectedPool ? `in pool ${selectedPool.title}` : `in pool with id ${poolId}`}. | ||
</ActionPreviewHighlight> | ||
) | ||
} |
35 changes: 35 additions & 0 deletions
35
src/extensions/artcpaclub/src/previews/UnstakeEsdtActionPreview.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,35 @@ | ||
import { Config } from '../config' | ||
import { EsdtPool } from '../types' | ||
import { ProposalAction } from '@peerme/core-ts' | ||
import React, { useEffect, useState } from 'react' | ||
import { ExtensionConfig } from '../../../../shared/types' | ||
import { ActionPreviewHighlight } from '../../../../shared/ui/elements' | ||
|
||
type Props = { | ||
action: ProposalAction | ||
config: ExtensionConfig | ||
} | ||
|
||
export function UnstakeEsdtActionPreview(props: Props) { | ||
const poolId = props.action.arguments[0] as number | ||
const optAmount = props.action.arguments[1] as number | null | ||
const [selectedPool, setSelectedPool] = useState<EsdtPool | null>(null) | ||
|
||
useEffect(() => { | ||
if (!poolId) return | ||
fetch(Config.ApiBaseUrl(props.config.network) + '/tokenstaking/' + poolId).then(async (res) => { | ||
const data = await res.json() | ||
setSelectedPool(data) | ||
}) | ||
}, [poolId]) | ||
|
||
return ( | ||
<ActionPreviewHighlight> | ||
unstake{' '} | ||
<strong> | ||
{optAmount ? optAmount : 'all'} {selectedPool ? selectedPool.stake_token_id : ''} | ||
</strong>{' '} | ||
{selectedPool ? `from pool ${selectedPool.title}` : `from pool with id ${poolId}`}. | ||
</ActionPreviewHighlight> | ||
) | ||
} |
db5013c
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:
extensions-dev – ./
extensions-dev-vleap.vercel.app
extensions-dev-git-main-vleap.vercel.app
extensions-dev.vercel.app
extensions-dev.peerme.io