Skip to content

Commit

Permalink
Merge development to testnet (#226)
Browse files Browse the repository at this point in the history
* Amount validity check update

* Airdrop fund and register subtitle fix (#219)

* Fix subtitles for airdrop register & fund

* Typo fix

* Native token airdrop support (#220)

* Add token selection UI to airdrop create page

* Fix native token logic on airdrop create

* Add new method for funding in merkle airdrop contract

* Update airdrop props

* Use correct funding method based on airdrop token

* Implement native token logic on claim page

* Fix client error on website load

* Update instantiate message with native token

* Fix balance error on website load

* Manage (burn or withdraw) remaining funds for an expired airdrop (#223)

* Feature: Terra airdrop support (#224)

* Sync development to testnet (#205)

* Remove comment

* Update testnet chain id

* Merge development to testnet (#214)

* Remove comment

* Update testnet chain id

* Typo fixes (#208)

* Changed "swiss knife" to "Swiss Army knife"
* Removed unnecessary and unconventional "as" before "Smart Contract Dashboard"
* Capitalized first letter of "Airdrops" and "Create Airdrop" page names, changed reference to Create Airdrop page to mention the page name

* Sign and verify placeholder (#207)

* add placeholders for sign and verify

* Fix signature placeholder

* fix placeholder

* update testnet explorer

* Add features to keplr config

* The utility function isValidAccountsFile() now includes a check for duplicate addresses

* Json formatted execute operation entry changed (#206)

* Json formatted execute operation entry turned into form like formatted entry

* Minor fixs

* Minor fixes

* Minor fixes

* Walletless query (#212)

* Wallet.tsx client turned into cosmwasmclient when not initialised

* Minor fix

* Minor fixes

Co-authored-by: Lyte <andygolay@gmail.com>
Co-authored-by: Highlander <68139321+Highlander-maker@users.noreply.github.com>
Co-authored-by: Highlander-Maker <highlander1952@protonmail.com>
Co-authored-by: Furkan Kaymak <furkan@deuslabs.fi>
Co-authored-by: Serkan Reis <serkanreis@gmail.com>
Co-authored-by: name-user1 <101495985+name-user1@users.noreply.github.com>

* Bump version

* Add terra related logic (#2)

* Add terra related logic to whitelist processing

* Set terra airdrop flag on airdrop creation

* Update airdrop props

* Add terra related logic to merkle contract helpers

* Add terra logic to claim page

* Update logic

* Show claim button for all terra airdrops

* Include signature in Terra airdrop claim messages

* Revert "Include signature in Terra airdrop claim messages"

This reverts commit ecaed19.

* Include "sig_info" in Terra airdrop claim messages (#4)

* Include signature in Terra airdrop claim messages

* Remove txSigner from burn message on merkle airdrop

* Remove unused code

* Add comments for later on

Co-authored-by: findolor <anakisci@gmail.com>

* Add hrp field

* Setup redirects and fix manage page error

* Refactor claim page terra airdrop logic

Co-authored-by: Lyte <andygolay@gmail.com>
Co-authored-by: Highlander <68139321+Highlander-maker@users.noreply.github.com>
Co-authored-by: Highlander-Maker <highlander1952@protonmail.com>
Co-authored-by: Furkan Kaymak <furkan@deuslabs.fi>
Co-authored-by: Serkan Reis <serkanreis@gmail.com>
Co-authored-by: name-user1 <101495985+name-user1@users.noreply.github.com>

* Revert "Merge branch 'testnet' into development"

This reverts commit f370b81, reversing
changes made to c94efb3.

* Remove txSigner from claim method in airdrop helpers

Co-authored-by: Serkan Reis <serkanreis@gmail.com>
Co-authored-by: Lyte <andygolay@gmail.com>
Co-authored-by: Highlander <68139321+Highlander-maker@users.noreply.github.com>
Co-authored-by: Highlander-Maker <highlander1952@protonmail.com>
Co-authored-by: Furkan Kaymak <furkan@deuslabs.fi>
Co-authored-by: name-user1 <101495985+name-user1@users.noreply.github.com>
  • Loading branch information
7 people authored Jul 4, 2022
1 parent 7a54362 commit 5ba6a4c
Show file tree
Hide file tree
Showing 14 changed files with 1,381 additions and 71 deletions.
15 changes: 14 additions & 1 deletion components/AirdropStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const AirdropStatus = (props: AirdropStatusProps) => {
<StackedList.Item name="Escrow Deposit">{ESCROW_AMOUNT} juno</StackedList.Item>
</Conditional>

<Conditional test={page === 'register' || page === 'fund'}>
<Conditional test={page === 'register' || page === 'fund' || page === 'manage'}>
<StackedList.Item name="Whitelist Generation">
<span className={clsx('font-bold', airdrop.processing ? 'text-plumbus' : 'text-green-500')}>
{airdrop.processing ? 'Processing' : 'Completed'}
Expand All @@ -66,6 +66,19 @@ export const AirdropStatus = (props: AirdropStatusProps) => {
<StackedList.Item className="capitalize" name="Airdrop Latest Step">
{airdrop.status ?? '...'}
</StackedList.Item>

<Conditional test={page === 'manage'}>
{airdrop.expirationType === null && <StackedList.Item name="Expiration Time"> None </StackedList.Item>}
{airdrop.expiration && airdrop.expirationType === 'timestamp' && (
<StackedList.Item name="Expiration Time">
{' '}
{new Date(airdrop.expiration * 1000).toLocaleString()}{' '}
</StackedList.Item>
)}
{airdrop.expiration && airdrop.expirationType === 'height' && (
<StackedList.Item name="Expiration Height"> {airdrop.expiration} </StackedList.Item>
)}
</Conditional>
</StackedList>
</FormControl>
)
Expand Down
1 change: 1 addition & 0 deletions components/AirdropsStepper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const steps = [
{ name: 'Escrow', href: '/airdrops/escrow' },
{ name: 'Register', href: '/airdrops/register' },
{ name: 'Fund', href: '/airdrops/fund' },
{ name: 'Manage', href: '/airdrops/manage' },
] as const

export interface AirdropsStepperProps {
Expand Down
3 changes: 2 additions & 1 deletion components/AirdropsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface AirdropData {
expiration: number
expirationType: string
logo: { url: string } | null
isTerraAirdrop?: boolean
}

export interface AirdropsTableProps extends ComponentProps<'table'> {
Expand Down Expand Up @@ -80,7 +81,7 @@ export const AirdropsTable = (props: AirdropsTableProps) => {
<div className="flex">
<AnchorButton
className={clsx({
invisible: !wallet.address || !airdrop.allocation,
invisible: !airdrop.isTerraAirdrop && (!wallet.address || !airdrop.allocation),
})}
href={`/airdrops/${airdrop.contractAddress}/claim`}
variant="outline"
Expand Down
123 changes: 113 additions & 10 deletions contracts/cw20/merkleAirdrop/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ interface ExecuteWithSignDataResponse {
signed: TxRaw
txHash: string
}

interface SignedClaimMsg {
addr: string
}

export interface SignedMessage {
claim_msg: SignedClaimMsg
signature: string
}

export interface CW20MerkleAirdropInstance {
readonly contractAddress: string

Expand All @@ -54,14 +64,16 @@ export interface CW20MerkleAirdropInstance {
expiration: Expiration,
total_amount: number,
) => Promise<string>
claim: (txSigner: string, stage: number, amount: string, proof: string[]) => Promise<string>
burn: (txSigner: string, stage: number) => Promise<string>
claim: (stage: number, amount: string, proof: string[], signedMessage?: SignedMessage) => Promise<string>
burn: (stage: number) => Promise<string>
withdraw: (stage: number, address: string) => Promise<string>
registerAndReleaseEscrow: (
merkleRoot: string,
start: Expiration,
expiration: Expiration,
totalAmount: number,
stage: number,
hrp?: string,
) => Promise<ExecuteWithSignDataResponse>
depositEscrow: () => Promise<ExecuteWithSignDataResponse>
fundWithSend: (amount: string) => Promise<ExecuteWithSignDataResponse>
Expand All @@ -74,11 +86,21 @@ export interface CW20MerkleAirdropMessages {
merkleRoot: string,
start: Expiration,
expiration: Expiration,
totalAmount: number,
stage: number,
hrp?: string,
) => [RegisterMessage, ReleaseEscrowMessage]
depositEscrow: (airdropAddress: string) => DepositEscrowMessage
claim: (airdropAddress: string, stage: number, amount: string, proof: string[]) => ClaimMessage
claim: (
airdropAddress: string,
stage: number,
amount: string,
proof: string[],
signedMessage?: SignedMessage,
) => ClaimMessage
fundWithSend: (recipient: string, amount: string) => FundWithSendMessage
burn: (airdropAddress: string, stage: number) => BurnMessage
withdraw: (airdropAddress: string, stage: number, address: string) => WithdrawMessage
}

export interface InstantiateMessage {
Expand All @@ -98,6 +120,8 @@ export interface RegisterMessage {
merkle_root: string
start: Expiration
expiration: Expiration
total_amount: number
hrp?: string
}
}
funds: Coin[]
Expand Down Expand Up @@ -134,6 +158,7 @@ export interface ClaimMessage {
stage: number
amount: string
proof: string[]
sig_info?: SignedMessage
}
}
funds: Coin[]
Expand All @@ -145,6 +170,29 @@ export interface FundWithSendMessage {
amount: Coin[]
}

export interface BurnMessage {
sender: string
contract: string
msg: {
burn: {
stage: number
}
}
funds: Coin[]
}

export interface WithdrawMessage {
sender: string
contract: string
msg: {
withdraw: {
stage: number
address: string
}
}
funds: Coin[]
}

export interface CW20MerkleAirdropContract {
instantiate: (
senderAddress: string,
Expand Down Expand Up @@ -229,13 +277,28 @@ export const CW20MerkleAirdrop = (client: SigningCosmWasmClient, txSigner: strin
return result.transactionHash
}

const claim = async (_txSigner: string, stage: number, amount: string, proof: string[]): Promise<string> => {
const result = await client.execute(_txSigner, contractAddress, { claim: { stage, amount, proof } }, fee)
const claim = async (
stage: number,
amount: string,
proof: string[],
signedMessage?: SignedMessage,
): Promise<string> => {
const result = await client.execute(
txSigner,
contractAddress,
{ claim: { stage, amount, proof, sig_info: signedMessage } },
fee,
)
return result.transactionHash
}

const burn = async (stage: number): Promise<string> => {
const result = await client.execute(txSigner, contractAddress, { burn: { stage } }, fee)
return result.transactionHash
}

const burn = async (_txSigner: string, stage: number): Promise<string> => {
const result = await client.execute(_txSigner, contractAddress, { burn: { stage } }, 'auto')
const withdraw = async (stage: number, address: string): Promise<string> => {
const result = await client.execute(txSigner, contractAddress, { withdraw: { stage, address } }, fee)
return result.transactionHash
}

Expand All @@ -245,6 +308,7 @@ export const CW20MerkleAirdrop = (client: SigningCosmWasmClient, txSigner: strin
expiration: Expiration,
totalAmount: number,
stage: number,
hrp?: string,
): Promise<ExecuteWithSignDataResponse> => {
const signed = await client.sign(
txSigner,
Expand All @@ -261,7 +325,8 @@ export const CW20MerkleAirdrop = (client: SigningCosmWasmClient, txSigner: strin
merkle_root: merkleRoot,
start,
expiration,
// total_amount: totalAmount,
total_amount: totalAmount.toString(),
hrp,
},
}),
),
Expand Down Expand Up @@ -384,6 +449,7 @@ export const CW20MerkleAirdrop = (client: SigningCosmWasmClient, txSigner: strin
registerMerkleRoot,
claim,
burn,
withdraw,
registerAndReleaseEscrow,
depositEscrow,
fundWithSend,
Expand Down Expand Up @@ -426,8 +492,9 @@ export const CW20MerkleAirdrop = (client: SigningCosmWasmClient, txSigner: strin
merkleRoot: string,
start: Expiration,
expiration: Expiration,
// totalAmount: number,
totalAmount: number,
stage: number,
hrp?: string,
): [RegisterMessage, ReleaseEscrowMessage] => {
return [
{
Expand All @@ -438,6 +505,8 @@ export const CW20MerkleAirdrop = (client: SigningCosmWasmClient, txSigner: strin
merkle_root: merkleRoot,
start,
expiration,
total_amount: totalAmount,
hrp,
},
},
funds: [],
Expand Down Expand Up @@ -469,7 +538,13 @@ export const CW20MerkleAirdrop = (client: SigningCosmWasmClient, txSigner: strin
}
}

const claim = (airdropAddress: string, stage: number, amount: string, proof: string[]): ClaimMessage => {
const claim = (
airdropAddress: string,
stage: number,
amount: string,
proof: string[],
signedMessage?: SignedMessage,
): ClaimMessage => {
return {
sender: txSigner,
contract: airdropAddress,
Expand All @@ -478,6 +553,7 @@ export const CW20MerkleAirdrop = (client: SigningCosmWasmClient, txSigner: strin
stage,
amount,
proof,
sig_info: signedMessage,
},
},
funds: [],
Expand All @@ -491,13 +567,40 @@ export const CW20MerkleAirdrop = (client: SigningCosmWasmClient, txSigner: strin
amount: [coin(amount, getNetworkConfig(NETWORK).feeToken)],
}
}
const burn = (airdropAddress: string, stage: number): BurnMessage => {
return {
sender: txSigner,
contract: airdropAddress,
msg: {
burn: {
stage,
},
},
funds: [],
}
}
const withdraw = (airdropAddress: string, stage: number, address: string): WithdrawMessage => {
return {
sender: txSigner,
contract: airdropAddress,
msg: {
withdraw: {
stage,
address,
},
},
funds: [],
}
}

return {
instantiate,
registerAndReleaseEscrow,
depositEscrow,
claim,
fundWithSend,
burn,
withdraw,
}
}

Expand Down
9 changes: 9 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ const nextConfig = {
)
return config
},
async redirects() {
return [
{
source: '/airdrops/:address/manage',
destination: '/airdrops/manage',
permanent: true,
},
]
},
}

module.exports = nextConfig
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "juno-tools",
"version": "1.2.1",
"version": "1.3.0",
"workspaces": [
"packages/*"
],
Expand All @@ -26,6 +26,8 @@
"@svgr/webpack": "^6",
"@tailwindcss/forms": "^0",
"@tailwindcss/line-clamp": "^0",
"@terra-money/terra.js": "^3.1.3",
"@terra-money/wallet-provider": "^3.9.4",
"axios": "^0",
"clsx": "^1",
"compare-versions": "^4",
Expand All @@ -42,12 +44,14 @@
"react-query": "^3",
"react-tracked": "^1",
"scheduler": "^0",
"styled-components": "^5.3.3",
"zustand": "^3"
},
"devDependencies": {
"@types/node": "^14",
"@types/react": "^18",
"@types/react-datetime-picker": "^3",
"@types/react-dom": "^17.0.11",
"autoprefixer": "^10",
"husky": "^7",
"lint-staged": "^12",
Expand Down Expand Up @@ -77,4 +81,4 @@
},
"prettier": "@juno-tools/prettier-config",
"private": true
}
}
Loading

0 comments on commit 5ba6a4c

Please sign in to comment.