Skip to content

Commit

Permalink
Merge branch 'main' into reskin
Browse files Browse the repository at this point in the history
  • Loading branch information
timpau authored Mar 20, 2024
2 parents 81de7db + 6b61eda commit f7332f5
Show file tree
Hide file tree
Showing 27 changed files with 704 additions and 626 deletions.
9 changes: 6 additions & 3 deletions frontend/claim_sdk/claim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ export type Ecosystem =
| 'evm'
| 'sui'
| 'aptos'
| 'cosmwasm'
| 'terra'
| 'osmosis'
| 'injective'
export const Ecosystems: Ecosystem[] = [
'discord',
'solana',
'evm',
'sui',
'aptos',
'cosmwasm',
'terra',
'osmosis',
'injective',
]

Expand Down Expand Up @@ -53,7 +55,8 @@ export class ClaimInfo {
}
break
}
case 'cosmwasm': {
case 'osmosis':
case 'terra': {
identityStruct = {
cosmwasm: { address: this.identity },
}
Expand Down
1 change: 1 addition & 0 deletions frontend/claim_sdk/merkleTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const LEAF_PREFIX = Buffer.from('00', 'hex')
const NODE_PREFIX = Buffer.from('01', 'hex')
const NULL_PREFIX = Buffer.from('02', 'hex')

// The size of the hash output in bytes
export const HASH_SIZE = 20

export class MerkleTree {
Expand Down
6 changes: 4 additions & 2 deletions frontend/claim_sdk/solana.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,8 @@ export class TokenDispenserProvider {
},
}
}
case 'cosmwasm': {
case 'osmosis':
case 'terra': {
return {
cosmwasm: {
pubkey: Array.from(signedMessage.publicKey),
Expand Down Expand Up @@ -426,7 +427,8 @@ export class TokenDispenserProvider {
recoveryId: signedMessage.recoveryId!,
})
}
case 'cosmwasm': {
case 'osmosis':
case 'terra': {
return undefined
}
case 'discord':
Expand Down
19 changes: 12 additions & 7 deletions frontend/claim_sdk/testWallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import { ethers } from 'ethers'
import fs from 'fs'
import { AminoSignResponse, Secp256k1HdWallet } from '@cosmjs/amino'
import { HdPath, stringToPath } from '@cosmjs/crypto'
import { makeADR36AminoSignDoc } from '@keplr-wallet/cosmos'
import NodeWallet from '@coral-xyz/anchor/dist/cjs/nodewallet'
import { Keypair, PublicKey } from '@solana/web3.js'
Expand Down Expand Up @@ -79,7 +80,8 @@ export async function loadTestWallets(): Promise<
evm: [],
sui: [],
aptos: [],
cosmwasm: [],
terra: [],
osmosis: [],
injective: [],
}
result['discord'] = [
Expand All @@ -89,10 +91,12 @@ export async function loadTestWallets(): Promise<
result['evm'] = [TestEvmWallet.fromKeyfile(evmPrivateKeyPath)]
result['sui'] = [TestSuiWallet.fromKeyfile(suiPrivateKeyPath)]
result['aptos'] = [TestAptosWallet.fromKeyfile(aptosPrivateKeyPath)]
result['cosmwasm'] = [
await TestCosmWasmWallet.fromKeyFile(cosmosPrivateKeyPath, 'sei'),
await TestCosmWasmWallet.fromKeyFile(cosmosPrivateKeyPath, 'osmo'),
await TestCosmWasmWallet.fromKeyFile(cosmosPrivateKeyPath, 'neutron'),
// prettier-ignore
result['osmosis'] = [await TestCosmWasmWallet.fromKeyFile(cosmosPrivateKeyPath, 'osmo')]
// prettier-ignore
result['terra'] = [await TestCosmWasmWallet.fromKeyFile(cosmosPrivateKeyPath, 'terra', [
stringToPath("m/44'/330'/0'/0/0"),
]),
]
result['injective'] = [TestEvmWallet.fromKeyfile(cosmosPrivateKeyPath, true)]

Expand Down Expand Up @@ -150,14 +154,15 @@ export class TestCosmWasmWallet implements TestWallet {
*/
static async fromKeyFile(
keyFile: string,
chainId?: string
prefix?: string,
hdPaths?: HdPath[]
): Promise<TestCosmWasmWallet> {
const jsonContent = fs.readFileSync(keyFile, 'utf8')

const mnemonic = JSON.parse(jsonContent).mnemonic
const wallet: Secp256k1HdWallet = await Secp256k1HdWallet.fromMnemonic(
mnemonic,
chainId ? { prefix: chainId } : {}
{ prefix, hdPaths }
)

const { address: addressStr } = (await wallet.getAccounts())[0]
Expand Down
3 changes: 1 addition & 2 deletions frontend/components/Ecosystem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ export enum Ecosystem {
SUI = 'Sui',
INJECTIVE = 'Injective',
OSMOSIS = 'Osmosis',
NEUTRON = 'Neutron',
SEI = 'Sei',
TERRA = 'Terra',
DISCORD = 'Pyth Discord',
}

Expand Down
7 changes: 2 additions & 5 deletions frontend/components/EcosystemConnectButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Ecosystem } from './Ecosystem'
import { AptosWalletButton } from './wallets/Aptos'
import { CosmosWalletButton } from './wallets/Cosmos'
import { EVMWalletButton } from './wallets/EVM'
import { SeiWalletButton } from './wallets/Sei'
import { SolanaWalletButton } from './wallets/Solana'
import { SuiWalletButton } from './wallets/Sui'

Expand All @@ -29,10 +28,10 @@ export function EcosystemConnectButton({
isInjective={true}
/>
)
case Ecosystem.NEUTRON:
case Ecosystem.TERRA:
return (
<CosmosWalletButton
chainName="neutron"
chainName="terra"
disableOnConnect={disableOnConnect}
/>
)
Expand All @@ -43,8 +42,6 @@ export function EcosystemConnectButton({
disableOnConnect={disableOnConnect}
/>
)
case Ecosystem.SEI:
return <SeiWalletButton />
case Ecosystem.SOLANA:
return <SolanaWalletButton disableOnConnect={disableOnConnect} />
case Ecosystem.SUI:
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/wallets/Cosmos.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import keplr from '@images/keplr.svg'

export const WALLET_NAME = 'keplr-extension'

export type ChainName = 'osmosis' | 'neutron' | 'sei'
export type ChainName = 'osmosis' | 'terra'

type CosmosWalletProviderProps = {
children: ReactNode
Expand Down
158 changes: 0 additions & 158 deletions frontend/components/wallets/Sei.tsx

This file was deleted.

16 changes: 4 additions & 12 deletions frontend/hooks/useGetEcosystemIdentity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {

import { Ecosystem } from '@components/Ecosystem'
import { useCallback } from 'react'
import { useSeiWalletContext } from '@components/wallets/Sei'
import { getInjectiveAddress } from '../utils/getInjectiveAddress'

// It will return a function that can be used to get the identity of a given ecosystem
Expand All @@ -18,10 +17,7 @@ export function useGetEcosystemIdentity() {
const aptosAddress = useAptosAddress()
const evmAddress = useEVMAddress()
const osmosisAddress = useCosmosAddress('osmosis')
const neutronAddress = useCosmosAddress('neutron')

const { connectedSeiWallet } = useSeiWalletContext()
const seiAddress = useCosmosAddress('sei', connectedSeiWallet ?? undefined)
const terraAddress = useCosmosAddress('terra')
const solanaAddress = useSolanaAddress()
const suiAddress = useSuiAddress()
// TODO update logic to get discord data from lambda function execution
Expand All @@ -40,14 +36,11 @@ export function useGetEcosystemIdentity() {
case Ecosystem.INJECTIVE:
return evmAddress ? getInjectiveAddress(evmAddress) : undefined

case Ecosystem.NEUTRON:
return neutronAddress

case Ecosystem.OSMOSIS:
return osmosisAddress

case Ecosystem.SEI:
return seiAddress
case Ecosystem.TERRA:
return terraAddress

case Ecosystem.SOLANA:
return solanaAddress
Expand All @@ -63,9 +56,8 @@ export function useGetEcosystemIdentity() {
aptosAddress,
data?.user?.hashedUserId,
evmAddress,
neutronAddress,
osmosisAddress,
seiAddress,
terraAddress,
solanaAddress,
suiAddress,
]
Expand Down
Loading

0 comments on commit f7332f5

Please sign in to comment.