Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

Commit

Permalink
fix: invalid alchemy api key
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed Jun 14, 2022
1 parent ca8c8ae commit 363c6b9
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 22 deletions.
3 changes: 3 additions & 0 deletions docs/.vuepress/init.ts
Expand Up @@ -19,6 +19,9 @@ export default defineClientConfig({
app.config.globalProperties.Unidata = Unidata;
app.config.globalProperties.unidata = new Unidata({
moralisWeb3APIKey: 'gqcVQSCpWGNlfs2nMM1xvW1pOmZhzHc058aNpEK8BKIp26Q39PJemBu5BJi6SZOD',
alchemyEthereumAPIKey: '4h0_z1B6WEmj9hp1HJZm7ujeWZpLR6rv',
alchemyPolygonAPIKey: 'm1tznK8U8nVecA0Zime5dzF8Pb2av70q',
alchemyFlowAPIKey: 'op8m1oqlivm297iodsezvn3hoya9960u',
});

(<any>window).unidata = app.config.globalProperties.unidata;
Expand Down
24 changes: 14 additions & 10 deletions docs/guide/README.md
Expand Up @@ -34,19 +34,23 @@ const unidata = new Unidata({
ipfsGateway?: string;
moralisWeb3APIKey?: string;
openseaAPIKey?: string;
alchemyAPIKey?: string;
alchemyEthereumAPIKey?: string;
alchemyPolygonAPIKey?: string;
alchemyFlowAPIKey?: string;
});
```

| Parameter | Default | Description |
| --------------------- | --------------------------- | ------------------------------------ |
| `infuraProjectID` | ethers default keys | The PROJECT ID of the Infura to use. |
| `ipfsGateway` | `'https://dweb.link/ipfs/'` | The IPFS gateway to use. |
| `moralisWeb3APIKey` | | Account Web3 API Key of Moralis. |
| `openseaAPIKey` | | API Key of OpenSea. |
| `alchemyAPIKey` | `'demo'` | API Key of Alchemy. |
| `web3StorageAPIToken` | Unidata default token | API Token of Web3 Storage. |
| `ethereumProvider` | window.ethereum | Ethereum provider |
| Parameter | Default | Description |
| ----------------------- | --------------------------- | ------------------------------------ |
| `infuraProjectID` | ethers default keys | The PROJECT ID of the Infura to use. |
| `ipfsGateway` | `'https://dweb.link/ipfs/'` | The IPFS gateway to use. |
| `moralisWeb3APIKey` | | Account Web3 API Key of Moralis. |
| `openseaAPIKey` | | API Key of OpenSea. |
| `alchemyEthereumAPIKey` | | API Key of Alchemy Ethereum. |
| `alchemyPolygonAPIKey` | | API Key of Alchemy Polygon. |
| `alchemyFlowAPIKey` | | API Key of Alchemy Flow. |
| `web3StorageAPIToken` | Unidata default token | API Token of Web3 Storage. |
| `ethereumProvider` | window.ethereum | Ethereum provider |

If you don't want to expose some api keys on the front end, or if you want to cache data for faster response and higher stability, then you can use the SDK for your Node.js project.

Expand Down
4 changes: 3 additions & 1 deletion docs/guide/assets/Ethereum-NFT/Alchemy.md
Expand Up @@ -6,7 +6,9 @@
You can use Alchemy API for free (no rate limit disclosed).
:::

You can initialize with `ipfsGateway` and `alchemyAPIKey` to potentially get a faster response or higher stability.
You must initialize with `alchemyEthereumAPIKey` and `alchemyPolygonAPIKey` to use this provider.

You can initialize with `ipfsGateway` to potentially get a faster response or higher stability.

## API

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/assets/Ethereum-NFT/Moralis.md
Expand Up @@ -11,7 +11,7 @@ You need to register a Moralis account to use it.

You can initialize with `ipfsGateway` to potentially get a faster response or higher stability.

You must initialize with `moralisWeb3APIKey`, which will expose your Moralis api key on the front end. The steps to get the key after registration are as follows:
You must initialize with `moralisWeb3APIKey` to use this provider, which will expose your Moralis api key on the front end. The steps to get the key after registration are as follows:

![](https://i.imgur.com/wXPAPfm.png)

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/assets/Ethereum-NFT/README.md
Expand Up @@ -4,7 +4,7 @@

[Ethereum NFT](https://ethereum.org/en/nft/) is a kind of token on Ethereum with a chaotic specification. They can be normalized through Unidata now.

You can initialize with `ipfsGateway` `alchemyAPIKey` `moralisWeb3APIKey` and `openseaAPIKey` to potentially get a faster response or higher stability.
You can initialize with `ipfsGateway` `alchemyEthereumAPIKey` `alchemyPolygonAPIKey` `moralisWeb3APIKey` and `openseaAPIKey` to potentially get a faster response or higher stability.

## API

Expand Down
4 changes: 3 additions & 1 deletion docs/guide/assets/Flow-NFT/Alchemy.md
Expand Up @@ -6,7 +6,9 @@
You can use Alchemy API for free (no rate limit disclosed).
:::

You can initialize with `ipfsGateway` and `alchemyAPIKey` to potentially get a faster response or higher stability.
You must initialize with `alchemyFlowAPIKey` to use this provider.

You can initialize with `ipfsGateway` to potentially get a faster response or higher stability.

## API

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/assets/Flow-NFT/README.md
Expand Up @@ -2,7 +2,7 @@

<Logos type="Assets" :names="['Flow', 'Alchemy']" />

You can initialize with `ipfsGateway` `alchemyAPIKey` to potentially get a faster response or higher stability.
You can initialize with `ipfsGateway` `alchemyFlowAPIKey` to potentially get a faster response or higher stability.

## API

Expand Down
21 changes: 17 additions & 4 deletions src/assets/ethereum-nft-alchemy.ts
Expand Up @@ -14,18 +14,31 @@ class EthereumNFTAlchemy extends Base {
let result: Asset[] = [];

const networkMap: {
[key: string]: string;
[key: string]: {
endpoint: string;
keyName: 'alchemyEthereumAPIKey' | 'alchemyPolygonAPIKey';
};
} = {
Ethereum: 'https://eth-mainnet.alchemyapi.io/v2/',
Polygon: 'https://polygon-mainnet.g.alchemy.com/v2/',
Ethereum: {
endpoint: 'https://eth-mainnet.alchemyapi.io/v2/',
keyName: 'alchemyEthereumAPIKey',
},
Polygon: {
endpoint: 'https://polygon-mainnet.g.alchemy.com/v2/',
keyName: 'alchemyPolygonAPIKey',
},
};

const cursor: string[] = [];
let total = 0;

await Promise.all(
Object.keys(networkMap).map(async (network, index) => {
const res = await axios.get(`${networkMap[network]}${this.main.options.alchemyAPIKey}/getNFTs/`, {
const key = this.main.options[networkMap[network].keyName];
if (!key) {
return;
}
const res = await axios.get(`${networkMap[network].endpoint}${key}/getNFTs/`, {
params: {
owner: options.identity,
pageKey: options.cursor?.[index],
Expand Down
8 changes: 7 additions & 1 deletion src/assets/flow-nft-alchemy.ts
Expand Up @@ -10,8 +10,14 @@ class FlowNFTAlchemy extends Base {
}

async get(options: AssetsOptions) {
if (!this.main.options.alchemyFlowAPIKey) {
return {
total: 0,
list: [],
};
}
const res = await axios.get(
`https://flow-mainnet.g.alchemy.com/v2/${this.main.options.alchemyAPIKey}/getNFTs/`,
`https://flow-mainnet.g.alchemy.com/v2/${this.main.options.alchemyFlowAPIKey}/getNFTs/`,
{
params: {
owner: options.identity,
Expand Down
5 changes: 3 additions & 2 deletions src/index.ts
Expand Up @@ -15,7 +15,9 @@ type IOptions = {
ipfsGateway?: string;
moralisWeb3APIKey?: string;
openseaAPIKey?: string;
alchemyAPIKey?: string;
alchemyEthereumAPIKey?: string;
alchemyPolygonAPIKey?: string;
alchemyFlowAPIKey?: string;
web3StorageAPIToken?: string;
ethereumProvider?: any;
};
Expand All @@ -33,7 +35,6 @@ class Unidata {
{},
{
ipfsGateway: 'https://gateway.ipfs.io/ipfs/',
alchemyAPIKey: 'demo',
web3StorageAPIToken:
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJkaWQ6ZXRocjoweDAyMDIwODZmRjU5OUU0Y0YyMzM4MkUzNjg1Y0NmZUEyOGNBODBCOTAiLCJpc3MiOiJ3ZWIzLXN0b3JhZ2UiLCJpYXQiOjE2NTIzNjM1Njk3NDUsIm5hbWUiOiJVbmlkYXRhIn0.XmsAuXvbTj4BFhZlJK4xXfbd0ltVZJCEhqdYcW_kLOo',
ethereumProvider: window.ethereum,
Expand Down

0 comments on commit 363c6b9

Please sign in to comment.