Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
56e85d4
Merge pull request #94 from liquality/master
koderholic Mar 17, 2023
2848121
default to set gas, if gas estimate fails
koderholic Mar 19, 2023
ee4acf5
clear sensitive data
koderholic Mar 19, 2023
5e3ee43
clear sensitive data
koderholic Mar 19, 2023
692b1e2
add changeset
koderholic Mar 19, 2023
030abfe
Merge pull request #95 from liquality/fix-gas-estimate-error
koderholic Mar 19, 2023
90ea93e
chore: enter prerelease mode and version packages
github-actions[bot] Mar 19, 2023
3860cc8
Merge pull request #96 from liquality/changeset-release/develop
koderholic Mar 19, 2023
ecb3961
Ensure NFT metadata name field is always a string
darrylyeo Mar 20, 2023
39c5483
fix: deprecate rounding of formatted erc20 balance
havidtech Mar 20, 2023
e8847d7
fix: return raw metadata of nft
havidtech Mar 20, 2023
6765e5b
fix: return formatted native balance
havidtech Mar 20, 2023
b96f434
fix: use chaiID of ExternalProvider param if exist
havidtech Mar 20, 2023
db54242
Merge pull request #101 from havidtech/return-formatted-native-balance
johannafransn Mar 27, 2023
db90dd4
Merge pull request #99 from havidtech/fix-erc20-formatted-balance
johannafransn Mar 27, 2023
b424504
Merge pull request #98 from darrylyeo/patch-1
johannafransn Mar 27, 2023
689214f
Merge pull request #100 from havidtech/return-nft-raw-metadata
johannafransn Mar 27, 2023
faedf7b
Merge pull request #102 from havidtech/use-chainid-of-external-provider
johannafransn Mar 27, 2023
3abca20
Update README.md
johannafransn Mar 27, 2023
3f25ac8
Update readme.md
johannafransn Mar 30, 2023
1accfc1
support gaslessly custom transaction and update NFT data
koderholic Jun 9, 2023
6a41f0b
add changeset
koderholic Jun 9, 2023
f9a4632
Merge pull request #103 from liquality/feat/support-custom-contract
koderholic Jun 9, 2023
991257d
chore: enter prerelease mode and version packages
github-actions[bot] Jun 9, 2023
e2b300c
Merge pull request #104 from liquality/changeset-release/develop
koderholic Jun 9, 2023
7888931
fix: remove alchemy's strict check for nft-type
koderholic Jun 12, 2023
6371621
Merge pull request #105 from liquality/remove-nft-type-check
koderholic Jun 12, 2023
c2b325e
chore: enter prerelease mode and version packages
github-actions[bot] Jun 12, 2023
4ba53b0
Merge pull request #106 from liquality/changeset-release/develop
koderholic Jun 12, 2023
f78e057
feat: add isApprovedForAll to nft-service
koderholic Jun 13, 2023
41611f1
Merge pull request #107 from liquality/add-new-function
koderholic Jun 13, 2023
27d3b76
chore: enter prerelease mode and version packages
github-actions[bot] Jun 13, 2023
3979639
Merge pull request #108 from liquality/changeset-release/develop
koderholic Jun 13, 2023
db107bb
add changeset
koderholic Jun 19, 2023
2ee2b18
Merge pull request #109 from liquality/fix/getDefaultProvider-issue
koderholic Jun 19, 2023
efabd74
chore: enter prerelease mode and version packages
github-actions[bot] Jun 19, 2023
9c55459
Merge pull request #110 from liquality/changeset-release/develop
koderholic Jun 19, 2023
e38f46b
undo getDefaultProvider update
koderholic Jun 20, 2023
d1837c5
Merge pull request #111 from liquality/fix/getDefaultProvider-issue
koderholic Jun 20, 2023
cf22ece
add changeset
koderholic Jun 20, 2023
2146f12
Merge pull request #112 from liquality/fix/getDefaultProvider-issue
koderholic Jun 20, 2023
c6d6b7d
chore: enter prerelease mode and version packages
github-actions[bot] Jun 20, 2023
12116c9
Merge pull request #113 from liquality/changeset-release/develop
koderholic Jun 23, 2023
d8b097e
fix: update gelato-relay-sdk
koderholic Jun 29, 2023
e728b3c
Merge pull request #114 from liquality/update-gelato
koderholic Jun 29, 2023
c99412b
chore: enter prerelease mode and version packages
github-actions[bot] Jun 29, 2023
d266ec4
Merge pull request #115 from liquality/changeset-release/develop
koderholic Jun 29, 2023
e7405b9
feat: filter nfts by contract address
koderholic Jul 3, 2023
52f0d30
Merge pull request #116 from liquality/add-contract-filter-to-get-nfts
koderholic Jul 3, 2023
edb9e49
chore: enter prerelease mode and version packages
github-actions[bot] Jul 3, 2023
33be7dc
Merge pull request #117 from liquality/changeset-release/develop
koderholic Jul 3, 2023
86e813d
fix default provider issue
koderholic Jul 6, 2023
5c6f784
Merge pull request #118 from liquality/fix/fixDefaultProvider
koderholic Jul 6, 2023
721cc0e
chore: enter prerelease mode and version packages
github-actions[bot] Jul 6, 2023
64db3df
Merge pull request #119 from liquality/changeset-release/develop
koderholic Jul 6, 2023
e323da0
Updated chainIDs
koderholic Jul 6, 2023
0751e11
Merge pull request #120 from liquality/fix/update-chainIds
koderholic Jul 6, 2023
ff00747
chore: enter prerelease mode and version packages
github-actions[bot] Jul 6, 2023
f3f3ebe
Merge pull request #121 from liquality/changeset-release/develop
koderholic Jul 6, 2023
a6e0627
Add renovate.json
renovate[bot] Dec 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 7 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Turborepo starter
# Turborepo Wallet SDK starter

This is an official npm starter turborepo.

Expand All @@ -17,58 +17,25 @@ This turborepo uses [npm](https://www.npmjs.com/) as a package manager. It inclu

Each package/app is 100% [TypeScript](https://www.typescriptlang.org/).

### Utilities

This turborepo has some additional tools already setup for you:

- [TypeScript](https://www.typescriptlang.org/) for static type checking
- [ESLint](https://eslint.org/) for code linting
- [Prettier](https://prettier.io) for code formatting

### Build

To build all apps and packages, run the following command:

```
cd my-turborepo
yarn run build
```

### Develop

To develop all apps and packages, run the following command:
To develop all apps and packages, run the following command in the root folder:

```
cd my-turborepo
yarn run dev
yarn && yarn dev
```

### Remote Caching

Turborepo can use a technique known as [Remote Caching](https://turbo.build/repo/docs/core-concepts/remote-caching) to share cache artifacts across machines, enabling you to share build caches with your team and CI/CD pipelines.

By default, Turborepo will cache locally. To enable Remote Caching you will need an account with Vercel. If you don't have an account you can [create one](https://vercel.com/signup), then enter the following commands:

```
cd my-turborepo
npx turbo login
```

This will authenticate the Turborepo CLI with your [Vercel account](https://vercel.com/docs/concepts/personal-accounts/overview).
### Build

Next, you can link your Turborepo to your Remote Cache by running the following command from the root of your turborepo:
To build the wallet SDK, run the following command in wallet-sdk/packages/sdk folder:

```
npx turbo link
yarn && yarn compile && yarn build
```

## Useful Links

Learn more about the power of Turborepo:

- [Pipelines](https://turbo.build/repo/docs/core-concepts/monorepos/running-tasks)
- [Caching](https://turbo.build/repo/docs/core-concepts/caching)
- [Remote Caching](https://turbo.build/repo/docs/core-concepts/remote-caching)
- [Filtering](https://turbo.build/repo/docs/core-concepts/monorepos/filtering)
- [Configuration Options](https://turbo.build/repo/docs/reference/configuration)
- [CLI Usage](https://turbo.build/repo/docs/reference/command-line-reference)
Building the SDK is needed to generate types.
4 changes: 2 additions & 2 deletions apps/web-demo/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export default function Web() {
async function updateNfts() {
// if (!address) throw new Error("set address first");
// alert(window.ethereum.address)
// const hash = await NftService.createERC721Collection({tokenName: "gaslessNft", tokenSymbol:"gnft"}, 80001,"", true);
const hash = await NftService.mintERC721Token({contractAddress: "0x276d843c8c7f3aa6518b6ba119d92c6262dd3577", recipient:"0x97542289b1453eb8e9c0f4af562ef7eb354db75c", uri:"spark"}, 80001,"<private key>", true);
const hash = await NftService.createERC721Collection({tokenName: "gaslessNft", tokenSymbol:"gnft"}, 80001,"", true);
// const hash = await NftService.mintERC721Token({contractAddress: "0x276d843c8c7f3aa6518b6ba119d92c6262dd3577", recipient:"0x97542289b1453eb8e9c0f4af562ef7eb354db75c", uri:"spark"}, 80001,"<private key>", true);

console.log("hash => ",hash);
// console.log(nfts, "NFTS in my addr");
Expand Down
60 changes: 60 additions & 0 deletions packages/sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,65 @@
# @liquality/wallet-sdk

## 2.5.2

### Patch Changes

- e323da0: Update chain id for MATIC mainnet

## 2.5.1

### Patch Changes

- 86e813d: Update chain-providers for MATIC Mainnet

## 2.5.0

### Minor Changes

- e7405b9: filter getNfts by contract address

## 2.4.3

### Patch Changes

- d8b097e: fix: update gelato-relay-sdk

## 2.4.2

### Patch Changes

- cf22ece: Undo changes to getDefaultProvider

## 2.4.1

### Patch Changes

- db107bb: Resolve unsupported getDefaultProvider issue

## 2.4.0

### Minor Changes

- f78e057: feat: add isApprovedForAll to nft-service

## 2.3.1

### Patch Changes

- 7888931: some nfts return unknown as type from alchemy, you can provide the type yourself to avoid that blocker

## 2.3.0

### Minor Changes

- 6a41f0b: Support gasless custom transactions and update NFT data

## 2.2.1

### Patch Changes

- 692b1e2: Default to set gas, if gas estimate fails

## 2.2.0

### Minor Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@liquality/wallet-sdk",
"version": "2.2.0",
"version": "2.5.2",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"files": [
Expand Down Expand Up @@ -38,7 +38,7 @@
"url": "^0.11.0"
},
"dependencies": {
"@gelatonetwork/relay-sdk": "^3.4.0",
"@gelatonetwork/relay-sdk": "^4.0.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^14.4.3",
Expand Down
13 changes: 1 addition & 12 deletions packages/sdk/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,7 @@ You can use npm or yarn to install the Liquality SDK
npm install @liquality/wallet-sdk
```

Authentication is handled by key shares that allow for easy recoverability without compromising security.

### This is how it works:

The keys are managed by creating shares of the private key via Shamir Secret Sharing.

**ShareNumberOne** Could be stored on the user's device, similarly to how you usually can store a private key or seed phrase on a hardware device.

**ShareNumberTwo** could be split across the Web3Auth network, only accessed by a OAuth provider login that the user owns. This could be Google SSO, or any of the other login providers that are currently supported (Facebook, Twitch, Discord)

**ShareNumberThree**
This share is a recovery share, which can be accessed through a users set password
The Liquality Wallet SDK is a robust TypeScript library that has been purposefully designed to simplify the process of onboarding and building web3 applications. Its suite of powerful features includes the ability to facilitate self-custodial wallet creation and authentication through social single sign-on, as well as token and balance retrieval, NFT retrieval and minting, swaps, and much more.

---

Expand Down
6 changes: 5 additions & 1 deletion packages/sdk/src/account/account.service.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { ethers } from "ethers";
import { formatEther } from "ethers/lib/utils";
import { getChainProvider } from "../factory/chain-provider";


export abstract class AccountService {

public static async getBalance(address: string, chainID: number) {
let balance = await (await getChainProvider(chainID)).getBalance(address)
return balance.toString()
return {
rawBalance: balance.toString(),
formattedBalance: formatEther(balance)
}
}
}
2 changes: 1 addition & 1 deletion packages/sdk/src/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const CHAINS = {
},
[CHAIN_IDS.MATIC_MAINNET] : {
providerRPCs: {
ALCHEMY: "https://polygon-mumbai.g.alchemy.com/v2/",
ALCHEMY: "https://polygon-mainnet.g.alchemy.com/v2/",
INFURA: "https://polygon-mainnet.infura.io/v3/"
}
},
Expand Down
9 changes: 8 additions & 1 deletion packages/sdk/src/common/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { random, reject, update } from "lodash";
import { random } from "lodash";
import { getChainProvider } from "../factory/chain-provider";
import { ExternalProvider, Web3Provider } from "@ethersproject/providers";
import { Wallet } from "ethers";
Expand Down Expand Up @@ -43,4 +43,11 @@ export async function getWallet(pkOrProvider: string | ExternalProvider, chainID
return (await getChainProvider(chainID, pkOrProvider) as Web3Provider).getSigner()
}

export async function getChainID(pkOrProvider: string | ExternalProvider, chainID?: number): Promise<number> {
if(typeof pkOrProvider === 'string') return chainID!;

const hexChainID = await (pkOrProvider as ExternalProvider).request!({method: 'eth_chainId'});
return parseInt(hexChainID);
}


6 changes: 4 additions & 2 deletions packages/sdk/src/erc20/erc.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ERC20 as ERC20Contract, ERC20__factory } from "../../typechain-types";
import { AddressZero } from "@ethersproject/constants";
import { getChainProvider } from "../factory/chain-provider";
import { TransactionService } from "../transaction/transaction.service";
import { getWallet } from "../common/utils";
import { getChainID, getWallet } from "../common/utils";
import { ExternalProvider } from "@ethersproject/providers";
import { Gelato } from "../gasless-providers/gelato";

Expand Down Expand Up @@ -83,7 +83,7 @@ export abstract class ERC20Service {
formattedBalance = new BigNumber(balance).div(
Math.pow(10, metadata.decimals)
);
formattedBalance = formattedBalance.toFixed(2);
formattedBalance = formattedBalance.toString();
}

return {
Expand All @@ -100,6 +100,8 @@ export abstract class ERC20Service {
pkOrProvider: string | ExternalProvider,
isGasless: boolean
): Promise<string> {
chainId = await getChainID(pkOrProvider, chainId);

const { contractAddress, owner, receiver, amount } = transferRequest;
const contract: ERC20Contract = ERC20__factory.connect(
AddressZero,
Expand Down
2 changes: 2 additions & 0 deletions packages/sdk/src/factory/chain-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export function createChainProvider(chainId: number) {
let chainProvider;
if (chainId === CHAIN_IDS.BNB_MAINNET) {
chainProvider = new ethers.providers.JsonRpcProvider('https://bsc-dataseed.binance.org/', 56);
} else if (chainId === CHAIN_IDS.MATIC_MAINNET) {
chainProvider = new ethers.providers.JsonRpcProvider(CHAINS[chainId].providerRPCs.ALCHEMY+Config.ALCHEMY_API_KEY , 137);
} else if (chainId === CHAIN_IDS.MATIC_MUMBAI) {
chainProvider = new ethers.providers.JsonRpcProvider(CHAINS[chainId].providerRPCs.ALCHEMY+Config.ALCHEMY_API_KEY , 80001);
}
Expand Down
6 changes: 4 additions & 2 deletions packages/sdk/src/nft/nft.provider.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getContractAddress } from "ethers/lib/utils";
import { AlchemyNftProvider } from "./providers/alchemy-nft.provider";
import { BaseNftProvider } from "./providers/base-nft.provider";
import { Nft, NftsForContract, NftType } from "./types";
Expand All @@ -8,13 +9,14 @@ export abstract class NftProvider extends BaseNftProvider {
// Get all the NFTs owned by an address
public static async getNfts(
owner: string,
chainID: number
chainID: number,
contractAddresses?: string[]
): Promise<Nft[] | null> {
let nfts: any;

// Go through each nftProviders until one succeeds.
for (let i = 0; i < this.nftProviders.length && !nfts; i++) {
nfts = await this.nftProviders[i].getNfts(owner, chainID);
nfts = await this.nftProviders[i].getNfts(owner, chainID, contractAddresses);
}

return nfts;
Expand Down
Loading