-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: rename networkType param and set default
- Loading branch information
Showing
30 changed files
with
869 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@moralisweb3/auth': patch | ||
'@moralisweb3/evm-utils': patch | ||
'@moralisweb3/streams': patch | ||
--- | ||
|
||
Rename `network` param to `networkType` for `Moralis.Streams` and `Moralis.Auth`, to communicate more clearly the purpose of this param. Also make this value optional and default to `"evm"` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export enum AuthNetworkType { | ||
EVM = 'evm', | ||
SOLANA = 'solana', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 23 additions & 7 deletions
30
packages/evmUtils/src/dataTypes/EvmChain/EvmChainParser.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
packages/integration/mockRequests/authApi/evmRequestChallenge.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { rest } from 'msw'; | ||
import { AUTH_API_ROOT, MOCK_API_KEY } from '../config'; | ||
|
||
const MockResponse: Record<string, { data: any; status: number }> = { | ||
VALID_RESPONSE: { | ||
data: { | ||
id: 'x8yok3wHhgfAOCfPx', | ||
message: | ||
'defi.finance wants you to sign in with your Ethereum account:\n0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B\n\n\nURI: https://defi.finance/\nVersion: 1\nChain ID: 1\nNonce: 984ge9Yuc9gLTMEJO\nIssued At: 2022-09-29T13:10:23.832Z', | ||
profileId: '0xed330cc4d7da53313bc7480dcdfcb876c05b94926e6156e3bd8667c0c542277b', | ||
}, | ||
status: 201, | ||
}, | ||
INVALID_ADDRESS: { | ||
data: { | ||
statusCode: 400, | ||
name: 'BadRequestException', | ||
message: ['address must be an Ethereum address'], | ||
}, | ||
status: 400, | ||
}, | ||
MULTI_ERROR: { | ||
data: { | ||
statusCode: 400, | ||
name: 'BadRequestException', | ||
message: ['domain must be a valid domain name', 'address must be an Ethereum address'], | ||
}, | ||
status: 400, | ||
}, | ||
}; | ||
|
||
export const mockEvmRequestChallenge = rest.post(`${AUTH_API_ROOT}/challenge/request/evm`, (req, res, ctx) => { | ||
const apiKey = req.headers.get('x-api-key'); | ||
const id = (req.body as Record<string, any>).statement as string; | ||
|
||
if (apiKey !== MOCK_API_KEY) { | ||
return res( | ||
ctx.status(401), | ||
ctx.json({ | ||
message: 'Api Key Not Present', | ||
}), | ||
); | ||
} | ||
|
||
if (MockResponse[id]) { | ||
return res(ctx.status(MockResponse[id].status), ctx.json(MockResponse[id].data)); | ||
} | ||
|
||
throw new Error('mockEvmRequestChallenge: Not supported scenario'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { rest } from 'msw'; | ||
import { AUTH_API_ROOT, MOCK_API_KEY } from '../config'; | ||
|
||
const MockResponse: Record<string, { data: any; status: number }> = { | ||
VALID_RESPONSE: { | ||
data: { | ||
id: 'fRyt67D3eRss3RrX', | ||
domain: 'defi.finance', | ||
chainId: '1', | ||
address: '0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B', | ||
statement: 'Please confirm', | ||
uri: 'https://defi.finance/', | ||
expirationTime: '2020-01-01T00:00:00.000Z', | ||
notBefore: '2020-01-01T00:00:00.000Z', | ||
resources: ['https://docs.moralis.io/'], | ||
version: '1.0', | ||
nonce: '0x1234567890abcdef0123456789abcdef1234567890abcdef', | ||
profileId: '0xbfbcfab169c67072ff418133124480fea02175f1402aaa497daa4fd09026b0e1', | ||
}, | ||
status: 201, | ||
}, | ||
|
||
INVALID_SIGNATURE: { | ||
data: { | ||
statusCode: 400, | ||
name: 'BadRequestException', | ||
message: 'Invalid Signature', | ||
}, | ||
status: 400, | ||
}, | ||
|
||
MULTI_ERROR: { | ||
data: { | ||
statusCode: 400, | ||
name: 'BadRequestException', | ||
message: ['message must be present', 'signature must be present'], | ||
}, | ||
status: 400, | ||
}, | ||
}; | ||
|
||
export const mockEvmVerify = rest.post(`${AUTH_API_ROOT}/challenge/verify/evm`, (req, res, ctx) => { | ||
const apiKey = req.headers.get('x-api-key'); | ||
const id = (req.body as Record<string, any>).message as string; | ||
|
||
if (apiKey !== MOCK_API_KEY) { | ||
return res( | ||
ctx.status(401), | ||
ctx.json({ | ||
message: 'Api Key Not Present', | ||
}), | ||
); | ||
} | ||
|
||
if (MockResponse[id]) { | ||
return res(ctx.status(MockResponse[id].status), ctx.json(MockResponse[id].data)); | ||
} | ||
|
||
throw new Error('mockEvmVerify: Not supported scenario'); | ||
}); |
Oops, something went wrong.