Skip to content

Commit

Permalink
feat(PLTF-216): support rari blockchain (#586)
Browse files Browse the repository at this point in the history
* feat(PLTF-216): support rari blockchain
  • Loading branch information
ex1st0r authored Jan 9, 2024
1 parent 0914b70 commit deeb2bc
Show file tree
Hide file tree
Showing 27 changed files with 124 additions and 31 deletions.
2 changes: 1 addition & 1 deletion packages/connectors/connector-helper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"dependencies": {
"@imtbl/imx-sdk": "^2.1.1",
"@rarible/api-client": "0.16.5-alpha.2",
"@rarible/api-client": "0.16.5-alpha.6",
"@rarible/connector": "^0.13.65",
"@rarible/connector-beacon": "^0.13.65",
"@rarible/connector-fcl": "^0.13.65",
Expand Down
4 changes: 2 additions & 2 deletions packages/connectors/connector-mattel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
"@magic-ext/flow": "~13.5.0",
"@magic-ext/oidc": "~1.3.0",
"@onflow/fcl": "~1.3.2",
"@rarible/api-client": "0.16.5-alpha.2",
"@rarible/api-client": "0.16.5-alpha.6",
"@rarible/connector": "^0.13.65",
"@rarible/types": "~0.9.20",
"@rarible/types": "~0.9.21",
"magic-sdk": "~18.4.1"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
"verify": "tsc --noEmit"
},
"dependencies": {
"@rarible/api-client": "0.16.5-alpha.2",
"@rarible/api-client": "0.16.5-alpha.6",
"@rarible/ethereum-sdk-test-common": "^0.13.65",
"@rarible/flow-test-common": "~0.5.75-fix.1",
"@rarible/sdk-wallet": "^0.13.65",
"@rarible/types": "~0.9.20",
"@rarible/types": "~0.9.21",
"bignumber.js": "^9.0.1",
"jest-jasmine2": "^29.4.1"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ETHER_IN_WEI } from "./index"
export function checkGreaterThanMinPaymentValue({ assetType, value }: Asset, config: EthereumConfig): void {
if ((isETH(assetType) || isWeth(assetType, config) || isRari(assetType, config))
&& !toBn(value).gte(MIN_PAYMENT_VALUE)) {
throw new Warning(`Asset value must be less or equal to ${MIN_PAYMENT_VALUE.div(ETHER_IN_WEI).toFixed()}`)
throw new Warning(`Asset value must be greater or equal to ${MIN_PAYMENT_VALUE.div(ETHER_IN_WEI).toFixed()}`)
}
}

Expand Down
2 changes: 2 additions & 0 deletions packages/ethereum/sdk/src/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export function getBlockchainBySDKNetwork(network: EthereumNetwork): EVMBlockcha
case "lightlink":
case "testnet-lightlink":
return Blockchain.LIGHTLINK
case "testnet-rari":
return Blockchain.RARI
default: throw new Error(`Unrecognized ethereum network ${network}`)
}
}
2 changes: 2 additions & 0 deletions packages/ethereum/sdk/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { chilizConfig } from "./chilliz"
import { chilizTestnetConfig } from "./testnet-chiliz"
import { lightlinkConfig } from "./lightlink"
import { testnetLightlinkConfig } from "./testnet-lightlink"
import { rariTestnetConfig } from "./testnet-rari"

export const configDictionary: Record<EthereumNetwork, EthereumConfig> = {
mainnet: mainnetConfig,
Expand All @@ -34,6 +35,7 @@ export const configDictionary: Record<EthereumNetwork, EthereumConfig> = {
"testnet-chiliz": chilizTestnetConfig,
lightlink: lightlinkConfig,
"testnet-lightlink": testnetLightlinkConfig,
"testnet-rari": rariTestnetConfig,
}

export function getEthereumConfig(env: EthereumNetwork): EthereumConfig {
Expand Down
47 changes: 47 additions & 0 deletions packages/ethereum/sdk/src/config/testnet-rari.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { toAddress, ZERO_ADDRESS } from "@rarible/types"
import { id32 } from "../common/id"
import type { EthereumConfig } from "./type"
import { FEE_CONFIG_URL } from "./common"

export const rariTestnetConfig: EthereumConfig = {
basePath: "https://testnet-rari-api.rarible.org",
chainId: 1918988905,
exchange: {
v1: ZERO_ADDRESS,
v2: toAddress("0x61512179F6a16bEC0D259d8010CC0485CE363868"),
openseaV1: ZERO_ADDRESS,
wrapper: toAddress("0x3049455cdA17beE43d61090Ec344624aeda72Ed6"),
looksrare: ZERO_ADDRESS,
looksrareV2: ZERO_ADDRESS,
x2y2: ZERO_ADDRESS,
},
transferProxies: {
nft: toAddress("0x00C74eD067Cea48F1D6F7D00aBABa3C1D5B2598b"),
erc20: toAddress("0xA094E566b61b3c2D88ACf7Cc15e3Dd0FA83F32af"),
erc721Lazy: toAddress("0xB8863180CAC2d0Ab665e5968C0De25298A1D8CEe"),
erc1155Lazy: toAddress("0xa2eEBb837aEF89369Ad117568d75348e6174520e"),
openseaV1: ZERO_ADDRESS,
cryptoPunks: ZERO_ADDRESS,
},
feeConfigUrl: FEE_CONFIG_URL,
openSea: {
metadata: id32("RARIBLE"),
proxyRegistry: ZERO_ADDRESS,
merkleValidator: ZERO_ADDRESS,
},
factories: {
erc721: toAddress("0x41407B447Fb5425187A9BCA3a062644EF2410F8D"),
erc1155: toAddress("0xc798B273FaF23932Cf11177402C10C9b44D30Da2"),
},
cryptoPunks: {
marketContract: ZERO_ADDRESS,
wrapperContract: ZERO_ADDRESS,
},
sudoswap: {
pairFactory: ZERO_ADDRESS,
pairRouter: ZERO_ADDRESS,
},
weth: toAddress("0x6df6A970A5e92F93C65BD81dFf2D2ad4ab27C9CD"),
auction: ZERO_ADDRESS,
looksrareOrderValidatorV2: ZERO_ADDRESS,
}
2 changes: 2 additions & 0 deletions packages/ethereum/sdk/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type EthereumNetwork =
| "testnet-chiliz"
| "lightlink"
| "testnet-lightlink"
| "testnet-rari"

export enum LogsLevel {
DISABLED = 0,
Expand All @@ -39,6 +40,7 @@ export interface IRaribleEthereumSdkConfig {
arbitrum?: EthereumNetworkConfig
zksync?: EthereumNetworkConfig
chiliz?: EthereumNetworkConfig
rari?: EthereumNetworkConfig
marketplaceMarker?: Binary
apiKey?: string
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ethereum/test-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"dependencies": {
"@rarible/ethereum-provider": "^0.13.65",
"@rarible/test-provider": "~0.5.0",
"@rarible/types": "~0.9.20",
"@rarible/types": "~0.9.21",
"@types/web3-provider-engine": "^14.0.1",
"eth-sig-util": "^3.0.1",
"ethereumjs-wallet": "^1.0.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@mui/material": "^5.5.0",
"@nfid/embed": "0.0.5-alpha.0",
"@nfid/wallet": "^1.1.0",
"@rarible/api-client": "0.16.5-alpha.2",
"@rarible/api-client": "0.16.5-alpha.6",
"@rarible/connector": "^0.13.65",
"@rarible/connector-beacon": "^0.13.65",
"@rarible/connector-fcl": "^0.13.65",
Expand Down Expand Up @@ -69,7 +69,7 @@
"react-error-overlay": "6.0.9"
},
"scripts": {
"start": "SKIP_PREFLIGHT_CHECK=true NODE_OPTIONS=--openssl-legacy-provider react-app-rewired start",
"start": "SKIP_PREFLIGHT_CHECK=true react-app-rewired start",
"serve-static": "serve ./build",
"build": "mv common.env .env && CI=false NODE_OPTIONS=--max-old-space-size=6096 SKIP_PREFLIGHT_CHECK=true react-app-rewired build",
"eject": "SKIP_PREFLIGHT_CHECK=true react-app-rewired eject",
Expand Down
26 changes: 23 additions & 3 deletions packages/example/src/common/currency-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export function getCurrency(blockchain: Blockchain, type: CurrencyOption["type"]
case Blockchain.ARBITRUM:
case Blockchain.ZKSYNC:
case Blockchain.CHILIZ:
case Blockchain.RARI:
if (type === "TOKEN") {
return getERC20(contract)
}
Expand Down Expand Up @@ -264,8 +265,8 @@ export function getCurrencyOptions(
return res
}
return []
case Blockchain.CHILIZ:
if (currency.type === "ERC20") {
case Blockchain.CHILIZ: {
if (currency.type === "ERC20") {
const res: CurrencyOption[] = []
switch (environment) {
case"testnet":
Expand All @@ -286,9 +287,28 @@ export function getCurrencyOptions(
break
default:
}
return res
return res
}
return []
}
case Blockchain.RARI: {
if (currency.type === "ERC20") {
const res: CurrencyOption[] = []
switch (environment) {
case"testnet":
res.push({
type: "TOKEN",
label: "WETH",
blockchain: Blockchain.RARI,
contract: "RARI:0x6df6A970A5e92F93C65BD81dFf2D2ad4ab27C9CD",
})
break
default:
}
return res
}
return []
}
case Blockchain.IMMUTABLEX:
if (currency.type === "NATIVE") {
return { type: "NATIVE", label: "ETH", blockchain: Blockchain.IMMUTABLEX }
Expand Down
2 changes: 1 addition & 1 deletion packages/imx-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@rarible/immutable-wallet": "^0.13.65"
},
"devDependencies": {
"@rarible/types": "~0.9.20",
"@rarible/types": "~0.9.21",
"@rarible/utils": "~0.9.10",
"@types/jest": "^27.0.2",
"jest": "^27.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"verify": "tsc --noEmit --project tsconfig-build.json"
},
"dependencies": {
"@rarible/api-client": "0.16.5-alpha.2"
"@rarible/api-client": "0.16.5-alpha.6"
},
"devDependencies": {
"dotenv": "16.0.0",
Expand Down
2 changes: 2 additions & 0 deletions packages/sdk-common/src/utils/blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Blockchain } from "@rarible/api-client/build/models/Blockchain"

export type EVMBlockchain = Blockchain.ETHEREUM | Blockchain.POLYGON | Blockchain.MANTLE
| Blockchain.ARBITRUM | Blockchain.ZKSYNC | Blockchain.CHILIZ | Blockchain.LIGHTLINK
| Blockchain.RARI
export const EVMBlockchains: EVMBlockchain[] = [
Blockchain.ETHEREUM,
Blockchain.POLYGON,
Expand All @@ -10,6 +11,7 @@ export const EVMBlockchains: EVMBlockchain[] = [
Blockchain.ZKSYNC,
Blockchain.CHILIZ,
Blockchain.LIGHTLINK,
Blockchain.RARI,
]

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk-examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
"verify": "tsc --noEmit --project tsconfig-build.json"
},
"dependencies": {
"@rarible/api-client": "0.16.5-alpha.2",
"@rarible/api-client": "0.16.5-alpha.6",
"@rarible/estimate-middleware": "~0.9.6",
"@rarible/ethers-ethereum": "^0.13.65",
"@rarible/sdk": "^0.13.65",
"@rarible/sdk-wallet": "^0.13.65",
"@rarible/test-provider": "~0.5.4",
"@rarible/types": "~0.9.20",
"@rarible/types": "~0.9.21",
"ethereumjs-wallet": "^1.0.2",
"ethers": "^5.6.2",
"web3": ">=1.5.0 <1.9.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@babel/runtime": "^7.15.4",
"@ethersproject/keccak256": "^5.6.0",
"@rarible/action": "~0.9.1",
"@rarible/api-client": "0.16.5-alpha.2",
"@rarible/api-client": "0.16.5-alpha.6",
"@rarible/flow-sdk": "~0.5.76",
"@rarible/immutable-sdk": "^0.13.65",
"@rarible/immutable-wallet": "^0.13.65",
Expand All @@ -39,7 +39,7 @@
"@rarible/sdk-wallet": "^0.13.65",
"@rarible/solana-sdk": "^0.13.65",
"@rarible/tezos-sdk": "0.1.46",
"@rarible/types": "~0.9.20",
"@rarible/types": "~0.9.21",
"@rarible/utils": "~0.9.10",
"@solana/web3.js": "^1.35.1",
"bignumber.js": "^9.0.1",
Expand Down
1 change: 1 addition & 0 deletions packages/sdk/src/config/development.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export const developmentConfig: RaribleSdkConfig = {
zksync: "testnet-zksync",
chiliz: "testnet-chiliz",
lightlink: "testnet-lightlink",
rari: "testnet-rari",
}
1 change: 1 addition & 0 deletions packages/sdk/src/config/domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ export type RaribleSdkConfig = {
zksync: EthereumNetwork
chiliz: EthereumNetwork
lightlink: EthereumNetwork
rari: EthereumNetwork
}
1 change: 1 addition & 0 deletions packages/sdk/src/config/prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export const prodConfig: RaribleSdkConfig = {
zksync: "zksync",
chiliz: "chiliz",
lightlink: "lightlink",
rari: "testnet-rari",
}
1 change: 1 addition & 0 deletions packages/sdk/src/config/testnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export const testnetConfig: RaribleSdkConfig = {
zksync: "testnet-zksync",
chiliz: "testnet-chiliz",
lightlink: "testnet-lightlink",
rari: "testnet-rari",
}
7 changes: 7 additions & 0 deletions packages/sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,13 @@ export function createRaribleSdk(
blockchainConfig.lightlink,
ethConfig
),
createEthereumSdk(
filterWallet(wallet, WalletType.ETHEREUM),
apis,
Blockchain.RARI,
blockchainConfig.rari,
ethConfig
),
)

const sdkContext: ISdkContext = {
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/sdk-blockchains/solana/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class SolanaCollection {

try {
// calling this to let backend know what mint is actually created as a collection
await this.apis.collection.refreshCollectionMeta({
await this.apis.collection.refreshCollectionItemsMeta({
collection: collectionAddress,
})
} catch (e) {
Expand Down
5 changes: 5 additions & 0 deletions packages/sdk/src/sdk-blockchains/union/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export function createUnionSdk(
zksync: IRaribleInternalSdk,
chiliz: IRaribleInternalSdk,
lightlink: IRaribleInternalSdk,
rari: IRaribleInternalSdk,
): IRaribleInternalSdk {
return {
balances: new UnionBalanceSdk({
Expand All @@ -80,6 +81,7 @@ export function createUnionSdk(
ZKSYNC: zksync.balances,
CHILIZ: chiliz.balances,
LIGHTLINK: lightlink.balances,
RARI: rari.balances,
}),
nft: new UnionNftSdk({
ETHEREUM: ethereum.nft,
Expand All @@ -93,6 +95,7 @@ export function createUnionSdk(
ZKSYNC: zksync.nft,
CHILIZ: chiliz.nft,
LIGHTLINK: lightlink.nft,
RARI: rari.nft,
}),
order: new UnionOrderSdk({
ETHEREUM: ethereum.order,
Expand All @@ -106,6 +109,7 @@ export function createUnionSdk(
ZKSYNC: zksync.order,
CHILIZ: chiliz.order,
LIGHTLINK: lightlink.order,
RARI: rari.order,
}),
restriction: new UnionRestrictionSdk({
ETHEREUM: ethereum.restriction,
Expand All @@ -119,6 +123,7 @@ export function createUnionSdk(
ZKSYNC: zksync.restriction,
CHILIZ: chiliz.restriction,
LIGHTLINK: lightlink.restriction,
RARI: rari.restriction,
}),
ethereum: new UnionEthereumSpecificSdk(ethereum.ethereum!),
flow: new UnionFlowSpecificSdk(flow.flow!),
Expand Down
4 changes: 2 additions & 2 deletions packages/transaction/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
},
"dependencies": {
"@babel/runtime": "^7.15.4",
"@rarible/api-client": "0.16.5-alpha.2",
"@rarible/api-client": "0.16.5-alpha.6",
"@rarible/ethereum-provider": "^0.13.65",
"@rarible/flow-sdk": "~0.5.76",
"@rarible/protocol-ethereum-sdk": "^0.13.65",
"@rarible/solana-sdk": "^0.13.65",
"@rarible/tezos-sdk": "0.1.46",
"@rarible/types": "~0.9.20"
"@rarible/types": "~0.9.21"
},
"devDependencies": {
"@babel/cli": "^7.14.8",
Expand Down
2 changes: 2 additions & 0 deletions packages/transaction/src/ethereum/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ IBlockchainTransaction<Blockchain, TransactionResult> {
return `https://phoenix.lightlink.io/tx/${this.hash()}`
case "testnet-lightlink":
return `https://pegasus.lightlink.io/tx/${this.hash()}`
case "testnet-rari":
return `https://rari-testnet.calderaexplorer.xyz/tx/${this.hash()}`
default:
throw new Error("Unsupported transaction network")
}
Expand Down
Loading

0 comments on commit deeb2bc

Please sign in to comment.