Skip to content

Commit 3e07e38

Browse files
committed
near: support custom rpc
1 parent 1cf1ac5 commit 3e07e38

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

src/kiln.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ export class Kiln {
3636
this.sol = new SolService({ testnet, integrations, rpc: rpcs?.solana, });
3737
this.atom = new AtomService({ testnet, integrations, rpc: rpcs?.atom, });
3838
this.ada = new AdaService({ testnet, integrations });
39-
this.near = new NearService({ testnet, integrations });
39+
this.near = new NearService({ testnet, integrations, rpc: rpcs?.near });
4040
}
4141
}

src/services/near.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,18 @@ import { ADDRESSES } from "../globals";
2222
import { FinalExecutionOutcome } from "near-api-js/lib/providers";
2323

2424
export class NearService extends Service {
25+
private rpc: string | undefined;
2526

26-
constructor({ testnet, integrations }: InternalNearConfig) {
27+
constructor({ testnet, integrations, rpc }: InternalNearConfig) {
2728
super({ testnet, integrations });
29+
this.rpc = rpc;
2830
}
2931

3032
private async getConnection(): Promise<Near> {
33+
const officialRpc = `https://rpc.${this.testnet ? 'testnet' : 'mainnet'}.near.org`;
3134
const connectionConfig = {
3235
networkId: this.testnet ? 'testnet' : 'mainnet',
33-
nodeUrl: `https://rpc.${this.testnet ? 'testnet' : 'mainnet'}.near.org`,
36+
nodeUrl: this.rpc ?? officialRpc,
3437
};
3538
return await connect(connectionConfig);
3639
}

src/types/near.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { FinalExecutionOutcome } from "near-api-js/lib/providers";
44
export type InternalNearConfig = {
55
testnet?: boolean;
66
integrations: Integrations | undefined;
7+
rpc: string | undefined;
78
};
89

910

src/types/rpcs.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ export type Rpcs = {
22
ethereum: string;
33
solana: string;
44
atom: string;
5+
near: string;
56
}

0 commit comments

Comments
 (0)