Skip to content

Commit

Permalink
Fix webhook creation on arb and opt sepolia (#417)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshzhang5 committed Apr 3, 2024
1 parent fddd65f commit 1b6a070
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@

### Minor Changes

## 3.2.1

### Major Changes

- Added support for Arbitrum and Optimism Sepolia webhook creation.

### Minor Changes

- API error messages return the actual error instead of [Object object]

## 3.2.0

### Major Changes
Expand Down
2 changes: 2 additions & 0 deletions src/api/notify-namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,8 +639,10 @@ const WEBHOOK_NETWORK_TO_NETWORK: { [key: string]: Network } = {
MATIC_AMOY: Network.MATIC_AMOY,
ARB_MAINNET: Network.ARB_MAINNET,
ARB_GOERLI: Network.ARB_GOERLI,
ARB_SEPOLIA: Network.ARB_SEPOLIA,
OPT_MAINNET: Network.OPT_MAINNET,
OPT_GOERLI: Network.OPT_GOERLI,
OPT_SEPOLIA: Network.OPT_SEPOLIA,
BASE_MAINNET: Network.BASE_MAINNET,
BASE_GOERLI: Network.BASE_GOERLI,
BASE_SEPOLIA: Network.BASE_SEPOLIA
Expand Down
4 changes: 3 additions & 1 deletion src/internal/dispatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ export async function requestHttpWithBackoff<Req, Res>(
throw err;
}
// TODO: Standardize all errors into AlchemyError
lastError = new Error(err.response.status + ': ' + err.response.data);
lastError = new Error(
err.response.status + ': ' + JSON.stringify(err.response.data)
);
if (!isRetryableHttpError(err, apiType)) {
break;
}
Expand Down
14 changes: 8 additions & 6 deletions test/integration/notify.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('E2E integration tests', () => {
}
];

const webhookUrl = 'https://temp-site.ngrok.io';
const webhookUrl = 'https://www.example.com';
const graphqlQuery = '{ block { hash } }';

let addressWh: AddressActivityWebhook;
Expand Down Expand Up @@ -277,14 +277,15 @@ describe('E2E integration tests', () => {
});

it('create and delete NftActivityWebhook', async () => {
const network = Network.ETH_SEPOLIA;
const nftActivityWebhook = await alchemy.notify.createWebhook(
webhookUrl,
WebhookType.NFT_ACTIVITY,
{ filters: nftFilters, network: Network.ETH_GOERLI }
{ filters: nftFilters, network }
);
expect(nftActivityWebhook.url).toEqual(webhookUrl);
expect(nftActivityWebhook.type).toEqual(WebhookType.NFT_ACTIVITY);
expect(nftActivityWebhook.network).toEqual(Network.ETH_GOERLI);
expect(nftActivityWebhook.network).toEqual(network);
let response = await alchemy.notify.getAllWebhooks();
expect(
response.webhooks.filter(wh => wh.id === nftActivityWebhook.id).length
Expand All @@ -297,15 +298,16 @@ describe('E2E integration tests', () => {
).toEqual(0);
});

it('create and delete NftActivityWebhook', async () => {
it('create and delete NftMetadataUpdateWebhook', async () => {
const network = Network.ETH_MAINNET;
const nftActivityWebhook = await alchemy.notify.createWebhook(
webhookUrl,
WebhookType.NFT_METADATA_UPDATE,
{ filters: nftFilters, network: Network.ETH_GOERLI }
{ filters: nftFilters, network }
);
expect(nftActivityWebhook.url).toEqual(webhookUrl);
expect(nftActivityWebhook.type).toEqual(WebhookType.NFT_METADATA_UPDATE);
expect(nftActivityWebhook.network).toEqual(Network.ETH_GOERLI);
expect(nftActivityWebhook.network).toEqual(network);
let response = await alchemy.notify.getAllWebhooks();
expect(
response.webhooks.filter(wh => wh.id === nftActivityWebhook.id).length
Expand Down

0 comments on commit 1b6a070

Please sign in to comment.