Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into default-networkType
Browse files Browse the repository at this point in the history
  • Loading branch information
ErnoW committed Sep 30, 2022
2 parents ce64de2 + 7533a10 commit 8f9faf4
Show file tree
Hide file tree
Showing 46 changed files with 309 additions and 208 deletions.
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"demo-nextjs",
"demo-express-proxy",
"demo-parse-server",
"demo-subabase-auth",
"demo-supabase-auth",
"demo-firebase-auth-functions",
"demo-firebase-proxy-functions",
"demo-moralis-stream"
Expand Down
6 changes: 6 additions & 0 deletions .changeset/gorgeous-plants-exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@moralisweb3/evm-utils': patch
'@moralisweb3/sol-utils': patch
---

Deprecate old testnets and add enums for SolNetwork
5 changes: 5 additions & 0 deletions .changeset/late-ladybugs-rescue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@moralisweb3/eslint-config': patch
---

Update peer dependency of eslint-plugin-etc
5 changes: 5 additions & 0 deletions .changeset/pretty-bikes-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@moralisweb3/streams': patch
---

Update types according to api changes: remove `address` and `tokenAddress`, add includeContractLogs, includeInternalTxs and allAddresses flags, and mape `topic0` an array
5 changes: 5 additions & 0 deletions .changeset/tall-nails-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@moralisweb3/streams': patch
---

Allow multiple addresses for Moralis.Streams.addAddress
1 change: 1 addition & 0 deletions demos/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@typescript-eslint/eslint-plugin": "^5.12.0",
"@typescript-eslint/parser": "^5.12.0",
"eslint": "^8.9.0",
"eslint-plugin-etc": "^2.0.2",
"eslint-plugin-import": "^2.26.0",
"@types/node": "^18.7.14",
"ts-node": "^10.9.1"
Expand Down
1 change: 1 addition & 0 deletions demos/express-proxy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@typescript-eslint/eslint-plugin": "^5.12.0",
"@typescript-eslint/parser": "^5.12.0",
"eslint": "^8.9.0",
"eslint-plugin-etc": "^2.0.2",
"eslint-plugin-import": "^2.26.0",
"ts-node": "^10.9.1",
"typescript": "^4.7.4",
Expand Down
1 change: 1 addition & 0 deletions demos/firebase-auth/functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@typescript-eslint/eslint-plugin": "^5.12.0",
"@typescript-eslint/parser": "^5.12.0",
"eslint": "^8.9.0",
"eslint-plugin-etc": "^2.0.2",
"eslint-plugin-import": "^2.26.0",
"firebase-functions-test": "^0.2.0",
"typescript": "^4.5.4"
Expand Down
1 change: 1 addition & 0 deletions demos/firebase-proxy/functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@typescript-eslint/eslint-plugin": "^5.12.0",
"@typescript-eslint/parser": "^5.12.0",
"eslint": "^8.9.0",
"eslint-plugin-etc": "^2.0.2",
"eslint-plugin-import": "^2.26.0",
"firebase-functions-test": "^0.2.0",
"typescript": "^4.5.4"
Expand Down
1 change: 1 addition & 0 deletions demos/moralis-stream/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@typescript-eslint/eslint-plugin": "^5.12.0",
"@typescript-eslint/parser": "^5.12.0",
"eslint": "^8.9.0",
"eslint-plugin-etc": "^2.0.2",
"eslint-plugin-import": "^2.26.0",
"ts-node": "^10.9.1",
"typescript": "^4.7.4",
Expand Down
6 changes: 0 additions & 6 deletions demos/moralis-stream/src/stream/streamService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ interface StreamOptions {

const DESCRIPTION = 'some description';
const TAG = 'transactions';
const ADDRESS = '0x992eCcC191D6F74E8Be187ed6B6AC196b08314f7';
const CHAINIDS = ['0x3', '0x4'];
const TYPE = 'wallet';

export async function addStream(options: StreamOptions) {
const { networkType, webhookUrl } = options;
Expand All @@ -18,9 +16,7 @@ export async function addStream(options: StreamOptions) {
webhookUrl,
chains: CHAINIDS,
tag: TAG,
type: TYPE,
description: DESCRIPTION,
address: ADDRESS,
includeNativeTxs: true,
});

Expand Down Expand Up @@ -53,9 +49,7 @@ export async function updateStream(id: string, options: StreamOptions) {
webhookUrl,
chains: CHAINIDS,
tag: TAG,
type: TYPE,
description: DESCRIPTION,
address: ADDRESS,
includeNativeTxs: true,
});

Expand Down
1 change: 1 addition & 0 deletions demos/parse-server-migration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@typescript-eslint/parser": "^5.12.0",
"axios": "^0.27.2",
"eslint": "^8.9.0",
"eslint-plugin-etc": "^2.0.2",
"eslint-plugin-import": "^2.26.0",
"mongodb-runner": "^4.9.0",
"prettier": "^2.7.1",
Expand Down
1 change: 1 addition & 0 deletions demos/parse-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@typescript-eslint/eslint-plugin": "^5.12.0",
"@typescript-eslint/parser": "^5.12.0",
"eslint": "^8.9.0",
"eslint-plugin-etc": "^2.0.2",
"eslint-plugin-import": "^2.26.0",
"mongodb-runner": "^4.9.0",
"prettier": "^2.7.1",
Expand Down
3 changes: 2 additions & 1 deletion demos/supabase-auth/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "demo-subabase-auth",
"name": "demo-supabase-auth",
"version": "1.0.0",
"main": "dist/index.js",
"private": true,
Expand All @@ -20,6 +20,7 @@
"@typescript-eslint/eslint-plugin": "^5.12.0",
"@typescript-eslint/parser": "^5.12.0",
"eslint": "^8.9.0",
"eslint-plugin-etc": "^2.0.2",
"eslint-plugin-import": "^2.26.0",
"ts-node": "^10.9.1",
"typescript": "^4.7.4",
Expand Down
2 changes: 2 additions & 0 deletions packages/eslintConfig/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ These rules are based on community standards and inspired by the airbnb and goog
```sh
npm install @moralisweb3/eslint-config \
@typescript-eslint/eslint-plugin@^5.13.0 \
@eslint-plugin-etc@^2.0.2 \
@typescript-eslint/parser@^5.0.0 \
--save-dev
```
Expand All @@ -19,6 +20,7 @@ or
```sh
yarn add @moralisweb3/eslint-config \
@typescript-eslint/eslint-plugin@^5.13.0 \
@eslint-plugin-etc@^2.0.2 \
@typescript-eslint/parser@^5.0.0 \
-D
```
Expand Down
1 change: 1 addition & 0 deletions packages/eslintConfig/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"eslint": "^8.22.0",
"@typescript-eslint/eslint-plugin": "^5.13.0",
"@typescript-eslint/parser": "^5.0.0",
"eslint-plugin-etc": "^2.0.2",
"eslint-plugin-import": "^2.26.0"
},
"devDependencies": {
Expand Down
7 changes: 7 additions & 0 deletions packages/evmUtils/src/dataTypes/EvmChain/EvmChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class EvmChain implements MoralisData, EvmChainable {
* Returns ROPSTEN chain
*
* @example EvmChain.ROPSTEN
* @deprecated see https://ethereum.org/en/developers/docs/networks/
*/
public static get ROPSTEN() {
return EvmChain.create(3);
Expand All @@ -46,6 +47,7 @@ export class EvmChain implements MoralisData, EvmChainable {
* Returns RINKEBY chain
*
* @example EvmChain.RINKEBY
* @deprecated see https://ethereum.org/en/developers/docs/networks/
*/
public static get RINKEBY() {
return EvmChain.create(4);
Expand All @@ -64,11 +66,16 @@ export class EvmChain implements MoralisData, EvmChainable {
* Returns KOVAN chain
*
* @example EvmChain.KOVAN
* @deprecated see https://ethereum.org/en/developers/docs/networks/
*/
public static get KOVAN() {
return EvmChain.create(42);
}

public static get SEPOLIA() {
return EvmChain.create(11155111);
}

/**
* Returns POLYGON chain
*
Expand Down
7 changes: 7 additions & 0 deletions packages/integration/mockRequests/streamApi/addAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ const AddAddressResponse: Record<string, { data: any; status: number }> = {
},
status: 200,
},
MULTIPLE_ADDRESSES: {
data: {
streamId: 'MULTIPLE_ADDRESSES',
address: ['0x295522b61890c3672d12efbff4358a6411ce996f', '0xd8da6bf26964af9d7eed9e03e53415d37aa96045'],
},
status: 200,
},
INVALID_ADDRESS: {
data: {
message: 'Invalid Address: some-address',
Expand Down
22 changes: 12 additions & 10 deletions packages/integration/mockRequests/streamApi/createStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ import { STREAM_API_ROOT, MOCK_API_KEY } from '../config';

export const mockCreateStreamOutput: Record<string, unknown> = {
webhookUrl: 'https://webhook.site/c76c6361-960d-4600-8498-9fecba8abb5f',
description: 'string',
tag: 'string',
tokenAddress: '0xdac17f958d2ee523a2206206994597c13d831ec7',
topic0: '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
filter: {},
abi: {},
address: '0x992eCcC191D6F74E8Be187ed6B6AC196b08314f7',
chainIds: ['0x3'],
type: 'wallet',
id: '3fa85f64-5717-4562-b3fc-2c963f66afa6',
description: 'test stream',
tag: 'test',
topic0: ['0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'],
allAddresses: false,
includeNativeTxs: false,
includeContractLogs: false,
includeInternalTxs: false,
abi: null,
filter: null,
chainIds: ['0x3', '0x4'],
status: 'active',
statusMessage: 'Stream is active',
};

export const mockCreateStream = rest.put(`${STREAM_API_ROOT}/streams/evm`, (req, res, ctx) => {
Expand Down
9 changes: 5 additions & 4 deletions packages/integration/mockRequests/streamApi/deleteStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ export const mockDeleteStreamOutput: Record<string, unknown> = {
webhookUrl: 'https://webhook.site/c76c6361-960d-4600-8498-9fecba8abb5f',
description: 'string',
tag: 'string',
tokenAddress: '0xdac17f958d2ee523a2206206994597c13d831ec7',
topic0: '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
topic0: ['0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'],
filter: {},
abi: {},
address: '0x992eCcC191D6F74E8Be187ed6B6AC196b08314f7',
chainIds: ['0x3'],
type: 'wallet',
id: '3fa85f64-5717-4562-b3fc-2c963f66afa6',
allAddresses: false,
includeNativeTxs: false,
includeContractLogs: false,
includeInternalTxs: false,
};

export const mockDeleteStream = rest.delete(`${STREAM_API_ROOT}/streams/evm/:id`, (req, res, ctx) => {
Expand Down
9 changes: 5 additions & 4 deletions packages/integration/mockRequests/streamApi/getStreams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ export const mockGetStreamsOutput = {
webhookUrl: 'https://webhook.site/c76c6361-960d-4600-8498-9fecba8abb5f',
description: 'string',
tag: 'string',
tokenAddress: '0xdac17f958d2ee523a2206206994597c13d831ec7',
topic0: '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
topic0: ['0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'],
filter: {},
abi: {},
address: '0x992eCcC191D6F74E8Be187ed6B6AC196b08314f7',
chainIds: ['0x3'],
type: 'wallet',
id: '3fa85f64-5717-4562-b3fc-2c963f66afa6',
allAddresses: false,
includeNativeTxs: false,
includeContractLogs: false,
includeInternalTxs: false,
},
],
cursor: 'string',
Expand Down
23 changes: 13 additions & 10 deletions packages/integration/mockRequests/streamApi/updateStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@ import { rest } from 'msw';
import { STREAM_API_ROOT, MOCK_API_KEY } from '../config';

export const mockUpdateStreamOutput: Record<string, unknown> = {
id: 'VALID_REQUEST',
webhookUrl: 'https://webhook.site/c76c6361-960d-4600-8498-9fecba8abb5f',
description: 'string',
tag: 'string',
tokenAddress: '0xdac17f958d2ee523a2206206994597c13d831ec7',
topic0: '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
filter: {},
abi: {},
address: '0x992eCcC191D6F74E8Be187ed6B6AC196b08314f7',
chainIds: ['0x3'],
type: 'wallet',
id: '3fa85f64-5717-4562-b3fc-2c963f66afa6',
description: 'test stream',
tag: 'test',
topic0: ['0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'],
allAddresses: false,
includeNativeTxs: false,
includeContractLogs: false,
includeInternalTxs: false,
abi: null,
filter: null,
chainIds: ['0x3', '0x4'],
status: 'active',
statusMessage: 'Stream is active',
};

export const mockUpdateStream = rest.post(`${STREAM_API_ROOT}/streams/evm/:id`, (req, res, ctx) => {
Expand Down
15 changes: 15 additions & 0 deletions packages/integration/test/streamApi/addAddress.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ describe('addAddress', () => {
expect(result.result.streamId).toEqual('VALID_RESPONSE');
});

it('should create multiple addresses succesfully ', async () => {
const result = await StreamApi.addAddress({
networkType: 'evm',
address: ['0x295522b61890c3672d12efbff4358a6411ce996f', '0xd8da6bf26964af9d7eed9e03e53415d37aa96045'],
id: 'MULTIPLE_ADDRESSES',
});

expect(result).toBeDefined();
expect(result.toJSON().address).toStrictEqual([
'0x295522b61890c3672d12efbff4358a6411ce996f',
'0xd8da6bf26964af9d7eed9e03e53415d37aa96045',
]);
expect(result.result.streamId).toEqual('MULTIPLE_ADDRESSES');
});

it('should throw a 400 Error on invalid address ', async () => {
expect(
StreamApi.addAddress({
Expand Down
10 changes: 0 additions & 10 deletions packages/integration/test/streamApi/createStream.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,43 +15,35 @@ describe('Create stream', () => {
it('should create a stream ', async () => {
const result = await StreamApi.add({
chains: ['0x3'],
address: '0x992eCcC191D6F74E8Be187ed6B6AC196b08314f7',
tag: 'test',
description: 'test',
type: 'wallet',
webhookUrl: 'https://webhook.site/4f1b1b1b-1b1b-4f1b-1b1b-1b1b1b1b1b1b',
networkType: 'evm',
});

expect(result).toBeDefined();
expect(result).toEqual(expect.objectContaining({}));
expect(result.result.chainIds).toContain('0x3');
expect(result.result.type).toEqual('wallet');
});

it('should default to evm networkType', async () => {
const result = await StreamApi.add({
chains: ['0x3'],
address: '0x992eCcC191D6F74E8Be187ed6B6AC196b08314f7',
tag: 'test',
description: 'test',
type: 'wallet',
webhookUrl: 'https://webhook.site/4f1b1b1b-1b1b-4f1b-1b1b-1b1b1b1b1b1b',
});

expect(result).toBeDefined();
expect(result).toEqual(expect.objectContaining({}));
expect(result.result.chainIds).toContain('0x3');
expect(result.result.type).toEqual('wallet');
});

it('should not create stream', async () => {
const failedResult = await StreamApi.add({
chains: ['0x3'],
address: '0x992eCcC191D6F74E8Be187ed6B6AC196b08314f7',
tag: 'test',
description: 'test',
type: 'wallet',
webhookUrl: 'https://webhook.site/4f1b1b1b-1b1b-4f1b-1b1b-1b1b1b1b1b1b',
networkType: 'evm',
})
Expand All @@ -64,10 +56,8 @@ describe('Create stream', () => {
expect(
StreamApi.add({
chains: ['invalid_chain'],
address: '0x992eCcC191D6F74E8Be187ed6B6AC196b08314f7',
tag: 'test',
description: 'test',
type: 'wallet',
webhookUrl: 'https://webhook.site/4f1b1b1b-1b1b-4f1b-1b1b-1b1b1b1b1b1b',
networkType: 'evm',
}),
Expand Down
2 changes: 0 additions & 2 deletions packages/integration/test/streamApi/deleteStream.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ describe('Delete stream', () => {
expect(result).toBeDefined();
expect(result).toEqual(expect.objectContaining({}));
expect(result.result.chainIds).toContain('0x3');
expect(result.result.type).toEqual('wallet');
});

it('should default to evm networkType', async () => {
Expand All @@ -32,6 +31,5 @@ describe('Delete stream', () => {
expect(result).toBeDefined();
expect(result).toEqual(expect.objectContaining({}));
expect(result.result.chainIds).toContain('0x3');
expect(result.result.type).toEqual('wallet');
});
});
Loading

0 comments on commit 8f9faf4

Please sign in to comment.