Skip to content

Commit

Permalink
Merge pull request #28 from LinkdropHQ/dev
Browse files Browse the repository at this point in the history
added support for new networks
  • Loading branch information
spacehaz authored Aug 3, 2023
2 parents 2d007eb + f0f5dce commit 907379d
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 38 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Linkdrop SDK

## 2.0.8
- added 'base' and 'baseGoerli' network support

## 2.0.7
- 'only_preferred_wallet' removed

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ Linkdrop provides tools to distribute NFTs with links, QR codes or claim codes.
Currently, Linkdrop supports the following networks:
- Ethereum Mainnet
- Polygon Mainnet
- Basic Mainnet

Testnets:
- Goerli (Ethereum testnet)
- Mumbai (Polygon testnet)
- Basic Goerli (Basic testnet)

We can add support of any EVM-based chain by request. Please contact us If you need to use Linkdrop on other networks.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "linkdrop-sdk",
"version": "2.0.7",
"version": "2.0.8",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
Expand Down
4 changes: 3 additions & 1 deletion src/configs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ export const testnetsApiUrl = 'https://testnets.dashboard-api.linkdrop.io'
export const polygonJSONRPCUrl = 'https://rpc-mainnet.maticvigil.com/v1/ad4cd2ea018ddb1ccd0418ffa43c27b3d99fbd55'
export const mainnetJSONRPCUrl = 'https://mainnet.infura.io/v3/620c738fbe1843a18f47ada0e60e738a'
export const goerliJSONRPCUrl = 'https://goeli.infura.io/v3/620c738fbe1843a18f47ada0e60e738a'
export const mumbaiJSONRPCUrl = 'https://rpc-mumbai.maticvigil.com/v1/f592ae2e5afb3bebe39314e9bd0949de5b74cd2f'
export const mumbaiJSONRPCUrl = 'https://rpc-mumbai.maticvigil.com/v1/f592ae2e5afb3bebe39314e9bd0949de5b74cd2f'
export const basicJSONRPCUrl = 'https://developer-access-mainnet.base.org'
export const basicGoerliJSONRPCUrl = 'https://base-goerli.public.blastapi.io'
30 changes: 18 additions & 12 deletions src/helpers/define-json-rpc-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,29 @@ import {
polygonJSONRPCUrl,
mumbaiJSONRPCUrl,
goerliJSONRPCUrl,
mainnetJSONRPCUrl
mainnetJSONRPCUrl,
basicGoerliJSONRPCUrl,
basicJSONRPCUrl
} from '../configs'

const defineJSONRpcUrl = ({ chainId } : { chainId: number }) => {
const networkName = defineNetworkName(chainId)

if (networkName === 'matic') {
return polygonJSONRPCUrl
} else if (networkName === 'mumbai') {
return mumbaiJSONRPCUrl
} else if (networkName === 'goerli') {
return goerliJSONRPCUrl
} else if (networkName === 'mainnet') {
return mainnetJSONRPCUrl
switch (networkName) {
case 'matic':
return polygonJSONRPCUrl
case 'mumbai':
return mumbaiJSONRPCUrl
case 'goerli':
return goerliJSONRPCUrl
case 'mainnet':
return mainnetJSONRPCUrl
case 'basic':
return basicJSONRPCUrl
case 'basicGoerli':
return basicGoerliJSONRPCUrl
default:
return alert('Current chain id is not supported')
}

return alert('Current chain id is not supported')
}

export default defineJSONRpcUrl
2 changes: 2 additions & 0 deletions src/helpers/define-network-name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const defineNetworkName = (chainId: number | null) : string => {
case 5: return 'goerli'
case 137: return 'matic'
case 80001: return 'mumbai'
case 8453: return 'basic'
case 84531: return 'basicMumbai'
default: return 'mainnet'
}
}
Expand Down
10 changes: 0 additions & 10 deletions src/helpers/get-chain-id.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/helpers/get-chain-name.ts

This file was deleted.

4 changes: 0 additions & 4 deletions src/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { getChainId } from './get-chain-id'
import { parseLinkParams } from './parse-link-params'
import { getChainName } from './get-chain-name'
import getLinkParams from './get-link-params'
import getLinkStatus from './get-link-status'
import getContractVersion from './get-contract-version'
Expand All @@ -14,11 +12,9 @@ import defineCampaignSig from './define-campaign-sig'
import prepareAsset from './prepare-asset'

export {
getChainId,
parseLinkParams,
defineCampaignSig,
getBignumberInterval,
getChainName,
getLinkParams,
getLinkStatus,
getContractVersion,
Expand Down

0 comments on commit 907379d

Please sign in to comment.