Skip to content

Commit

Permalink
chore: pacakge bump
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasRalee committed Sep 20, 2023
1 parent 94dd093 commit 0ccddec
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 39 deletions.
2 changes: 1 addition & 1 deletion packages/sdk-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"@injectivelabs/grpc-web-node-http-transport": "^0.0.2",
"@injectivelabs/grpc-web-react-native-transport": "^0.0.2",
"@injectivelabs/indexer-proto-ts": "1.11.9",
"@injectivelabs/mito-proto-ts": "1.0.45",
"@injectivelabs/mito-proto-ts": "1.0.46",
"@injectivelabs/networks": "^1.12.2-beta.4",
"@injectivelabs/test-utils": "^1.12.1",
"@injectivelabs/token-metadata": "^1.12.2-beta.12",
Expand Down
26 changes: 26 additions & 0 deletions packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcMitoApi.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { IndexerGrpcMitoApi } from './IndexerGrpcMitoApi'

const injectiveAddress = mockFactory.injectiveAddress
const vaultAddress = 'inj1zwv6feuzhy6a9wekh96cd57lsarmqlwxvdl4nk'
const idoAddress = 'inj1zwv6feuzhy6a9wekh96cd57lsarmqlwxvdl4nk'
const endpoints = getNetworkEndpoints(Network.Devnet)
const indexerGrpcMitoApi = new IndexerGrpcMitoApi(endpoints.indexer)

Expand Down Expand Up @@ -433,4 +434,29 @@ describe('IndexerGrpcMitoApi', () => {
)
}
})

test('fetchIDOWhitelist', async () => {
try {
const response = await indexerGrpcMitoApi.fetchIDOWhitelist({
idoAddress,
})

if (response.accounts.length === 0) {
console.warn('fetchIDOWhitelist.responseIsEmptyArray')
}

expect(response).toBeDefined()
expect(response).toEqual(
expect.objectContaining<
ReturnType<
typeof IndexerGrpcMitoTransformer.mitoWhitelistAccountResponseToWhitelistAccount
>
>(response),
)
} catch (e) {
console.error(
'IndexerGrpcMitoApi.fetchIDOWhitelist => ' + (e as any).message,
)
}
})
})
46 changes: 46 additions & 0 deletions packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcMitoApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -890,4 +890,50 @@ export class IndexerGrpcMitoApi extends BaseGrpcConsumer {
})
}
}

async fetchIDOWhitelist({
skip,
limit,
idoAddress,
}: {
skip?: number
limit?: number
idoAddress: string
}) {
const request = MitoApi.GetWhitelistRequest.create()

request.idoAddress = idoAddress

if (skip) {
request.skip = skip
}

if (limit) {
request.limit = limit
}

try {
const response = await this.retry<MitoApi.GetWhitelistResponse>(() =>
this.client.GetWhitelist(request),
)

return IndexerGrpcMitoTransformer.mitoWhitelistAccountResponseToWhitelistAccount(
response,
)
} catch (e: unknown) {
if (e instanceof InjectiveMetaRpc.GrpcWebError) {
throw new GrpcUnaryRequestException(new Error(e.toString()), {
code: e.code,
context: 'GetWhitelist',
contextModule: this.module,
})
}

throw new GrpcUnaryRequestException(e as Error, {
code: UnspecifiedErrorCode,
context: 'GetWhitelist',
contextModule: this.module,
})
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
MitoIDOSubscriber,
MitoPriceSnapshot,
MitoIDOSubscription,
MitoWhitelistAccount,
MitoLeaderboardEpoch,
MitoSubaccountBalance,
MitoMissionLeaderboard,
Expand Down Expand Up @@ -335,6 +336,7 @@ export class IndexerGrpcMitoTransformer {
status: IDO.status,
tokenPrice: IDO.tokenPrice,
quoteDenom: IDO.quoteDenom,
useWhitelist: IDO.useWhitelist,
capPerAddress: IDO.capPerAddress,
contractAddress: IDO.contractAddress,
subscribedAmount: IDO.subscribedAmount,
Expand Down Expand Up @@ -432,6 +434,15 @@ export class IndexerGrpcMitoTransformer {
}
}

static mitoWhitelistAccountToWhitelistAccount(
account: MitoApi.WhitelistAccount,
): MitoWhitelistAccount {
return {
accountAddress: account.accountAddress,
updatedAt: parseInt(account.updatedAt, 10),
}
}

static vaultResponseToVault(response: MitoApi.GetVaultResponse): MitoVault {
const [vault] = response.vault

Expand Down Expand Up @@ -615,4 +626,18 @@ export class IndexerGrpcMitoTransformer {
),
}
}

static mitoWhitelistAccountResponseToWhitelistAccount(
response: MitoApi.GetWhitelistResponse,
) {
return {
idoAddress: response.idoAddress,
accounts: response.accounts.map(
IndexerGrpcMitoTransformer.mitoWhitelistAccountToWhitelistAccount,
),
pagination: IndexerGrpcMitoTransformer.mitoPaginationToPagination(
response.pagination,
),
}
}
}
7 changes: 7 additions & 0 deletions packages/sdk-ts/src/client/indexer/types/mito.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ export interface MitoIDO {
progress: MitoIDOProgress[]
quoteDenom: string
stakeToSubscription: MitoStakeToSubscription[]
useWhitelist: boolean
}

export interface MitoIDOSubscriber {
Expand Down Expand Up @@ -238,6 +239,11 @@ export interface MitoIDOSubscription {
claimTxHash?: string
}

export interface MitoWhitelistAccount {
accountAddress: string
updatedAt: number
}

export type GrpcMitoIDO = MitoApi.IDO
export type GrpcMitoVault = MitoApi.Vault
export type GrpcMitoMission = MitoApi.Mission
Expand All @@ -257,6 +263,7 @@ export type GrpcMitoLeaderboardEntry = MitoApi.LeaderboardEntry
export type GrpcMitoLeaderboardEpoch = MitoApi.LeaderboardEpoch
export type GrpcMitoStakingStakingReward = MitoApi.StakingReward
export type GrpcMitoSubaccountBalance = MitoApi.SubaccountBalance
export type GrpcMitoWhitelistAccount = MitoApi.WhitelistAccount
export type GrpcMitoStakingStakingActivity = MitoApi.StakingActivity
export type GrpcMitoMissionLeaderboardEntry = MitoApi.MissionLeaderboardEntry
export type GrpcMitoIDOSubscriptionActivity = MitoApi.IDOSubscriptionActivity
34 changes: 0 additions & 34 deletions packages/sdk-ts/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,40 +49,6 @@ export const CW20_SWAP_CONTRACT_BY_NETWORK = {
[Network.Local]: 'inj177yh38g3ctu7cemxpa3c2kvwh2yslfxfmfa66h',
}

export const CW20_STAKING_CONTRACT_BY_NETWORK = {
[Network.Mainnet]: '',
[Network.MainnetLB]: '',
[Network.MainnetK8s]: '',
[Network.Public]: '',
[Network.Staging]: '',
[Network.Internal]: 'inj1pxzykc8qry3ytxwxr3ua72tn6e4wvusj40yy2w',
[Network.Testnet]: 'inj1pxzykc8qry3ytxwxr3ua72tn6e4wvusj40yy2w',
[Network.TestnetK8s]: 'inj1pxzykc8qry3ytxwxr3ua72tn6e4wvusj40yy2w',
[Network.TestnetOld]: 'inj1pxzykc8qry3ytxwxr3ua72tn6e4wvusj40yy2w',
[Network.TestnetSentry]: 'inj1pxzykc8qry3ytxwxr3ua72tn6e4wvusj40yy2w',
[Network.Devnet]: 'inj15r735cjk9m6ujxtqn9zgxtdhd2lfzslde6c0s5',
[Network.Devnet1]: 'inj15r735cjk9m6ujxtqn9zgxtdhd2lfzslde6c0s5',
[Network.Devnet2]: 'inj15r735cjk9m6ujxtqn9zgxtdhd2lfzslde6c0s5',
[Network.Local]: 'inj15r735cjk9m6ujxtqn9zgxtdhd2lfzslde6c0s5',
}

export const CW20_ALLOCATOR_CONTRACT_BY_NETWORK = {
[Network.Mainnet]: '',
[Network.MainnetLB]: '',
[Network.MainnetK8s]: '',
[Network.Public]: '',
[Network.Staging]: '',
[Network.Internal]: 'inj1qsft9ptmywulv5hjzufl77j784sr9hf5yj6fwx',
[Network.Testnet]: 'inj1qsft9ptmywulv5hjzufl77j784sr9hf5yj6fwx',
[Network.TestnetK8s]: 'inj1qsft9ptmywulv5hjzufl77j784sr9hf5yj6fwx',
[Network.TestnetSentry]: 'inj1qsft9ptmywulv5hjzufl77j784sr9hf5yj6fwx',
[Network.TestnetOld]: 'inj1qsft9ptmywulv5hjzufl77j784sr9hf5yj6fwx',
[Network.Devnet]: 'inj1nu9wf9dw384attnpu0pwfet5fajn05w2xp99u3',
[Network.Devnet1]: 'inj1nu9wf9dw384attnpu0pwfet5fajn05w2xp99u3',
[Network.Devnet2]: 'inj1nu9wf9dw384attnpu0pwfet5fajn05w2xp99u3',
[Network.Local]: 'inj1nu9wf9dw384attnpu0pwfet5fajn05w2xp99u3',
}

export const INJ_NAME_REGISTRY_CONTRACT_BY_NETWORK = {
[Network.Mainnet]: 'inj1hm8vs8sr2h9nk0x66vctfs528wrp6k3gtgg275',
[Network.MainnetLB]: 'inj1hm8vs8sr2h9nk0x66vctfs528wrp6k3gtgg275',
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2176,10 +2176,10 @@
protobufjs "^7.0.0"
rxjs "^7.4.0"

"@injectivelabs/[email protected].45":
version "1.0.45"
resolved "https://registry.yarnpkg.com/@injectivelabs/mito-proto-ts/-/mito-proto-ts-1.0.45.tgz#1d2f7bb2d91de5ee87801815178090878533287f"
integrity sha512-YFyT+7d09VFGuwE7UXBkfK+XlU/MNc7ZM0UKB460I3zB1yXU7RttME5eM8W2eJvej04cf109DlZVG4yAw60gZA==
"@injectivelabs/[email protected].46":
version "1.0.46"
resolved "https://registry.yarnpkg.com/@injectivelabs/mito-proto-ts/-/mito-proto-ts-1.0.46.tgz#d0e31c4ca2f76940771621b2fe88f9bc40c7a891"
integrity sha512-K1g5udssQd4pDNzMteUQiI3PLHsuBhCKT6wli2h05ImB0NFQcGbLQlk3lpzsdfE9Usx2hCmZiQNUfUouRrTBpQ==
dependencies:
"@injectivelabs/grpc-web" "^0.0.1"
google-protobuf "^3.14.0"
Expand Down

0 comments on commit 0ccddec

Please sign in to comment.