Skip to content

Commit 6456a0d

Browse files
authored
move dd wrapped provider to rpc adapter pkg (#913)
* wip * basic example works * add doc and polish * move dd wrapped provider to rpc adapter pkg * fix
1 parent 3700887 commit 6456a0d

File tree

6 files changed

+20
-23
lines changed

6 files changed

+20
-23
lines changed

packages/eth-providers/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"@acala-network/contracts": "4.3.4",
1818
"@acala-network/eth-transactions": "workspace:*",
1919
"bn.js": "~5.2.0",
20-
"dd-trace": "~4.16.0",
2120
"ethers": "~5.7.0",
2221
"graphql": "~16.0.1",
2322
"graphql-request": "~3.6.1",
@@ -26,7 +25,6 @@
2625
"devDependencies": {
2726
"@acala-network/api": "~6.0.4",
2827
"@types/bn.js": "~5.1.0",
29-
"@types/dd-trace": "^0.9.0",
3028
"@types/lru-cache": "~7.6.1",
3129
"dotenv": "~10.0.0",
3230
"jsdom": "^22.0.0",

packages/eth-providers/src/rpc-provider.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { options } from '@acala-network/api';
22

33
import { ApiPromise, WsProvider } from '@polkadot/api';
44
import { BaseProvider, BaseProviderOptions } from './base-provider';
5-
import { BaseProviderWithTrace } from './base-provider-dd';
65

76
export class EvmRpcProvider extends BaseProvider {
87
constructor(endpoint: string | string[], opts?: BaseProviderOptions) {
@@ -18,18 +17,3 @@ export class EvmRpcProvider extends BaseProvider {
1817
return new EvmRpcProvider(endpoint, opt);
1918
}
2019
}
21-
22-
export class EvmRpcProviderWithTrace extends BaseProviderWithTrace {
23-
constructor(endpoint: string | string[], opts?: BaseProviderOptions) {
24-
super(opts);
25-
26-
const provider = new WsProvider(endpoint);
27-
const api = new ApiPromise(options({ provider }));
28-
29-
this.setApi(api);
30-
}
31-
32-
static from(endpoint: string | string[], opt?: BaseProviderOptions): EvmRpcProviderWithTrace {
33-
return new EvmRpcProviderWithTrace(endpoint, opt);
34-
}
35-
}

packages/eth-rpc-adapter/src/eip1193-bridge.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {
22
EvmRpcProvider,
3-
EvmRpcProviderWithTrace,
43
PROVIDER_ERRORS,
54
PollFilterType,
65
TX,
@@ -13,6 +12,7 @@ import { hexValue } from '@ethersproject/bytes';
1312
import EventEmitter from 'events';
1413
import WebSocket from 'ws';
1514

15+
import { EvmRpcProviderWithTrace } from './wrapped-provider';
1616
import { InvalidParams, MethodNotFound } from './errors';
1717
import { validate } from './validate';
1818
import { version } from './_version';

packages/eth-rpc-adapter/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import './utils/tracer';
22

33
import { Eip1193Bridge } from './eip1193-bridge';
4-
import { EvmRpcProviderWithTrace } from '@acala-network/eth-providers';
4+
import { EvmRpcProviderWithTrace } from './wrapped-provider';
55
import { Router } from './router';
66
import { monitorRuntime } from './utils/monitor-runtime';
77
import { yargsOptions as opts } from './utils';

packages/eth-providers/src/base-provider-dd.ts renamed to packages/eth-rpc-adapter/src/wrapped-provider.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { BaseProvider } from './base-provider';
1+
import { ApiPromise, WsProvider } from '@polkadot/api';
2+
import { BaseProvider, BaseProviderOptions } from '@acala-network/eth-providers/base-provider';
3+
import { options } from '@acala-network/api';
24
import tracer from 'dd-trace';
35

46
const TRACE_METHODS = [
@@ -79,3 +81,18 @@ export class BaseProviderWithTrace extends BaseProvider {
7981
}
8082
}
8183
}
84+
85+
export class EvmRpcProviderWithTrace extends BaseProviderWithTrace {
86+
constructor(endpoint: string | string[], opts?: BaseProviderOptions) {
87+
super(opts);
88+
89+
const provider = new WsProvider(endpoint);
90+
const api = new ApiPromise(options({ provider }));
91+
92+
this.setApi(api);
93+
}
94+
95+
static from(endpoint: string | string[], opt?: BaseProviderOptions): EvmRpcProviderWithTrace {
96+
return new EvmRpcProviderWithTrace(endpoint, opt);
97+
}
98+
}

yarn.lock

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)