Skip to content

Commit

Permalink
feat(PLTF-353): get balances for eclipse (#610)
Browse files Browse the repository at this point in the history
* feat(PLTF-353): get balances for eclipse
  • Loading branch information
ex1st0r authored Mar 21, 2024
1 parent d5ad6ce commit 756ebf3
Show file tree
Hide file tree
Showing 19 changed files with 70 additions and 29 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 @@ -15,7 +15,7 @@
},
"dependencies": {
"@imtbl/imx-sdk": "^2.1.1",
"@rarible/api-client": "0.16.5-alpha.7",
"@rarible/api-client": "0.16.5-alpha.10",
"@rarible/connector": "^0.13.68-fix.12",
"@rarible/connector-beacon": "^0.13.68-fix.12",
"@rarible/connector-fcl": "^0.13.68-fix.12",
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 @@ -18,9 +18,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.7",
"@rarible/api-client": "0.16.5-alpha.10",
"@rarible/connector": "^0.13.68-fix.12",
"@rarible/types": "~0.9.24",
"@rarible/types": "~0.9.25",
"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.7",
"@rarible/api-client": "0.16.5-alpha.10",
"@rarible/ethereum-sdk-test-common": "^0.13.68-fix.12",
"@rarible/flow-test-common": "~0.5.75-fix.1",
"@rarible/sdk-wallet": "^0.13.68-fix.12",
"@rarible/types": "~0.9.24",
"@rarible/types": "~0.9.25",
"bignumber.js": "^9.0.1",
"jest-jasmine2": "^29.4.1"
},
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.67",
"@rarible/test-provider": "~0.5.0",
"@rarible/types": "~0.9.24",
"@rarible/types": "~0.9.25",
"@types/web3-provider-engine": "^14.0.1",
"eth-sig-util": "^3.0.1",
"ethereumjs-wallet": "^1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,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.7",
"@rarible/api-client": "0.16.5-alpha.10",
"@rarible/connector": "^0.13.68-fix.12",
"@rarible/connector-beacon": "^0.13.68-fix.12",
"@rarible/connector-fcl": "^0.13.68-fix.12",
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.24",
"@rarible/types": "~0.9.25",
"@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.7"
"@rarible/api-client": "0.16.5-alpha.10"
},
"devDependencies": {
"dotenv": "16.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/sdk-common/src/utils/blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const NonEVMBlockchains = [
Blockchain.FLOW,
Blockchain.TEZOS,
Blockchain.SOLANA,
Blockchain.ECLIPSE,
Blockchain.IMMUTABLEX,
] as const

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 @@ -17,13 +17,13 @@
"verify": "tsc --noEmit --project tsconfig-build.json"
},
"dependencies": {
"@rarible/api-client": "0.16.5-alpha.7",
"@rarible/api-client": "0.16.5-alpha.10",
"@rarible/estimate-middleware": "~0.9.6",
"@rarible/ethers-ethereum": "^0.13.68-fix.12",
"@rarible/sdk": "^0.13.68-fix.12",
"@rarible/sdk-wallet": "^0.13.68-fix.12",
"@rarible/test-provider": "~0.5.4",
"@rarible/types": "~0.9.24",
"@rarible/types": "~0.9.25",
"ethereumjs-wallet": "^1.0.2",
"ethers": "^5.6.2",
"web3": "1.8.2",
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.7",
"@rarible/api-client": "0.16.5-alpha.10",
"@rarible/flow-sdk": "~0.5.78-fix.3",
"@rarible/immutable-sdk": "^0.13.68-fix.12",
"@rarible/immutable-wallet": "^0.13.65",
Expand All @@ -39,7 +39,7 @@
"@rarible/sdk-wallet": "^0.13.68-fix.12",
"@rarible/solana-sdk": "^0.13.68-fix.12",
"@rarible/tezos-sdk": "0.1.46",
"@rarible/types": "~0.9.24",
"@rarible/types": "~0.9.25",
"@rarible/utils": "~0.9.10",
"@solana/web3.js": "~1.54.0",
"bignumber.js": "^9.0.1",
Expand Down
1 change: 1 addition & 0 deletions packages/sdk/src/common/domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ export type RequestCurrencyAssetType =
| ApiClient.TezosXTZAssetType
| ApiClient.TezosFTAssetType
| ApiClient.SolanaNftAssetType
| ApiClient.SolanaFtAssetType
| ApiClient.SolanaSolAssetType
2 changes: 1 addition & 1 deletion packages/sdk/src/common/get-currency-asset-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export function convertCurrencyIdToAssetType(id: ApiClient.CurrencyId): RequestC
tokenId: tokenId ? toBigNumber(tokenId) : undefined,
}
}
if (blockchain === Blockchain.SOLANA) {
if (blockchain === Blockchain.SOLANA || blockchain === Blockchain.ECLIPSE) {
if (contract === ZERO_ADDRESS) {
return {
"@type": "SOLANA_SOL",
Expand Down
6 changes: 6 additions & 0 deletions packages/sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ export function createRaribleSdk(
blockchainConfig.solanaNetwork,
config?.blockchain?.SOLANA
),
createSolanaSdk(
filterWallet(wallet, WalletType.SOLANA),
apis,
blockchainConfig.solanaNetwork,
config?.blockchain?.SOLANA
),
createImmutablexSdk(
filterWallet(wallet, WalletType.IMMUTABLEX),
apis,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { SolanaWallet, WalletType } from "@rarible/sdk-wallet"
import type { SolanaWalletProvider } from "@rarible/solana-wallet"
import type { SolanaKeypairWallet } from "@rarible/solana-wallet"
import { createRaribleSdk } from "../../../../index"
import type { IRaribleSdk } from "../../../../index"
import { LogsLevel } from "../../../../domain"

export function createSdk(wallet: SolanaWalletProvider): IRaribleSdk {
export function createSdk(wallet: SolanaKeypairWallet): IRaribleSdk {
const endpoint = process.env.SOLANA_CUSTOM_ENDPOINT !== "" ? process.env.SOLANA_CUSTOM_ENDPOINT : undefined
console.debug("solana endpoint:", endpoint)

Expand Down
30 changes: 29 additions & 1 deletion packages/sdk/src/sdk-blockchains/solana/tests/balance.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { toCollectionId, toCurrencyId, toUnionAddress, ZERO_ADDRESS } from "@rarible/types"
import {
toCollectionId,
toCurrencyId,
toUnionAddress,
ZERO_ADDRESS,
} from "@rarible/types"
import { getWallet } from "../common/test/test-wallets"
import { MintType } from "../../../types/nft/mint/prepare"
import { retry } from "../../../common/retry"
Expand Down Expand Up @@ -44,3 +49,26 @@ describe("Solana get balance", () => {
expect(parseFloat(balance.toString())).toBeGreaterThanOrEqual(1)
})
})

describe.skip("Eclipse get balance", () => {
const wallet = getWallet()
const sdk = createSdk(wallet)

test("get balance SOL", async () => {
console.log("wallet.publicKey", wallet.publicKey.toString())
const balance = await sdk.balances.getBalance(
toUnionAddress("SOLANA:EeLKq9SnMK6WNLdk8px7yT2JM5Gru8pgbAGghnBYArVt"),
toCurrencyId(`ECLIPSE:${ZERO_ADDRESS}`)
)
expect(parseFloat(balance.toString())).toBeGreaterThanOrEqual(1)
})

test("get balance wSOL", async () => {
const balance = await sdk.balances.getBalance(
toUnionAddress("SOLANA:EeLKq9SnMK6WNLdk8px7yT2JM5Gru8pgbAGghnBYArVt"),
toCurrencyId("ECLIPSE:So11111111111111111111111111111111111111112")
)
expect(parseFloat(balance.toString())).toBe("0.80485509")
})

})
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 @@ -69,6 +69,7 @@ export function createUnionSdk(
flow: IRaribleInternalSdk,
tezos: IRaribleInternalSdk,
solana: IRaribleInternalSdk,
eclipse: IRaribleInternalSdk,
immutablex: IRaribleInternalSdk,
): IRaribleInternalSdk {
return {
Expand All @@ -78,27 +79,31 @@ export function createUnionSdk(
TEZOS: tezos.balances,
SOLANA: solana.balances,
IMMUTABLEX: immutablex.balances,
ECLIPSE: eclipse.balances,
}),
nft: new UnionNftSdk({
EVM: evm.nft,
FLOW: flow.nft,
TEZOS: tezos.nft,
SOLANA: solana.nft,
IMMUTABLEX: immutablex.nft,
ECLIPSE: eclipse.nft,
}),
order: new UnionOrderSdk({
EVM: evm.order,
FLOW: flow.order,
TEZOS: tezos.order,
SOLANA: solana.order,
IMMUTABLEX: immutablex.order,
ECLIPSE: eclipse.order,
}),
restriction: new UnionRestrictionSdk({
EVM: evm.restriction,
FLOW: flow.restriction,
TEZOS: tezos.restriction,
SOLANA: solana.restriction,
IMMUTABLEX: immutablex.restriction,
ECLIPSE: eclipse.restriction,
}),
ethereum: new UnionEthereumSpecificSdk(evm.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.7",
"@rarible/api-client": "0.16.5-alpha.10",
"@rarible/ethereum-provider": "^0.13.67",
"@rarible/flow-sdk": "~0.5.78-fix.3",
"@rarible/protocol-ethereum-sdk": "^0.13.68-fix.12",
"@rarible/solana-sdk": "^0.13.68-fix.12",
"@rarible/tezos-sdk": "0.1.46",
"@rarible/types": "~0.9.24"
"@rarible/types": "~0.9.25"
},
"devDependencies": {
"@babel/cli": "^7.14.8",
Expand Down
4 changes: 2 additions & 2 deletions packages/wallet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
"@babel/runtime": "^7.15.4",
"@ethersproject/abstract-signer": "^5.4.0",
"@imtbl/imx-sdk": "^2.1.1",
"@rarible/api-client": "0.16.5-alpha.7",
"@rarible/api-client": "0.16.5-alpha.10",
"@rarible/ethereum-provider": "^0.13.67",
"@rarible/ethers-ethereum": "^0.13.68-fix.12",
"@rarible/fcl-types": "~0.5.56",
"@rarible/flow-sdk": "~0.5.78-fix.3",
"@rarible/solana-wallet": "^0.13.68-fix.12",
"@rarible/tezos-sdk": "0.1.46",
"@rarible/types": "~0.9.24",
"@rarible/types": "~0.9.25",
"@rarible/web3-ethereum": "^0.13.68-fix.12"
},
"devDependencies": {
Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6581,10 +6581,10 @@
dependencies:
callable-instance "^2.0.0"

"@rarible/api-client@0.16.5-alpha.7":
version "0.16.5-alpha.7"
resolved "https://registry.yarnpkg.com/@rarible/api-client/-/api-client-0.16.5-alpha.7.tgz#0f0105c240b20904169d0dd30717f231af03f4ed"
integrity sha512-ULAs+sjfdQQPzG86tNrvnqUO5747H0Kc+aNP4QI1Wvcj+cRNuPsMoOswBSMjQJjTRwsa/miqrRzaX8dBCimhzQ==
"@rarible/api-client@0.16.5-alpha.10":
version "0.16.5-alpha.10"
resolved "https://registry.yarnpkg.com/@rarible/api-client/-/api-client-0.16.5-alpha.10.tgz#9f9f43f3134bfd8db6507105903912fc0da8b202"
integrity sha512-GPAhX86KlfOhxnzFgUH6+Pv3PG1tQzsgZ7CtQQ6xKTDJ7fm+vGftBCheuVGogynwcvJ8vQ3sQhmu+mh2M7YoZA==

"@rarible/eslint-config-ts@~0.5.0":
version "0.5.0"
Expand Down Expand Up @@ -6743,10 +6743,10 @@
resolved "https://registry.yarnpkg.com/@rarible/types/-/types-0.9.3.tgz#16eac9f500b48e4bd4c43f2d93a84c46dc5a5a13"
integrity sha512-lvmmqyibKNqylXr9yYMdor+onv/2z7O8LThpEsO/DpM2nawJ8f/QeEPjlyqTpjVhQyrpGwwFjuNQCTiiJi3msg==

"@rarible/types@~0.9.24":
version "0.9.24"
resolved "https://registry.yarnpkg.com/@rarible/types/-/types-0.9.24.tgz#b3c38fed1c875f89905d56239b655190b645b691"
integrity sha512-iFhGHrBEzc1jZECOppQGIEWNekdzSWGxeSnNzcNJKx9wwkBcGl77F6xNblM4c4+1ghPZKFdf5bDQQzeDB/mUXg==
"@rarible/types@~0.9.25":
version "0.9.25"
resolved "https://registry.yarnpkg.com/@rarible/types/-/types-0.9.25.tgz#fdb77d1f9a52ca5e8a37dcf18f70296bb7a95e6e"
integrity sha512-AbtgPbuVQy5ecQFLniN2HFw1pdrU4nJFVSoLXWGOVaQOYCt3/EQohW21NeYKC8k9bMgcqsmqXEYJoZ1z472SmQ==

"@rarible/utils@^0.9.1":
version "0.9.1"
Expand Down

0 comments on commit 756ebf3

Please sign in to comment.