Skip to content

Commit

Permalink
refactor: remove unused services (#10851)
Browse files Browse the repository at this point in the history
* refactor: clean up apis

* refactor: clean up apis
  • Loading branch information
guanbinrui committed Sep 25, 2023
1 parent 222986c commit 0a26488
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 44 deletions.
2 changes: 1 addition & 1 deletion packages/web3-providers/src/RedPacket/api.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import secondsToMilliseconds from 'date-fns/secondsToMilliseconds'
import { abiCoder, type ChainId, type SchemaType } from '@masknet/web3-shared-evm'
import { isSameAddress } from '@masknet/web3-shared-base'
import REDPACKET_ABI from '@masknet/web3-contracts/abis/HappyRedPacketV4.json'
import { ChainResolverAPI } from '../Web3/EVM/apis/ResolverAPI.js'
import { ConnectionReadonlyAPI } from '../Web3/EVM/apis/ConnectionReadonlyAPI.js'
import type { RedPacketJSONPayloadFromChain } from './types.js'
import { CREATE_LUCKY_DROP_TOPIC } from './constants.js'
import type { RedPacketBaseAPI } from '../entry-types.js'
import { isSameAddress } from '@masknet/web3-shared-base'

const creationSuccessTopicInputs = REDPACKET_ABI.find((x) => x.name === 'CreationSuccess')?.inputs!

Expand Down
5 changes: 0 additions & 5 deletions packages/web3-providers/src/RedPacket/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
export const TRANSACTIONS_BY_CONTRACT_METHOD_ENDPOINT =
'https://arql3twjl4.execute-api.us-east-1.amazonaws.com/prod/records'

export const MAX_SIZE_PER_PAGE = 1000

export const CREATE_LUCKY_DROP_TOPIC = '0x86af556fd7cfab9462285ad44f2d5913527c539ff549f74731ca9997ca534018'
37 changes: 2 additions & 35 deletions packages/web3-providers/src/SmartPay/apis/OwnerAPI.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import urlcat from 'urlcat'
import { compact, first, unionBy } from 'lodash-es'
import { padLeft, toHex } from 'web3-utils'
import { compact, first } from 'lodash-es'
import { NetworkPluginID } from '@masknet/shared-base'
import { queryClient } from '@masknet/shared-base-ui'
import { isSameAddress } from '@masknet/web3-shared-base'
Expand All @@ -11,7 +9,7 @@ import { SmartPayBundlerAPI } from './BundlerAPI.js'
import { SmartPayFunderAPI } from './FunderAPI.js'
import { ContractWallet } from '../libs/ContractWallet.js'
import { Create2Factory } from '../libs/Create2Factory.js'
import { LOG_ROOT, MAX_ACCOUNT_LENGTH, THE_GRAPH_PROD } from '../constants.js'
import { MAX_ACCOUNT_LENGTH, THE_GRAPH_PROD } from '../constants.js'
import { fetchJSON } from '../../helpers/fetchJSON.js'
import type { OwnerAPI } from '../../entry-types.js'

Expand Down Expand Up @@ -138,37 +136,6 @@ export class SmartPayOwnerAPI implements OwnerAPI.Provider<NetworkPluginID.PLUGI
)
}

/**
* Query the on-chain changeOwner event from chainbase.
* @param chainId
* @param owner
* @returns
*/
private async getAccountsFromChainbase(chainId: ChainId, owner: string) {
const { records: logs } = await fetchJSON<{ records: OwnerAPI.Log[]; count: number }>(
urlcat(LOG_ROOT, '/records', {
newOwnerAddress: padLeft(owner, 64),
size: MAX_ACCOUNT_LENGTH,
offset: 0,
}),
)

if (!logs) {
return []
}

return compact(
unionBy(logs, (x) => x.address.toLowerCase()).map((topic) => {
if (!isValidAddress(topic.address)) return

const previousOwner = toHex(topic.topic1.slice(-40))
if (!isValidAddress(previousOwner)) return

return this.createContractAccount(chainId, topic.address, owner, previousOwner, true)
}),
)
}

async getAccountByNonce(chainId: ChainId, owner: string, nonce: number) {
const create2Factory = await this.createCreate2Factory(chainId, owner)
const contractWallet = await this.createContractWallet(chainId, owner)
Expand Down
1 change: 0 additions & 1 deletion packages/web3-providers/src/SmartPay/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ export const BUNDLER_DEV = 'https://829m2iqdy4.execute-api.ap-east-1.amazonaws.c
export const BUNDLER_PROD = 'https://9rh2q3tdqj.execute-api.ap-east-1.amazonaws.com/'
export const FUNDER_DEV = 'https://rrh4bmg4j9.execute-api.ap-east-1.amazonaws.com/Prod/'
export const FUNDER_PROD = 'https://uldpla73li.execute-api.ap-east-1.amazonaws.com/Prod/'
export const LOG_ROOT = 'https://wovfx4lsvb.execute-api.us-east-1.amazonaws.com/prod/'
export const THE_GRAPH_PROD = 'https://api.thegraph.com/subgraphs/name/dimensiondev/paygas-x-subgraph'
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { Flags } from '@masknet/flags'

function isIgnoredRequest(request: Request) {
return [
// Twitter NFT Avatar API
'yb0w3z63oa',
// Twitter Identity API
'mr8asf7i4h',
// NextID
Expand Down

0 comments on commit 0a26488

Please sign in to comment.