@talismn/chain-connectors 1.1.1 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +0 -22
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +0 -22
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -27
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Account, PublicClient, WalletClient } from "viem";
|
|
2
2
|
import { Rpc, RpcTransport, SolanaRpcApi } from "@solana/kit";
|
|
3
3
|
import { DotNetwork, DotNetworkId, EthNetwork, EthNetworkId, IChaindataNetworkProvider, IChaindataTokenProvider, SolNetwork, SolNetworkId } from "@talismn/chaindata-provider";
|
|
4
|
-
//#region src/dot/IChainConnectorDot.d.ts
|
|
5
4
|
/** Callback signature for RPC subscriptions (error-first, matches the legacy polkadot-js ProviderInterfaceCallback) */
|
|
6
5
|
export type SubscriptionCallback = (error: Error | null, result: any) => void;
|
|
7
6
|
export interface IChainConnectorDot {
|
|
@@ -11,8 +10,6 @@ export interface IChainConnectorDot {
|
|
|
11
10
|
subscribe(chainId: DotNetworkId, subscribeMethod: string, responseMethod: string, params: unknown[], callback: SubscriptionCallback, timeout?: number | false): Promise<(unsubscribeMethod: string) => void>;
|
|
12
11
|
reset(chainId: DotNetworkId): Promise<void>;
|
|
13
12
|
}
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region src/dot/ChainConnectorDot.d.ts
|
|
16
13
|
export declare class ChainConnectionError extends Error {
|
|
17
14
|
type: "CHAIN_CONNECTION_ERROR";
|
|
18
15
|
chainId: string;
|
|
@@ -93,8 +90,6 @@ export declare class ChainConnectorDot implements IChainConnectorDot {
|
|
|
93
90
|
private getRandomId;
|
|
94
91
|
private getTalismanSub;
|
|
95
92
|
}
|
|
96
|
-
//#endregion
|
|
97
|
-
//#region src/dot/ChainConnectorDotPapi.d.ts
|
|
98
93
|
/** The parts of a polkadot-api `PolkadotClient` that the connector uses */
|
|
99
94
|
export type PapiClient = {
|
|
100
95
|
/** `PolkadotClient` types it without `abortSignal`, but it is substrate-client's `request`, which honours it */
|
|
@@ -127,8 +122,6 @@ export declare class ChainConnectorDotPapi implements IChainConnectorDot {
|
|
|
127
122
|
reset(): Promise<void>;
|
|
128
123
|
private getClient;
|
|
129
124
|
}
|
|
130
|
-
//#endregion
|
|
131
|
-
//#region src/dot/ChainConnectorDotStub.d.ts
|
|
132
125
|
export declare class ChainConnectorDotStub implements IChainConnectorDot {
|
|
133
126
|
#private;
|
|
134
127
|
constructor(network: DotNetwork);
|
|
@@ -137,15 +130,11 @@ export declare class ChainConnectorDotStub implements IChainConnectorDot {
|
|
|
137
130
|
reset(): Promise<void>;
|
|
138
131
|
destroy(): void;
|
|
139
132
|
}
|
|
140
|
-
//#endregion
|
|
141
|
-
//#region src/eth/IChainConnectorEth.d.ts
|
|
142
133
|
export interface IChainConnectorEth {
|
|
143
134
|
getPublicClientForEvmNetwork: (evmNetworkId: EthNetworkId) => Promise<PublicClient | null>;
|
|
144
135
|
getWalletClientForEvmNetwork: (evmNetworkId: EthNetworkId, account?: `0x${string}` | Account) => Promise<WalletClient | null>;
|
|
145
136
|
clearRpcProvidersCache: (evmNetworkId?: EthNetworkId) => void;
|
|
146
137
|
}
|
|
147
|
-
//#endregion
|
|
148
|
-
//#region src/eth/ChainConnectorEth.d.ts
|
|
149
138
|
export declare class ChainConnectorEth implements IChainConnectorEth {
|
|
150
139
|
#private;
|
|
151
140
|
constructor(chaindataProvider: IChaindataNetworkProvider & IChaindataTokenProvider);
|
|
@@ -153,8 +142,6 @@ export declare class ChainConnectorEth implements IChainConnectorEth {
|
|
|
153
142
|
getWalletClientForEvmNetwork(evmNetworkId: EthNetworkId, account?: `0x${string}` | Account): Promise<WalletClient | null>;
|
|
154
143
|
clearRpcProvidersCache(evmNetworkId?: EthNetworkId): void;
|
|
155
144
|
}
|
|
156
|
-
//#endregion
|
|
157
|
-
//#region src/eth/ChainConnectorEthStub.d.ts
|
|
158
145
|
export declare class ChainConnectorEthStub implements IChainConnectorEth {
|
|
159
146
|
#private;
|
|
160
147
|
constructor(network: EthNetwork);
|
|
@@ -162,8 +149,6 @@ export declare class ChainConnectorEthStub implements IChainConnectorEth {
|
|
|
162
149
|
getWalletClientForEvmNetwork(_networkId: EthNetworkId, account?: `0x${string}` | Account): Promise<WalletClient | null>;
|
|
163
150
|
clearRpcProvidersCache(): void;
|
|
164
151
|
}
|
|
165
|
-
//#endregion
|
|
166
|
-
//#region src/sol/getSolRpc.d.ts
|
|
167
152
|
export type SolRpc = Rpc<SolanaRpcApi>;
|
|
168
153
|
export type SolTransportOptions = {
|
|
169
154
|
/** Called with the url of the RPC that answered, after every successful request */
|
|
@@ -176,15 +161,11 @@ export type SolTransportOptions = {
|
|
|
176
161
|
*/
|
|
177
162
|
export declare const getSolTransport: (_networkId: SolNetworkId, rpcs: string[], options?: SolTransportOptions) => RpcTransport;
|
|
178
163
|
export declare const getSolRpc: (networkId: SolNetworkId, rpcs: string[], options?: SolTransportOptions) => SolRpc;
|
|
179
|
-
//#endregion
|
|
180
|
-
//#region src/sol/IChainConnectorSol.d.ts
|
|
181
164
|
export interface IChainConnectorSol {
|
|
182
165
|
getRpc: (networkId: SolNetworkId) => Promise<SolRpc>;
|
|
183
166
|
/** Raw JSON-RPC transport, used by the background script to relay frontend RPC requests */
|
|
184
167
|
getTransport: (networkId: SolNetworkId) => Promise<RpcTransport>;
|
|
185
168
|
}
|
|
186
|
-
//#endregion
|
|
187
|
-
//#region src/sol/ChainConnectorSol.d.ts
|
|
188
169
|
export declare class ChainConnectorSol implements IChainConnectorSol {
|
|
189
170
|
#private;
|
|
190
171
|
constructor(chaindataProvider: IChaindataNetworkProvider & IChaindataTokenProvider);
|
|
@@ -193,13 +174,10 @@ export declare class ChainConnectorSol implements IChainConnectorSol {
|
|
|
193
174
|
/** Drops cached transports/rpcs so the next call re-reads the network's rpcs from chaindata */
|
|
194
175
|
clearRpcProvidersCache(networkId?: SolNetworkId): void;
|
|
195
176
|
}
|
|
196
|
-
//#endregion
|
|
197
|
-
//#region src/sol/ChainConnectorSolStub.d.ts
|
|
198
177
|
export declare class ChainConnectorSolStub implements IChainConnectorSol {
|
|
199
178
|
#private;
|
|
200
179
|
constructor(network: Pick<SolNetwork, "id" | "rpcs">);
|
|
201
180
|
getRpc(): Promise<SolRpc>;
|
|
202
181
|
getTransport(): Promise<RpcTransport>;
|
|
203
182
|
}
|
|
204
|
-
//#endregion
|
|
205
183
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/dot/IChainConnectorDot.ts","../src/dot/ChainConnectorDot.ts","../src/dot/ChainConnectorDotPapi.ts","../src/dot/ChainConnectorDotStub.ts","../src/eth/IChainConnectorEth.ts","../src/eth/ChainConnectorEth.ts","../src/eth/ChainConnectorEthStub.ts","../src/sol/getSolRpc.ts","../src/sol/IChainConnectorSol.ts","../src/sol/ChainConnectorSol.ts","../src/sol/ChainConnectorSolStub.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/dot/IChainConnectorDot.ts","../src/dot/ChainConnectorDot.ts","../src/dot/ChainConnectorDotPapi.ts","../src/dot/ChainConnectorDotStub.ts","../src/eth/IChainConnectorEth.ts","../src/eth/ChainConnectorEth.ts","../src/eth/ChainConnectorEthStub.ts","../src/sol/getSolRpc.ts","../src/sol/IChainConnectorSol.ts","../src/sol/ChainConnectorSol.ts","../src/sol/ChainConnectorSolStub.ts"],"mappings":";;;;YAIY,wBAAwB,OAAO,cAAc;iBAExC;EACf,KAAK,aACH,SAAS,cACT,gBACA,mBACA,uBACA;IACE;MAED,QAAQ;EAEX,UACE,SAAS,cACT,yBACA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OlE,6BACJ,cAAc,cACd,0BAA0B,UACzB,QAAQ;EAOJ,uBAAuB,eAAe;;qBC5BlC,iCAAiC;;EAG5C,YAAY,SAAS;EAIf,gCAAgC,QAAQ;EAIxC,6BACJ,YAAY,cACZ,0BAA0B,UACzB,QAAQ;EAIX;;YCrBU,SAAS,IAAI;YAqHb;;EAEV,gBAAgB;;;;;;;qBAuDL,kBAAe,YACd,cAAY,gBACV,UACL,wBACR;qBAIU,YAAS,WACT,cAAY,gBACT,UACJ,wBACT;iBCzLc;EACf,SAAS,WAAW,iBAAiB,QAAQ;;EAE7C,eAAe,WAAW,iBAAiB,QAAQ;;qBCIxC,6BAA6B;;EAKxC,YAAY,mBAAmB,4BAA4B;EAWrD,aAAa,WAAW,eAAe,QAAQ;EAU/C,OAAO,WAAW,eAAe,QAAQ;;EAQ/C,uBAAuB,YAAY;;qBCtCxB,iCAAiC;;EAI5C,YAAY,SAAS,KAAK;EAKpB,UAAU,QAAQ;EAIlB,gBAAgB,QAAQ"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { DotNetwork, DotNetworkId, EthNetwork, EthNetworkId, IChaindataNetworkProvider, IChaindataTokenProvider, SolNetwork, SolNetworkId } from "@talismn/chaindata-provider";
|
|
2
2
|
import { Account, PublicClient, WalletClient } from "viem";
|
|
3
3
|
import { Rpc, RpcTransport, SolanaRpcApi } from "@solana/kit";
|
|
4
|
-
//#region src/dot/IChainConnectorDot.d.ts
|
|
5
4
|
/** Callback signature for RPC subscriptions (error-first, matches the legacy polkadot-js ProviderInterfaceCallback) */
|
|
6
5
|
export type SubscriptionCallback = (error: Error | null, result: any) => void;
|
|
7
6
|
export interface IChainConnectorDot {
|
|
@@ -11,8 +10,6 @@ export interface IChainConnectorDot {
|
|
|
11
10
|
subscribe(chainId: DotNetworkId, subscribeMethod: string, responseMethod: string, params: unknown[], callback: SubscriptionCallback, timeout?: number | false): Promise<(unsubscribeMethod: string) => void>;
|
|
12
11
|
reset(chainId: DotNetworkId): Promise<void>;
|
|
13
12
|
}
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region src/dot/ChainConnectorDot.d.ts
|
|
16
13
|
export declare class ChainConnectionError extends Error {
|
|
17
14
|
type: "CHAIN_CONNECTION_ERROR";
|
|
18
15
|
chainId: string;
|
|
@@ -93,8 +90,6 @@ export declare class ChainConnectorDot implements IChainConnectorDot {
|
|
|
93
90
|
private getRandomId;
|
|
94
91
|
private getTalismanSub;
|
|
95
92
|
}
|
|
96
|
-
//#endregion
|
|
97
|
-
//#region src/dot/ChainConnectorDotPapi.d.ts
|
|
98
93
|
/** The parts of a polkadot-api `PolkadotClient` that the connector uses */
|
|
99
94
|
export type PapiClient = {
|
|
100
95
|
/** `PolkadotClient` types it without `abortSignal`, but it is substrate-client's `request`, which honours it */
|
|
@@ -127,8 +122,6 @@ export declare class ChainConnectorDotPapi implements IChainConnectorDot {
|
|
|
127
122
|
reset(): Promise<void>;
|
|
128
123
|
private getClient;
|
|
129
124
|
}
|
|
130
|
-
//#endregion
|
|
131
|
-
//#region src/dot/ChainConnectorDotStub.d.ts
|
|
132
125
|
export declare class ChainConnectorDotStub implements IChainConnectorDot {
|
|
133
126
|
#private;
|
|
134
127
|
constructor(network: DotNetwork);
|
|
@@ -137,15 +130,11 @@ export declare class ChainConnectorDotStub implements IChainConnectorDot {
|
|
|
137
130
|
reset(): Promise<void>;
|
|
138
131
|
destroy(): void;
|
|
139
132
|
}
|
|
140
|
-
//#endregion
|
|
141
|
-
//#region src/eth/IChainConnectorEth.d.ts
|
|
142
133
|
export interface IChainConnectorEth {
|
|
143
134
|
getPublicClientForEvmNetwork: (evmNetworkId: EthNetworkId) => Promise<PublicClient | null>;
|
|
144
135
|
getWalletClientForEvmNetwork: (evmNetworkId: EthNetworkId, account?: `0x${string}` | Account) => Promise<WalletClient | null>;
|
|
145
136
|
clearRpcProvidersCache: (evmNetworkId?: EthNetworkId) => void;
|
|
146
137
|
}
|
|
147
|
-
//#endregion
|
|
148
|
-
//#region src/eth/ChainConnectorEth.d.ts
|
|
149
138
|
export declare class ChainConnectorEth implements IChainConnectorEth {
|
|
150
139
|
#private;
|
|
151
140
|
constructor(chaindataProvider: IChaindataNetworkProvider & IChaindataTokenProvider);
|
|
@@ -153,8 +142,6 @@ export declare class ChainConnectorEth implements IChainConnectorEth {
|
|
|
153
142
|
getWalletClientForEvmNetwork(evmNetworkId: EthNetworkId, account?: `0x${string}` | Account): Promise<WalletClient | null>;
|
|
154
143
|
clearRpcProvidersCache(evmNetworkId?: EthNetworkId): void;
|
|
155
144
|
}
|
|
156
|
-
//#endregion
|
|
157
|
-
//#region src/eth/ChainConnectorEthStub.d.ts
|
|
158
145
|
export declare class ChainConnectorEthStub implements IChainConnectorEth {
|
|
159
146
|
#private;
|
|
160
147
|
constructor(network: EthNetwork);
|
|
@@ -162,8 +149,6 @@ export declare class ChainConnectorEthStub implements IChainConnectorEth {
|
|
|
162
149
|
getWalletClientForEvmNetwork(_networkId: EthNetworkId, account?: `0x${string}` | Account): Promise<WalletClient | null>;
|
|
163
150
|
clearRpcProvidersCache(): void;
|
|
164
151
|
}
|
|
165
|
-
//#endregion
|
|
166
|
-
//#region src/sol/getSolRpc.d.ts
|
|
167
152
|
export type SolRpc = Rpc<SolanaRpcApi>;
|
|
168
153
|
export type SolTransportOptions = {
|
|
169
154
|
/** Called with the url of the RPC that answered, after every successful request */
|
|
@@ -176,15 +161,11 @@ export type SolTransportOptions = {
|
|
|
176
161
|
*/
|
|
177
162
|
export declare const getSolTransport: (_networkId: SolNetworkId, rpcs: string[], options?: SolTransportOptions) => RpcTransport;
|
|
178
163
|
export declare const getSolRpc: (networkId: SolNetworkId, rpcs: string[], options?: SolTransportOptions) => SolRpc;
|
|
179
|
-
//#endregion
|
|
180
|
-
//#region src/sol/IChainConnectorSol.d.ts
|
|
181
164
|
export interface IChainConnectorSol {
|
|
182
165
|
getRpc: (networkId: SolNetworkId) => Promise<SolRpc>;
|
|
183
166
|
/** Raw JSON-RPC transport, used by the background script to relay frontend RPC requests */
|
|
184
167
|
getTransport: (networkId: SolNetworkId) => Promise<RpcTransport>;
|
|
185
168
|
}
|
|
186
|
-
//#endregion
|
|
187
|
-
//#region src/sol/ChainConnectorSol.d.ts
|
|
188
169
|
export declare class ChainConnectorSol implements IChainConnectorSol {
|
|
189
170
|
#private;
|
|
190
171
|
constructor(chaindataProvider: IChaindataNetworkProvider & IChaindataTokenProvider);
|
|
@@ -193,13 +174,10 @@ export declare class ChainConnectorSol implements IChainConnectorSol {
|
|
|
193
174
|
/** Drops cached transports/rpcs so the next call re-reads the network's rpcs from chaindata */
|
|
194
175
|
clearRpcProvidersCache(networkId?: SolNetworkId): void;
|
|
195
176
|
}
|
|
196
|
-
//#endregion
|
|
197
|
-
//#region src/sol/ChainConnectorSolStub.d.ts
|
|
198
177
|
export declare class ChainConnectorSolStub implements IChainConnectorSol {
|
|
199
178
|
#private;
|
|
200
179
|
constructor(network: Pick<SolNetwork, "id" | "rpcs">);
|
|
201
180
|
getRpc(): Promise<SolRpc>;
|
|
202
181
|
getTransport(): Promise<RpcTransport>;
|
|
203
182
|
}
|
|
204
|
-
//#endregion
|
|
205
183
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/dot/IChainConnectorDot.ts","../src/dot/ChainConnectorDot.ts","../src/dot/ChainConnectorDotPapi.ts","../src/dot/ChainConnectorDotStub.ts","../src/eth/IChainConnectorEth.ts","../src/eth/ChainConnectorEth.ts","../src/eth/ChainConnectorEthStub.ts","../src/sol/getSolRpc.ts","../src/sol/IChainConnectorSol.ts","../src/sol/ChainConnectorSol.ts","../src/sol/ChainConnectorSolStub.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/dot/IChainConnectorDot.ts","../src/dot/ChainConnectorDot.ts","../src/dot/ChainConnectorDotPapi.ts","../src/dot/ChainConnectorDotStub.ts","../src/eth/IChainConnectorEth.ts","../src/eth/ChainConnectorEth.ts","../src/eth/ChainConnectorEthStub.ts","../src/sol/getSolRpc.ts","../src/sol/IChainConnectorSol.ts","../src/sol/ChainConnectorSol.ts","../src/sol/ChainConnectorSolStub.ts"],"mappings":";;;;YAIY,wBAAwB,OAAO,cAAc;iBAExC;EACf,KAAK,aACH,SAAS,cACT,gBACA,mBACA,uBACA;IACE;MAED,QAAQ;EAEX,UACE,SAAS,cACT,yBACA,wBACA,mBACA,UAAU,sBACV,2BACC,SAAS;EAEZ,MAAM,SAAS,eAAe;;qBCOnB,6BAA6B;EACxC;EACA;EAEA,YAAY,iBAAiB,UAAU;;;;;;qBAY5B,sBAAsB;EACjC;EACA;EAEA,YAAY,iBAAiB,UAAU;;YAmC7B;;;;;;;EAOV;;;;;;;;;;;;;;;;qBAiBW,6BAA6B;;EAOxC,YACE,wBAAwB,2BACxB,UAAU;EAON,KAAK,SACT,SAAS,cACT,gBACA,mBACA,oCACA;;;;;;;;;;IAUE;MAED,QAAQ;EAsDL,UACJ,SAAS,cACT,yBACA,wBACA,mBACA,UAAU,sBACV,2BACC,SAAS;;;;;;EA2FN,MAAM,SAAS,eAAY;;UA2BzB;;UA0BA;;;;;;UAgCM;UA2BA;UAgCN;UAoDA;UAeA;UAwBM;;UAYN;;UAQA;UAIA;;;YC/hBE;;EAEV,WAAW,OAAO,gBAAgB,mBAAmB,cAAc,gBAAgB,QAAQ;EAC3F;IACE,YAAY;MACV,OAAO;QAAU;;MACjB,QAAQ;MACR;;MACM;;;;;;;;;;;;qBAYC,iCAAiC;;EAG5C,YAAY,YAAY,WAAW,iBAAiB;EAI9C,KAAK,aAAa,WAAW,cAAc,gBAAgB,oBAAoB,QAAQ;EAIvF,UACJ,WAAW,cACX,yBACA,yBACA,mBACA,UAAU,sBACV,2BACC,SAAS;EA8FN,SAAK;UAEH;;qBC1IG,iCAAiC;;EAG5C,YAAY,SAAS;EAIf,KAAK,aACT,UAAU,cACV,gBACA,mBACA,yBACC,QAAQ;EAOL,UACJ,UAAU,cACV,yBACA,yBACA,mBACA,UAAU,sBACV,2BACC,SAAS;EA4BZ,SAAS;EAIT;;iBChEe;EACf,+BAA+B,cAAc,iBAAiB,QAAQ;EACtE,+BACE,cAAc,cACd,0BAA0B,YACvB,QAAQ;EACb,yBAAyB,eAAe;;qBCE7B,6BAA6B;;EAGxC,YAAY,mBAAmB,4BAA4B;EAIrD,6BAA6B,cAAc,eAAe,QAAQ;EAOlE,6BACJ,cAAc,cACd,0BAA0B,UACzB,QAAQ;EAOJ,uBAAuB,eAAe;;qBC5BlC,iCAAiC;;EAG5C,YAAY,SAAS;EAIf,gCAAgC,QAAQ;EAIxC,6BACJ,YAAY,cACZ,0BAA0B,UACzB,QAAQ;EAIX;;YCrBU,SAAS,IAAI;YAqHb;;EAEV,gBAAgB;;;;;;;qBAuDL,kBAAe,YACd,cAAY,gBACV,UACL,wBACR;qBAIU,YAAS,WACT,cAAY,gBACT,UACJ,wBACT;iBCzLc;EACf,SAAS,WAAW,iBAAiB,QAAQ;;EAE7C,eAAe,WAAW,iBAAiB,QAAQ;;qBCIxC,6BAA6B;;EAKxC,YAAY,mBAAmB,4BAA4B;EAWrD,aAAa,WAAW,eAAe,QAAQ;EAU/C,OAAO,WAAW,eAAe,QAAQ;;EAQ/C,uBAAuB,YAAY;;qBCtCxB,iCAAiC;;EAI5C,YAAY,SAAS,KAAK;EAKpB,UAAU,QAAQ;EAIlB,gBAAgB,QAAQ"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
2
|
+
// \0rolldown/runtime.js
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -20,7 +20,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
20
20
|
value: mod,
|
|
21
21
|
enumerable: true
|
|
22
22
|
}) : target, mod));
|
|
23
|
-
//#endregion
|
|
24
23
|
let _polkadot_api_substrate_client = require("@polkadot-api/substrate-client");
|
|
25
24
|
let _polkadot_api_ws_provider = require("@polkadot-api/ws-provider");
|
|
26
25
|
let anylogger = require("anylogger");
|
|
@@ -31,11 +30,9 @@ let lodash_es = require("lodash-es");
|
|
|
31
30
|
let viem_chains = require("viem/chains");
|
|
32
31
|
viem_chains = __toESM(viem_chains);
|
|
33
32
|
let _solana_kit = require("@solana/kit");
|
|
34
|
-
|
|
35
|
-
//#region src/log.ts
|
|
33
|
+
// src/log.ts
|
|
36
34
|
var log_default = (0, anylogger.default)("@talismn/chain-connectors");
|
|
37
|
-
|
|
38
|
-
//#region src/dot/ChainConnectorDot.ts
|
|
35
|
+
// src/dot/ChainConnectorDot.ts
|
|
39
36
|
const BAD_RPC_ERRORS = {
|
|
40
37
|
"-32097": "Rate limit exceeded",
|
|
41
38
|
"-32098": "Capacity exceeded"
|
|
@@ -400,8 +397,7 @@ var ChainConnectorDot = class {
|
|
|
400
397
|
};
|
|
401
398
|
}
|
|
402
399
|
};
|
|
403
|
-
|
|
404
|
-
//#region src/dot/ChainConnectorDotPapi.ts
|
|
400
|
+
// src/dot/ChainConnectorDotPapi.ts
|
|
405
401
|
const RESPONSE_TIMEOUT = 3e4;
|
|
406
402
|
const FAILURES_BEFORE_FIRST_RESULT = 3;
|
|
407
403
|
/**
|
|
@@ -513,8 +509,7 @@ const requestWithTimeout = (client, method, params, controller) => new Promise((
|
|
|
513
509
|
reject(error);
|
|
514
510
|
}
|
|
515
511
|
});
|
|
516
|
-
|
|
517
|
-
//#region src/dot/ChainConnectorDotStub.ts
|
|
512
|
+
// src/dot/ChainConnectorDotStub.ts
|
|
518
513
|
const TIMEOUT = 1e4;
|
|
519
514
|
var ChainConnectorDotStub = class {
|
|
520
515
|
#client;
|
|
@@ -553,8 +548,7 @@ var ChainConnectorDotStub = class {
|
|
|
553
548
|
this.#client.destroy();
|
|
554
549
|
}
|
|
555
550
|
};
|
|
556
|
-
|
|
557
|
-
//#region src/eth/getChainFromEvmNetwork.ts
|
|
551
|
+
// src/eth/getChainFromEvmNetwork.ts
|
|
558
552
|
const { zoraTestnet, ...validViemChains } = viem_chains;
|
|
559
553
|
const VIEM_CHAINS = Object.keys(validViemChains).reduce((acc, curr) => {
|
|
560
554
|
const chain = validViemChains[curr];
|
|
@@ -593,8 +587,7 @@ const getChainFromEvmNetwork = (network) => {
|
|
|
593
587
|
}
|
|
594
588
|
return chainsCache.get(network.id);
|
|
595
589
|
};
|
|
596
|
-
|
|
597
|
-
//#region src/eth/getTransportForEvmNetwork.ts
|
|
590
|
+
// src/eth/getTransportForEvmNetwork.ts
|
|
598
591
|
const FRONTIER_EXECUTION_ERROR = /VM Exception while processing transaction/;
|
|
599
592
|
const isFinalError = (error) => (0, viem.shouldThrow)(error) || FRONTIER_EXECUTION_ERROR.test(error.message);
|
|
600
593
|
const getTransportForEvmNetwork = (evmNetwork, options = {}) => {
|
|
@@ -608,8 +601,7 @@ const getTransportForEvmNetwork = (evmNetwork, options = {}) => {
|
|
|
608
601
|
shouldThrow: isFinalError
|
|
609
602
|
});
|
|
610
603
|
};
|
|
611
|
-
|
|
612
|
-
//#region src/eth/getEvmNetworkPublicClient.ts
|
|
604
|
+
// src/eth/getEvmNetworkPublicClient.ts
|
|
613
605
|
const MUTLICALL_BATCH_WAIT = 25;
|
|
614
606
|
const MUTLICALL_BATCH_SIZE = 100;
|
|
615
607
|
const HTTP_BATCH_WAIT = 25;
|
|
@@ -642,8 +634,7 @@ const getEvmNetworkPublicClient = (network) => {
|
|
|
642
634
|
}
|
|
643
635
|
return publicClientCache.get(network.id);
|
|
644
636
|
};
|
|
645
|
-
|
|
646
|
-
//#region src/eth/getEvmNetworkWalletClient.ts
|
|
637
|
+
// src/eth/getEvmNetworkWalletClient.ts
|
|
647
638
|
const getEvmNetworkWalletClient = (network, options = {}) => {
|
|
648
639
|
const chain = getChainFromEvmNetwork(network);
|
|
649
640
|
const transport = getTransportForEvmNetwork(network);
|
|
@@ -653,8 +644,7 @@ const getEvmNetworkWalletClient = (network, options = {}) => {
|
|
|
653
644
|
account: options.account
|
|
654
645
|
});
|
|
655
646
|
};
|
|
656
|
-
|
|
657
|
-
//#region src/eth/ChainConnectorEth.ts
|
|
647
|
+
// src/eth/ChainConnectorEth.ts
|
|
658
648
|
var ChainConnectorEth = class {
|
|
659
649
|
#chaindataProvider;
|
|
660
650
|
constructor(chaindataProvider) {
|
|
@@ -674,8 +664,7 @@ var ChainConnectorEth = class {
|
|
|
674
664
|
clearPublicClientCache(evmNetworkId);
|
|
675
665
|
}
|
|
676
666
|
};
|
|
677
|
-
|
|
678
|
-
//#region src/eth/ChainConnectorEthStub.ts
|
|
667
|
+
// src/eth/ChainConnectorEthStub.ts
|
|
679
668
|
var ChainConnectorEthStub = class {
|
|
680
669
|
#network;
|
|
681
670
|
constructor(network) {
|
|
@@ -689,8 +678,7 @@ var ChainConnectorEthStub = class {
|
|
|
689
678
|
}
|
|
690
679
|
clearRpcProvidersCache() {}
|
|
691
680
|
};
|
|
692
|
-
|
|
693
|
-
//#region src/sol/getSolRpc.ts
|
|
681
|
+
// src/sol/getSolRpc.ts
|
|
694
682
|
const MAX_429_RETRIES = 5;
|
|
695
683
|
const BASE_BACKOFF_MS = 500;
|
|
696
684
|
const getRateLimitContext = (error) => {
|
|
@@ -819,8 +807,7 @@ const getSolTransport = (_networkId, rpcs, options = {}) => {
|
|
|
819
807
|
return withRetryOn429(withFailover(rpcs, options));
|
|
820
808
|
};
|
|
821
809
|
const getSolRpc = (networkId, rpcs, options) => (0, _solana_kit.createSolanaRpcFromTransport)(getSolTransport(networkId, rpcs, options));
|
|
822
|
-
|
|
823
|
-
//#region src/sol/ChainConnectorSol.ts
|
|
810
|
+
// src/sol/ChainConnectorSol.ts
|
|
824
811
|
var ChainConnectorSol = class {
|
|
825
812
|
#chaindataProvider;
|
|
826
813
|
#transports = /* @__PURE__ */ new Map();
|
|
@@ -852,8 +839,7 @@ var ChainConnectorSol = class {
|
|
|
852
839
|
}
|
|
853
840
|
}
|
|
854
841
|
};
|
|
855
|
-
|
|
856
|
-
//#region src/sol/ChainConnectorSolStub.ts
|
|
842
|
+
// src/sol/ChainConnectorSolStub.ts
|
|
857
843
|
var ChainConnectorSolStub = class {
|
|
858
844
|
#transport;
|
|
859
845
|
#rpc;
|
|
@@ -868,7 +854,6 @@ var ChainConnectorSolStub = class {
|
|
|
868
854
|
return this.#transport;
|
|
869
855
|
}
|
|
870
856
|
};
|
|
871
|
-
//#endregion
|
|
872
857
|
exports.ChainConnectionError = ChainConnectionError;
|
|
873
858
|
exports.ChainConnectorDot = ChainConnectorDot;
|
|
874
859
|
exports.ChainConnectorDotPapi = ChainConnectorDotPapi;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["packageJson.name","RESPONSE_TIMEOUT","getWsProvider","createClient","WsEvent","log","createClient","getWsProvider","throwAfter","viemChains","fromPairs","toPairs","camelCase","shouldThrow","fallback","http","createPublicClient","createWalletClient","isSolanaError","createDefaultRpcTransport","createSolanaRpcFromTransport","createSolanaRpcFromTransport","createSolanaRpcFromTransport"],"sources":["../package.json","../src/log.ts","../src/dot/ChainConnectorDot.ts","../src/dot/ChainConnectorDotPapi.ts","../src/dot/ChainConnectorDotStub.ts","../src/eth/getChainFromEvmNetwork.ts","../src/eth/getTransportForEvmNetwork.ts","../src/eth/getEvmNetworkPublicClient.ts","../src/eth/getEvmNetworkWalletClient.ts","../src/eth/ChainConnectorEth.ts","../src/eth/ChainConnectorEthStub.ts","../src/sol/getSolRpc.ts","../src/sol/ChainConnectorSol.ts","../src/sol/ChainConnectorSolStub.ts"],"sourcesContent":["","import anylogger from \"anylogger\"\n\nimport packageJson from \"../package.json\"\n\nexport default anylogger(packageJson.name)\n","import { createClient, type SubstrateClient } from \"@polkadot-api/substrate-client\"\nimport {\n getWsProvider,\n type StatusChange,\n WsEvent,\n type WsJsonRpcProvider,\n} from \"@polkadot-api/ws-provider\"\nimport type { DotNetworkId, IChaindataNetworkProvider } from \"@talismn/chaindata-provider\"\n\nimport log from \"../log\"\nimport type { IChainConnectorDot, SubscriptionCallback } from \"./IChainConnectorDot\"\n\n// errors that require an rpc fallback\n// https://docs.blastapi.io/blast-documentation/things-you-need-to-know/error-reference\nconst BAD_RPC_ERRORS: Record<string, string> = {\n \"-32097\": \"Rate limit exceeded\",\n \"-32098\": \"Capacity exceeded\",\n}\n\nconst RESPONSE_TIMEOUT = 30_000 // max wait for an rpc response (including connection time)\nconst KEEP_ALIVE_INTERVAL = 20_000 // periodic system_health to keep idle sockets alive (ws-provider kills quiet sockets after its 40s heartbeat)\n/**\n * How long a connection stays open once its last user releases it. A one-off request is\n * often followed by more traffic to the same chain (balances read the runtime version,\n * then subscribe to storage), which then reuses the socket instead of opening a new one.\n */\nconst IDLE_CLOSE_DELAY = 30_000\n\n/** in-flight requests reject with DestroyedError when a connection is torn down - expected, not worth logging */\nconst isDestroyedError = (error: unknown): boolean =>\n error instanceof Error && error.name === \"DestroyedError\"\nconst STALE_NOTIFY_TIMEOUT = 30_000 // how long a chain can be disconnected before subscribers are notified\n\nexport class ChainConnectionError extends Error {\n type: \"CHAIN_CONNECTION_ERROR\"\n chainId: string\n\n constructor(chainId: string, options?: ErrorOptions) {\n super(`Unable to connect to chain ${chainId}`, options)\n\n this.type = \"CHAIN_CONNECTION_ERROR\"\n this.chainId = chainId\n }\n}\n\n/**\n * Passed to subscription callbacks when the chain has been unreachable for a while. Not\n * terminal: the subscription stays registered and is re-issued when a socket connects.\n */\nexport class StaleRpcError extends Error {\n type: \"STALE_RPC_ERROR\"\n chainId: string\n\n constructor(chainId: string, options?: ErrorOptions) {\n super(`RPCs are stale/unavailable for chain ${chainId}`, options)\n\n this.type = \"STALE_RPC_ERROR\"\n this.chainId = chainId\n }\n}\n\ntype SocketUserId = number\n\ntype Subscription = {\n subscribeMethod: string\n params: unknown[]\n callback: SubscriptionCallback\n /** cancels the pending subscribe request, if any */\n cancelRequest: (() => void) | null\n /** stops routing notifications to the callback */\n stopFollow: (() => void) | null\n serverSubId: string | number | null\n unsubscribed: boolean\n}\n\ntype Connection = {\n chainId: DotNetworkId\n provider: WsJsonRpcProvider\n client: SubstrateClient\n users: Set<SocketUserId>\n subscriptions: Set<Subscription>\n wasConnected: boolean\n keepAliveInterval: ReturnType<typeof setInterval> | null\n staleTimeout: ReturnType<typeof setTimeout> | null\n /** closes the connection once it has had no users for IDLE_CLOSE_DELAY */\n idleTimeout: ReturnType<typeof setTimeout> | null\n}\n\nexport type ChainConnectorDotOptions = {\n /**\n * How long a new socket may take to open before the provider gives up on the endpoint\n * and tries the next one. Defaults to polkadot-api's 5 seconds. A slow device or\n * network can take longer than that to connect while it is busy, as a phone app is\n * at startup, and every endpoint then times out in turn.\n */\n connectionTimeout?: number\n}\n\n/**\n * ChainConnector provides an interface similar to a websocket JSON-RPC provider, but with three points of difference:\n *\n * 1. ChainConnector methods all accept a `chainId` instead of an array of RPCs. RPCs are then fetched internally from chaindata.\n * 2. ChainConnector creates only one socket connection per chain (via polkadot-api's ws-provider, which handles\n * endpoint rotation, reconnection and stale-socket detection) and ensures that all downstream requests to a chain\n * share that connection.\n * 3. Subscriptions return a callable `unsubscribe` method instead of an id, and are automatically re-established\n * when the provider reconnects (possibly to another endpoint).\n *\n * Additionally, when run on the clientside of a dapp where `window.talismanSub` is available, instead of spinning up new websocket\n * connections this class will forward all requests through to the wallet backend - where another instance of this class will\n * handle the websocket connections.\n */\nexport class ChainConnectorDot implements IChainConnectorDot {\n #chaindataChainProvider: IChaindataNetworkProvider\n #connectionTimeout: number | undefined\n\n #connections: Record<DotNetworkId, Connection> = {}\n #pendingConnections: Record<DotNetworkId, Promise<Connection>> = {}\n\n constructor(\n chaindataChainProvider: IChaindataNetworkProvider,\n options?: ChainConnectorDotOptions\n ) {\n this.#chaindataChainProvider = chaindataChainProvider\n this.#connectionTimeout = options?.connectionTimeout\n }\n\n // biome-ignore lint/suspicious/noExplicitAny: legacy\n async send<T = any>(\n chainId: DotNetworkId,\n method: string,\n params: unknown[],\n _isCacheable?: boolean | undefined,\n extraOptions?: {\n /**\n * Set to `true` if this query is speculative, i.e. if on some chains it's expected that it will raise a wasm unreachable error of the form:\n *\n * 4003: Client error: Execution failed: Execution aborted due to trap: wasm trap: wasm `unreachable` instruction executed\n *\n * By setting expectErrors to true, this method won't pollute the logs with errors we intend to have happen.\n * An example use case of this is when you plan to catch the wasm unreachable error on chains that don't support the query, and then fall back\n * to another query or perhaps an empty result.\n */\n expectErrors?: boolean\n }\n ): Promise<T> {\n const talismanSub = this.getTalismanSub()\n if (talismanSub !== undefined) {\n try {\n const genesisHash = await this.getGenesisHash(chainId)\n return await talismanSub.send(genesisHash, method, params)\n } catch (error) {\n log.warn(\n `Failed to make wallet-proxied send request for chain ${chainId}. Falling back to plain websocket`,\n error\n )\n }\n }\n\n let socketUserId: SocketUserId\n let connection: Connection\n try {\n ;[socketUserId, connection] = await this.acquireConnection(chainId)\n } catch (error) {\n throw new StaleRpcError(chainId, { cause: error })\n }\n\n try {\n return await this.request<T>(connection, method, params)\n } catch (err) {\n const error = err as (Error & { code?: number; data?: unknown }) | null\n\n if (error?.message === \"TIMEOUT\") {\n log.error(`ChainConnector timeout`, { chainId, error })\n connection.provider.switch()\n throw new Error(\"Timeout\")\n }\n\n const badRpcError = BAD_RPC_ERRORS[error?.code?.toString() ?? \"\"]\n if (badRpcError) {\n log.error(`ChainConnector ${badRpcError}`, { error, chainId })\n connection.provider.switch()\n throw new Error(badRpcError)\n }\n\n if (!extraOptions?.expectErrors)\n log.error(\n `Failed to send ${method} on chain ${chainId}\\nparams: ${JSON.stringify(params)}`,\n {\n error,\n }\n )\n\n throw error\n } finally {\n this.releaseConnection(chainId, socketUserId)\n }\n }\n\n async subscribe(\n chainId: DotNetworkId,\n subscribeMethod: string,\n responseMethod: string,\n params: unknown[],\n callback: SubscriptionCallback,\n timeout: number | false = 30_000 // 30 seconds in milliseconds\n ): Promise<(unsubscribeMethod: string) => void> {\n const talismanSub = this.getTalismanSub()\n if (talismanSub !== undefined) {\n try {\n const genesisHash = await this.getGenesisHash(chainId)\n\n const subscriptionId = await talismanSub.subscribe(\n genesisHash,\n subscribeMethod,\n responseMethod,\n params,\n callback,\n timeout\n )\n\n return (unsubscribeMethod: string) =>\n talismanSub.unsubscribe(subscriptionId, unsubscribeMethod)\n } catch (error) {\n log.warn(\n `Failed to create wallet-proxied subscription for chain ${chainId}. Falling back to plain websocket`,\n error\n )\n }\n }\n\n let socketUserId: SocketUserId\n let connection: Connection\n try {\n ;[socketUserId, connection] = await this.acquireConnection(chainId)\n } catch (error) {\n throw new StaleRpcError(chainId, { cause: error })\n }\n\n const subscription: Subscription = {\n subscribeMethod,\n params,\n callback,\n cancelRequest: null,\n stopFollow: null,\n serverSubId: null,\n unsubscribed: false,\n }\n connection.subscriptions.add(subscription)\n\n // if the chain can't be reached at all, let the caller know after a while (the provider keeps retrying)\n if (timeout && !connection.wasConnected) {\n const staleWarning = setTimeout(() => {\n if (!subscription.unsubscribed && !connection.wasConnected)\n callback(new StaleRpcError(chainId), null)\n }, timeout)\n const clear = () => clearTimeout(staleWarning)\n // piggyback on the follow setup to clear the warning once anything happens\n const originalCallback = subscription.callback\n subscription.callback = (error, result) => {\n clear()\n subscription.callback = originalCallback\n originalCallback(error, result)\n }\n }\n\n this.startSubscription(connection, subscription)\n\n return (unsubscribeMethod: string) => {\n if (subscription.unsubscribed) return\n subscription.unsubscribed = true\n\n subscription.cancelRequest?.()\n subscription.stopFollow?.()\n\n // the connection may have been replaced by a reset() since we subscribed. It stays\n // open for a while after its last user leaves, so unsubscribe on the server even then\n const current = this.#connections[chainId]\n if (subscription.serverSubId !== null && current)\n try {\n current.client.request(unsubscribeMethod, [subscription.serverSubId]).catch((error) => {\n if (!isDestroyedError(error)) log.warn(`Failed to unsubscribe from ${chainId}`, error)\n })\n } catch (error) {\n if (!isDestroyedError(error)) log.warn(`Failed to unsubscribe from ${chainId}`, error)\n }\n\n current?.subscriptions.delete(subscription)\n this.releaseConnection(chainId, socketUserId)\n }\n }\n\n /**\n * Kills and recreates the connection for a chain, if any.\n * Useful after changing a network's rpcs to make sure the new list is applied for further requests.\n * Active subscriptions are automatically re-established on the new connection.\n */\n async reset(chainId: DotNetworkId) {\n log.info(\"ChainConnector reset\", chainId)\n const connection = this.#connections[chainId]\n if (!connection) return\n\n this.destroyConnection(connection)\n delete this.#connections[chainId]\n\n // recreate a connection for the active subscriptions, if any\n if (connection.subscriptions.size) {\n try {\n const fresh = await this.createConnection(chainId)\n fresh.users = connection.users\n fresh.subscriptions = connection.subscriptions\n this.#connections[chainId] = fresh\n for (const subscription of fresh.subscriptions) this.startSubscription(fresh, subscription)\n } catch (error) {\n log.warn(`Failed to recreate connection for ${chainId} after reset`, error)\n // not a StaleRpcError: no connection is left to re-issue these subscriptions,\n // so subscribers must treat this one as terminal\n for (const subscription of connection.subscriptions)\n subscription.callback(new ChainConnectionError(chainId, { cause: error }), null)\n }\n }\n }\n\n /** Sends a request over a connection, throwing `Error(\"TIMEOUT\")` if no response arrives in time */\n private request<T>(\n connection: Connection,\n method: string,\n params: unknown[],\n timeoutMs = RESPONSE_TIMEOUT\n ): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n const timer = setTimeout(() => {\n cancel()\n reject(new Error(\"TIMEOUT\"))\n }, timeoutMs)\n\n const cancel = connection.client._request<T, unknown>(method, params, {\n onSuccess: (result) => {\n clearTimeout(timer)\n resolve(result)\n },\n onError: (error) => {\n clearTimeout(timer)\n reject(error)\n },\n })\n })\n }\n\n /** Issues the subscribe request and routes notifications to the subscription callback */\n private startSubscription(connection: Connection, subscription: Subscription) {\n subscription.serverSubId = null\n subscription.stopFollow = null\n\n subscription.cancelRequest = connection.client._request<string | number, unknown>(\n subscription.subscribeMethod,\n subscription.params,\n {\n onSuccess: (serverSubId, follow) => {\n subscription.cancelRequest = null\n if (subscription.unsubscribed) return\n\n subscription.serverSubId = serverSubId\n // raw-client matches notifications by the raw (not stringified) subscription id, but types it as string\n subscription.stopFollow = follow(serverSubId as string, {\n next: (result) => subscription.callback(null, result),\n error: (error) => subscription.callback(error, null),\n })\n },\n onError: (error) => {\n subscription.cancelRequest = null\n if (!subscription.unsubscribed) subscription.callback(error, null)\n },\n }\n )\n }\n\n /**\n * Get (or create) the shared connection for a chain.\n *\n * The caller must call releaseConnection with the returned SocketUserId once they are finished with it.\n */\n private async acquireConnection(chainId: DotNetworkId): Promise<[SocketUserId, Connection]> {\n // a single creation promise per chain guarantees that concurrent callers share the same connection\n let connection = this.#connections[chainId]\n if (!connection) {\n if (!this.#pendingConnections[chainId]) {\n this.#pendingConnections[chainId] = this.createConnection(chainId)\n .then((created) => {\n this.#connections[chainId] = created\n return created\n })\n .finally(() => {\n delete this.#pendingConnections[chainId]\n })\n }\n connection = await this.#pendingConnections[chainId]\n }\n\n if (connection.idleTimeout) {\n clearTimeout(connection.idleTimeout)\n connection.idleTimeout = null\n }\n const socketUserId = this.getExclusiveRandomId([...connection.users])\n connection.users.add(socketUserId)\n\n return [socketUserId, connection]\n }\n\n private async createConnection(chainId: DotNetworkId): Promise<Connection> {\n const chain = await this.#chaindataChainProvider.getNetworkById(chainId, \"polkadot\")\n if (!chain) throw new Error(`Chain ${chainId} not found in store`)\n\n const rpcs = chain.rpcs.concat()\n if (!rpcs.length) throw new Error(`No healthy RPCs available for chain ${chainId}`)\n\n // will be assigned below - the provider config needs to reference the connection\n let connection: Connection = null as unknown as Connection\n\n const provider = getWsProvider(rpcs, {\n onStatusChanged: (status: StatusChange) => this.handleStatusChange(connection, status),\n ...(this.#connectionTimeout !== undefined && { timeout: this.#connectionTimeout }),\n })\n\n const client = createClient(provider)\n\n connection = {\n chainId,\n provider,\n client,\n users: new Set(),\n subscriptions: new Set(),\n wasConnected: false,\n keepAliveInterval: null,\n staleTimeout: null,\n idleTimeout: null,\n }\n\n return connection\n }\n\n private handleStatusChange(connection: Connection, status: StatusChange) {\n // connection is still being constructed on the initial CONNECTING event\n if (!connection) return\n // ignore events from a connection that has been reset/destroyed\n if (this.#connections[connection.chainId] !== connection) return\n\n if (status.type === WsEvent.CONNECTED) {\n if (connection.staleTimeout) {\n clearTimeout(connection.staleTimeout)\n connection.staleTimeout = null\n }\n\n const isReconnect = connection.wasConnected\n connection.wasConnected = true\n\n // periodically send a request to keep the socket alive when there is no other traffic\n if (connection.keepAliveInterval) clearInterval(connection.keepAliveInterval)\n connection.keepAliveInterval = setInterval(() => {\n this.request(connection, \"system_health\", [], KEEP_ALIVE_INTERVAL).catch((error) => {\n if (!isDestroyedError(error))\n log.warn(`Failed keep-alive for socket ${connection.chainId}`, error)\n })\n }, KEEP_ALIVE_INTERVAL)\n\n // server-side subscriptions died with the previous socket : re-establish them\n // (skip author_* subscriptions : resubmitting an extrinsic is not safe)\n if (isReconnect)\n for (const subscription of connection.subscriptions) {\n if (subscription.unsubscribed) continue\n if (subscription.subscribeMethod.startsWith(\"author_\")) continue\n subscription.stopFollow?.()\n subscription.cancelRequest?.()\n this.startSubscription(connection, subscription)\n }\n } else {\n if (connection.keepAliveInterval) {\n clearInterval(connection.keepAliveInterval)\n connection.keepAliveInterval = null\n }\n\n // notify subscribers if the chain stays unreachable for too long\n if (!connection.staleTimeout && connection.subscriptions.size) {\n connection.staleTimeout = setTimeout(() => {\n connection.staleTimeout = null\n for (const subscription of connection.subscriptions)\n if (!subscription.unsubscribed)\n subscription.callback(new StaleRpcError(connection.chainId), null)\n }, STALE_NOTIFY_TIMEOUT)\n }\n }\n }\n\n private releaseConnection(chainId: DotNetworkId, socketUserId: SocketUserId): void {\n const connection = this.#connections[chainId]\n if (!connection) return\n\n connection.users.delete(socketUserId)\n if (connection.users.size > 0 || connection.idleTimeout) return\n\n connection.idleTimeout = setTimeout(() => {\n connection.idleTimeout = null\n if (connection.users.size > 0 || this.#connections[chainId] !== connection) return\n this.destroyConnection(connection)\n delete this.#connections[chainId]\n }, IDLE_CLOSE_DELAY)\n }\n\n private destroyConnection(connection: Connection): void {\n if (connection.keepAliveInterval) clearInterval(connection.keepAliveInterval)\n if (connection.staleTimeout) clearTimeout(connection.staleTimeout)\n if (connection.idleTimeout) clearTimeout(connection.idleTimeout)\n connection.keepAliveInterval = null\n connection.staleTimeout = null\n connection.idleTimeout = null\n\n // detach subscriptions before destroying the client so their callbacks don't receive a DestroyedError\n for (const subscription of connection.subscriptions) {\n subscription.stopFollow?.()\n subscription.cancelRequest?.()\n subscription.stopFollow = null\n subscription.cancelRequest = null\n subscription.serverSubId = null\n }\n\n try {\n connection.client.destroy()\n } catch (error) {\n log.warn(`Error occurred destroying connection ${connection.chainId}`, error)\n }\n }\n\n private async getGenesisHash(chainId: DotNetworkId): Promise<string> {\n const chain = await this.#chaindataChainProvider.getNetworkById(chainId, \"polkadot\")\n if (!chain) throw new Error(`Chain ${chainId} not found in store`)\n\n const { genesisHash } = chain\n if (typeof genesisHash !== \"string\")\n throw new Error(`Chain ${chainId} has no genesisHash in store`)\n\n return genesisHash\n }\n\n /** continues to generate a random number until it finds one which is not present in the exclude list */\n private getExclusiveRandomId(exclude: number[] = []): number {\n let id = this.getRandomId()\n while (exclude.includes(id)) {\n id = this.getRandomId()\n }\n return id\n }\n /** generates a random number */\n private getRandomId(): number {\n return Math.trunc(Math.random() * 10 ** 8)\n }\n\n private getTalismanSub() {\n // biome-ignore lint/suspicious/noExplicitAny: legacy\n const talismanSub = typeof window !== \"undefined\" && (window as any).talismanSub\n\n // biome-ignore lint/complexity/noBannedTypes: legacy\n const rpcByGenesisHashSend: Function | undefined = talismanSub?.rpcByGenesisHashSend\n // biome-ignore lint/complexity/noBannedTypes: legacy\n const rpcByGenesisHashSubscribe: Function | undefined = talismanSub?.rpcByGenesisHashSubscribe\n // biome-ignore lint/complexity/noBannedTypes: legacy\n const rpcByGenesisHashUnsubscribe: Function | undefined =\n talismanSub?.rpcByGenesisHashUnsubscribe\n\n if (typeof rpcByGenesisHashSend !== \"function\") return\n if (typeof rpcByGenesisHashSubscribe !== \"function\") return\n if (typeof rpcByGenesisHashUnsubscribe !== \"function\") return\n\n return {\n // biome-ignore lint/suspicious/noExplicitAny: legacy\n send: <T = any>(genesisHash: string, method: string, params: unknown[]): Promise<T> =>\n rpcByGenesisHashSend(genesisHash, method, params),\n\n subscribe: (\n genesisHash: string,\n subscribeMethod: string,\n responseMethod: string,\n params: unknown[],\n callback: SubscriptionCallback,\n timeout: number | false\n ): Promise<string> =>\n rpcByGenesisHashSubscribe(\n genesisHash,\n subscribeMethod,\n responseMethod,\n params,\n callback,\n timeout\n ),\n\n unsubscribe: (subscriptionId: string, unsubscribeMethod: string): Promise<void> =>\n rpcByGenesisHashUnsubscribe(subscriptionId, unsubscribeMethod),\n }\n }\n}\n","import type { DotNetworkId } from \"@talismn/chaindata-provider\"\n\nimport log from \"../log\"\nimport { StaleRpcError } from \"./ChainConnectorDot\"\nimport type { IChainConnectorDot, SubscriptionCallback } from \"./IChainConnectorDot\"\n\nconst RESPONSE_TIMEOUT = 30_000\nconst FAILURES_BEFORE_FIRST_RESULT = 3\n\ntype HexString = `0x${string}`\ntype StorageChanges = { block: HexString; changes: [HexString, HexString | null][] }\n\n/** The parts of a polkadot-api `PolkadotClient` that the connector uses */\nexport type PapiClient = {\n /** `PolkadotClient` types it without `abortSignal`, but it is substrate-client's `request`, which honours it */\n _request: <Reply>(method: string, params: unknown[], abortSignal?: AbortSignal) => Promise<Reply>\n bestBlocks$: {\n subscribe: (observer: {\n next: (blocks: { hash: string }[]) => void\n error: (error: unknown) => void\n complete: () => void\n }) => { unsubscribe: () => void }\n }\n}\n\n/**\n * Runs `@talismn/balances` over a dapp's polkadot-api clients, so the dapp and its balances share one socket per chain.\n *\n * `state_subscribeStorage` is the only subscription balances uses. It is served by querying the keys at each new\n * best block and reporting the values that changed, like the node does. One query runs at a time, for the latest\n * best block. A failed query is retried at the next block, because balances treats a subscription error as final\n * and would stop updating that network. Only when the first three queries fail does the subscription report the error.\n */\nexport class ChainConnectorDotPapi implements IChainConnectorDot {\n #clientFor: (networkId: DotNetworkId) => PapiClient | undefined\n\n constructor(clientFor: (networkId: DotNetworkId) => PapiClient | undefined) {\n this.#clientFor = clientFor\n }\n\n async send<T = unknown>(networkId: DotNetworkId, method: string, params: unknown[]): Promise<T> {\n return requestWithTimeout<T>(this.getClient(networkId), method, params, new AbortController())\n }\n\n async subscribe(\n networkId: DotNetworkId,\n subscribeMethod: string,\n _responseMethod: string,\n params: unknown[],\n callback: SubscriptionCallback,\n timeout: number | false = 30_000\n ): Promise<(unsubscribeMethod: string) => void> {\n const client = this.getClient(networkId)\n if (subscribeMethod !== \"state_subscribeStorage\")\n throw new Error(`ChainConnectorDotPapi does not support ${subscribeMethod}`)\n\n const [keys] = params as [HexString[]]\n const values = new Map<HexString, HexString | null>()\n let bestBlockHash: string | undefined\n let queriedBlockHash: string | undefined\n let inFlight: AbortController | undefined\n let delivered = false\n let failures = 0\n let active = true\n let subscription: { unsubscribe: () => void } | undefined\n const staleTimer = timeout\n ? setTimeout(() => callback(new StaleRpcError(networkId), null), timeout)\n : undefined\n\n const stop = () => {\n active = false\n clearTimeout(staleTimer)\n inFlight?.abort()\n subscription?.unsubscribe()\n }\n\n const finish = (error: Error) => {\n if (!active) return\n stop()\n callback(error, null)\n }\n\n const reportChanges = (result: StorageChanges) => {\n const changes = result.changes.filter(([key, value]) => values.get(key) !== value)\n for (const [key, value] of changes) values.set(key, value)\n if (!changes.length) return\n\n delivered = true\n clearTimeout(staleTimer)\n callback(null, { block: result.block, changes })\n }\n\n const reportFailure = (error: Error) => {\n if (delivered || ++failures < FAILURES_BEFORE_FIRST_RESULT)\n return log.warn(\n `state_queryStorageAt failed on ${networkId}, retrying at the next block`,\n error\n )\n finish(error)\n }\n\n const queryBestBlock = async () => {\n if (!active || inFlight || !bestBlockHash || bestBlockHash === queriedBlockHash) return\n const blockHash = bestBlockHash\n queriedBlockHash = blockHash\n const controller = new AbortController()\n inFlight = controller\n\n try {\n const [result] = await requestWithTimeout<StorageChanges[]>(\n client,\n \"state_queryStorageAt\",\n [keys, blockHash],\n controller\n )\n if (!active) return\n if (!result) throw new Error(`Empty state_queryStorageAt response on ${networkId}`)\n reportChanges(result)\n } catch (error) {\n if (active) reportFailure(error as Error)\n } finally {\n if (inFlight === controller) inFlight = undefined\n queryBestBlock()\n }\n }\n\n try {\n subscription = client.bestBlocks$.subscribe({\n next: ([best]) => {\n bestBlockHash = best?.hash\n queryBestBlock()\n },\n error: (error) => finish(error as Error),\n complete: () =>\n finish(new Error(`polkadot-api client for ${networkId} stopped following blocks`)),\n })\n } catch (error) {\n stop()\n throw error\n }\n if (!active) subscription.unsubscribe()\n\n return stop\n }\n\n async reset() {}\n\n private getClient(networkId: DotNetworkId): PapiClient {\n const client = this.#clientFor(networkId)\n if (!client) throw new Error(`No polkadot-api client for network ${networkId}`)\n return client\n }\n}\n\n/** rejects on its own timer too, so a client that ignores the abort signal cannot hang the caller */\nconst requestWithTimeout = <T>(\n client: PapiClient,\n method: string,\n params: unknown[],\n controller: AbortController\n) =>\n new Promise<T>((resolve, reject) => {\n const timer = setTimeout(() => {\n controller.abort()\n reject(new Error(\"Timeout\"))\n }, RESPONSE_TIMEOUT)\n try {\n client\n ._request<T>(method, params, controller.signal)\n .then(resolve, reject)\n .finally(() => clearTimeout(timer))\n } catch (error) {\n clearTimeout(timer)\n reject(error)\n }\n })\n","import { createClient, type SubstrateClient } from \"@polkadot-api/substrate-client\"\nimport { getWsProvider } from \"@polkadot-api/ws-provider\"\nimport type { DotNetwork, DotNetworkId } from \"@talismn/chaindata-provider\"\nimport { throwAfter } from \"@talismn/util\"\n\nimport type { IChainConnectorDot, SubscriptionCallback } from \"./IChainConnectorDot\"\n\nconst TIMEOUT = 10_000\n\nexport class ChainConnectorDotStub implements IChainConnectorDot {\n #client: SubstrateClient\n\n constructor(network: DotNetwork) {\n this.#client = createClient(getWsProvider(network.rpcs.concat()))\n }\n\n async send<T = unknown>(\n _chainId: DotNetworkId,\n method: string,\n params: unknown[],\n _isCacheable?: boolean\n ): Promise<T> {\n return await Promise.race([\n this.#client.request<T>(method, params),\n throwAfter(TIMEOUT, `Request ${method} timed out after ${TIMEOUT}ms`),\n ])\n }\n\n async subscribe(\n _chainId: DotNetworkId,\n subscribeMethod: string,\n _responseMethod: string,\n params: unknown[],\n callback: SubscriptionCallback,\n timeout?: number | false\n ): Promise<(unsubscribeMethod: string) => void> {\n let stopFollow: (() => void) | null = null\n let unsubscribed = false\n\n const serverSubId = await Promise.race([\n new Promise<string | number>((resolve, reject) => {\n this.#client._request<string | number, unknown>(subscribeMethod, params, {\n onSuccess: (subId, follow) => {\n stopFollow = follow(subId as string, {\n next: (result) => callback(null, result),\n error: (error) => callback(error, null),\n })\n resolve(subId)\n },\n onError: reject,\n })\n }),\n throwAfter(timeout || TIMEOUT, `Subscription timed out after ${timeout || TIMEOUT}ms`),\n ])\n\n return (unsubscribeMethod: string) => {\n if (unsubscribed) return\n unsubscribed = true\n stopFollow?.()\n this.#client.request(unsubscribeMethod, [serverSubId]).catch(() => {}) // connection may already be gone\n }\n }\n\n reset(): Promise<void> {\n throw new Error(\"ChainConnectorDotStub does not implement reset\")\n }\n\n destroy() {\n this.#client.destroy()\n }\n}\n","import type { EthNetwork, EthNetworkId } from \"@talismn/chaindata-provider\"\nimport { camelCase, fromPairs, toPairs } from \"lodash-es\"\nimport type { Chain, ChainContract } from \"viem\"\nimport * as viemChains from \"viem/chains\"\n\n// exclude zoraTestnet which uses Hyperliquid's chain id\nconst { zoraTestnet, ...validViemChains } = viemChains\n\n// viem chains benefit from multicall config & other viem goodies\nconst VIEM_CHAINS = Object.keys(validViemChains).reduce(\n (acc, curr) => {\n const chain = validViemChains[curr as keyof typeof validViemChains]\n acc[chain.id] = chain\n return acc\n },\n {} as Record<number, Chain>\n)\n\nconst chainsCache = new Map<string, Chain>()\n\nexport const clearChainsCache = (networkId?: EthNetworkId) => {\n if (networkId) chainsCache.delete(networkId)\n else chainsCache.clear()\n}\n\nexport const getChainFromEvmNetwork = (network: EthNetwork): Chain => {\n const { symbol, decimals } = network.nativeCurrency\n\n if (!chainsCache.has(network.id)) {\n const chainRpcs = network.rpcs ?? []\n\n const viemChain = VIEM_CHAINS[Number(network.id)] ?? {}\n\n const chain: Chain = {\n ...viemChain,\n id: Number(network.id),\n name: network.name ?? `Ethereum Chain ${network.id}`,\n rpcUrls: {\n public: { http: chainRpcs },\n default: { http: chainRpcs },\n },\n nativeCurrency: {\n symbol,\n decimals,\n name: symbol,\n },\n contracts: {\n ...viemChain.contracts,\n ...(network.contracts\n ? fromPairs(\n toPairs(network.contracts).map(([name, address]): [string, ChainContract] => [\n camelCase(name),\n { address },\n ])\n )\n : {}),\n },\n }\n\n chainsCache.set(network.id, chain)\n }\n\n return chainsCache.get(network.id) as Chain\n}\n","import type { EthNetwork } from \"@talismn/chaindata-provider\"\nimport { fallback, http, shouldThrow } from \"viem\"\n\nexport type TransportOptions = {\n batch?:\n | boolean\n | {\n batchSize?: number | undefined\n wait?: number | undefined\n }\n}\n\n// Frontier nodes report reverts with a message viem does not recognize, which makes fallback retry every rpc\nconst FRONTIER_EXECUTION_ERROR = /VM Exception while processing transaction/\n\nconst isFinalError = (error: Error) =>\n shouldThrow(error) || FRONTIER_EXECUTION_ERROR.test(error.message)\n\nexport const getTransportForEvmNetwork = (\n evmNetwork: EthNetwork,\n options: TransportOptions = {}\n) => {\n if (!evmNetwork.rpcs?.length) throw new Error(\"No RPCs found for EVM network\")\n\n const { batch } = options\n\n return fallback(\n evmNetwork.rpcs.map((url) => http(url, { batch, retryCount: 0 })),\n { retryCount: 0, shouldThrow: isFinalError }\n )\n}\n","import type { EthNetwork } from \"@talismn/chaindata-provider\"\nimport { createPublicClient, type PublicClient } from \"viem\"\n\nimport { clearChainsCache, getChainFromEvmNetwork } from \"./getChainFromEvmNetwork\"\nimport { getTransportForEvmNetwork, type TransportOptions } from \"./getTransportForEvmNetwork\"\n\nconst MUTLICALL_BATCH_WAIT = 25\nconst MUTLICALL_BATCH_SIZE = 100\n\nconst HTTP_BATCH_WAIT = 25\nconst HTTP_BATCH_SIZE_WITH_MULTICALL = 10\nconst HTTP_BATCH_SIZE_WITHOUT_MULTICALL = 30\n\n// cache to reuse previously created public clients\nconst publicClientCache = new Map<string, PublicClient>()\n\nexport const clearPublicClientCache = (evmNetworkId?: string) => {\n clearChainsCache(evmNetworkId)\n\n if (evmNetworkId) publicClientCache.delete(evmNetworkId)\n else publicClientCache.clear()\n}\n\nexport const getEvmNetworkPublicClient = (network: EthNetwork): PublicClient => {\n const chain = getChainFromEvmNetwork(network)\n\n if (!publicClientCache.has(network.id)) {\n if (!network.rpcs.length) throw new Error(\"No RPCs found for Ethereum network\")\n\n const batch = chain.contracts?.multicall3\n ? { multicall: { wait: MUTLICALL_BATCH_WAIT, batchSize: MUTLICALL_BATCH_SIZE } }\n : undefined\n\n const transportOptions: TransportOptions = {\n batch: {\n batchSize: chain.contracts?.multicall3\n ? HTTP_BATCH_SIZE_WITH_MULTICALL\n : HTTP_BATCH_SIZE_WITHOUT_MULTICALL,\n wait: HTTP_BATCH_WAIT,\n },\n }\n\n const transport = getTransportForEvmNetwork(network, transportOptions)\n\n publicClientCache.set(\n network.id,\n createPublicClient({\n chain,\n transport,\n batch,\n })\n )\n }\n\n return publicClientCache.get(network.id) as PublicClient\n}\n","import type { EthNetwork } from \"@talismn/chaindata-provider\"\nimport { type Account, createWalletClient, type WalletClient } from \"viem\"\n\nimport { getChainFromEvmNetwork } from \"./getChainFromEvmNetwork\"\nimport { getTransportForEvmNetwork } from \"./getTransportForEvmNetwork\"\n\ntype WalletClientOptions = {\n account?: `0x${string}` | Account\n}\n\nexport const getEvmNetworkWalletClient = (\n network: EthNetwork,\n options: WalletClientOptions = {}\n): WalletClient => {\n const chain = getChainFromEvmNetwork(network)\n\n const transport = getTransportForEvmNetwork(network)\n\n return createWalletClient({ chain, transport, account: options.account })\n}\n","import type {\n EthNetworkId,\n IChaindataNetworkProvider,\n IChaindataTokenProvider,\n} from \"@talismn/chaindata-provider\"\nimport type { Account, PublicClient, WalletClient } from \"viem\"\n\nimport { clearPublicClientCache, getEvmNetworkPublicClient } from \"./getEvmNetworkPublicClient\"\nimport { getEvmNetworkWalletClient } from \"./getEvmNetworkWalletClient\"\nimport type { IChainConnectorEth } from \"./IChainConnectorEth\"\n\nexport class ChainConnectorEth implements IChainConnectorEth {\n #chaindataProvider: IChaindataNetworkProvider & IChaindataTokenProvider\n\n constructor(chaindataProvider: IChaindataNetworkProvider & IChaindataTokenProvider) {\n this.#chaindataProvider = chaindataProvider\n }\n\n async getPublicClientForEvmNetwork(evmNetworkId: EthNetworkId): Promise<PublicClient | null> {\n const network = await this.#chaindataProvider.getNetworkById(evmNetworkId, \"ethereum\")\n if (!network) return null\n\n return getEvmNetworkPublicClient(network)\n }\n\n async getWalletClientForEvmNetwork(\n evmNetworkId: EthNetworkId,\n account?: `0x${string}` | Account\n ): Promise<WalletClient | null> {\n const network = await this.#chaindataProvider.getNetworkById(evmNetworkId, \"ethereum\")\n if (!network) return null\n\n return getEvmNetworkWalletClient(network, { account })\n }\n\n public clearRpcProvidersCache(evmNetworkId?: EthNetworkId) {\n clearPublicClientCache(evmNetworkId)\n }\n}\n","import type { EthNetwork, EthNetworkId } from \"@talismn/chaindata-provider\"\nimport type { Account, PublicClient, WalletClient } from \"viem\"\n\nimport { getEvmNetworkPublicClient } from \"./getEvmNetworkPublicClient\"\nimport { getEvmNetworkWalletClient } from \"./getEvmNetworkWalletClient\"\nimport type { IChainConnectorEth } from \"./IChainConnectorEth\"\n\nexport class ChainConnectorEthStub implements IChainConnectorEth {\n #network: EthNetwork\n\n constructor(network: EthNetwork) {\n this.#network = network\n }\n\n async getPublicClientForEvmNetwork(): Promise<PublicClient | null> {\n return getEvmNetworkPublicClient(this.#network)\n }\n\n async getWalletClientForEvmNetwork(\n _networkId: EthNetworkId,\n account?: `0x${string}` | Account\n ): Promise<WalletClient | null> {\n return getEvmNetworkWalletClient(this.#network, { account })\n }\n\n clearRpcProvidersCache(): void {\n // No-op for stub\n }\n}\n","import type { Rpc, RpcTransport, SolanaRpcApi } from \"@solana/kit\"\nimport { createDefaultRpcTransport, createSolanaRpcFromTransport, isSolanaError } from \"@solana/kit\"\nimport type { SolNetworkId } from \"@talismn/chaindata-provider\"\n\nexport type SolRpc = Rpc<SolanaRpcApi>\n\n// Public Solana RPC nodes rate-limit aggressively with HTTP 429. kit's default transport is\n// single-shot, unlike the old web3.js `Connection` which retried 429 up to 5x with backoff, so a\n// single 429 would fail an otherwise-valid request (e.g. a user's transaction submission, or token\n// discovery silently returning no tokens). This wrapper restores that behaviour.\nconst MAX_429_RETRIES = 5\nconst BASE_BACKOFF_MS = 500\n\ntype HttpErrorContext = { statusCode?: number; headers?: Headers }\n\nconst getRateLimitContext = (error: unknown): HttpErrorContext | null => {\n if (!isSolanaError(error)) return null\n\n const context = error.context as HttpErrorContext\n return context.statusCode === 429 ? context : null\n}\n\n/** Returns the delay to wait before retrying, or `null` if the error is not a retryable 429. */\nconst get429RetryDelay = (error: unknown, attempt: number): number | null => {\n const context = getRateLimitContext(error)\n if (!context) return null\n\n // honour the server's Retry-After header (delta-seconds) when present\n const retryAfter = Number(context.headers?.get(\"retry-after\"))\n if (Number.isFinite(retryAfter) && retryAfter > 0) return retryAfter * 1000\n\n // otherwise exponential backoff: 500ms, 1s, 2s, 4s, 8s\n return BASE_BACKOFF_MS * 2 ** attempt\n}\n\nconst sleep = (ms: number, signal?: AbortSignal): Promise<void> =>\n new Promise((resolve, reject) => {\n if (signal?.aborted) return reject(signal.reason)\n\n const onAbort = () => {\n clearTimeout(timeout)\n reject(signal?.reason)\n }\n const timeout = setTimeout(() => {\n signal?.removeEventListener(\"abort\", onAbort)\n resolve()\n }, ms)\n signal?.addEventListener(\"abort\", onAbort, { once: true })\n })\n\n/**\n * Wraps a transport so HTTP 429 responses are retried with backoff. Solana RPC requests are\n * idempotent (`sendTransaction` is keyed by signature), so replaying a rate-limited request is safe.\n */\nconst withRetryOn429 = (transport: RpcTransport): RpcTransport => {\n const wrapped = async (config: Parameters<RpcTransport>[0]) => {\n for (let attempt = 0; ; attempt++) {\n try {\n return await transport(config)\n } catch (error) {\n const delay = attempt < MAX_429_RETRIES ? get429RetryDelay(error, attempt) : null\n if (delay === null) throw error\n await sleep(delay, config.signal)\n }\n }\n }\n return wrapped as RpcTransport\n}\n\n/**\n * How long a request may wait on an RPC before moving on to the next one. The last RPC tried gets\n * no timeout, so a slow but working node still answers when every other one has failed.\n */\nconst FAILOVER_TIMEOUT_MS = 20_000\n\nconst sendWithTimeout = async <TResponse>(\n transport: RpcTransport,\n config: RpcTransportConfig,\n timeoutMs: number\n): Promise<TResponse> => {\n const controller = new AbortController()\n const onAbort = () => controller.abort(config.signal?.reason)\n config.signal?.addEventListener(\"abort\", onAbort, { once: true })\n const timeout = setTimeout(\n () => controller.abort(new Error(`RPC request timed out after ${timeoutMs}ms`)),\n timeoutMs\n )\n\n try {\n return await transport<TResponse>({ ...config, signal: controller.signal })\n } finally {\n clearTimeout(timeout)\n config.signal?.removeEventListener(\"abort\", onAbort)\n }\n}\n\ntype RpcTransportConfig = Parameters<RpcTransport>[0]\n\nconst isSendTransactionPayload = (\n payload: unknown\n): payload is { method: \"sendTransaction\"; params: unknown[] } =>\n typeof payload === \"object\" &&\n payload !== null &&\n \"method\" in payload &&\n payload.method === \"sendTransaction\" &&\n \"params\" in payload &&\n Array.isArray(payload.params)\n\nconst withoutPreflight = (config: RpcTransportConfig): RpcTransportConfig => {\n if (!isSendTransactionPayload(config.payload)) return config\n\n const [transaction, sendConfig] = config.payload.params\n return {\n ...config,\n payload: {\n ...config.payload,\n params: [transaction, { ...(sendConfig as object | undefined), skipPreflight: true }],\n },\n }\n}\n\nexport type SolTransportOptions = {\n /** Called with the url of the RPC that answered, after every successful request */\n onRpcSuccess?: (url: string) => void\n}\n\n/**\n * Sends each request to one RPC at a time, starting from the one that answered last, and moves on to\n * the next when the request fails. A transport only throws for connection, timeout and HTTP errors:\n * JSON-RPC errors come back in the response body and are returned as is.\n *\n * A failed RPC other than a rate limited one may still have forwarded a transaction. Resending it is\n * safe, as the network processes a signature once, but its preflight simulation on the next RPC\n * could then fail although it landed. So after such a failure, every resend of that transaction,\n * including the retries after a rate limit, skips preflight.\n */\nconst withFailover = (urls: string[], options: SolTransportOptions): RpcTransport => {\n const transports = urls.map((url) => createDefaultRpcTransport({ url }))\n let preferred = 0\n const mayHaveBeenProcessed = new WeakSet<RpcTransportConfig>()\n\n const failover = async <TResponse>(config: RpcTransportConfig): Promise<TResponse> => {\n if (!transports.length) throw new Error(\"No RPCs found for Solana network\")\n\n const start = preferred\n let lastError: unknown\n let rateLimitError: unknown\n for (let attempt = 0; attempt < transports.length; attempt++) {\n config.signal?.throwIfAborted()\n const index = (start + attempt) % transports.length\n const transport = transports[index] as RpcTransport\n const isLastAttempt = attempt === transports.length - 1\n const request = mayHaveBeenProcessed.has(config) ? withoutPreflight(config) : config\n\n try {\n const response = isLastAttempt\n ? await transport<TResponse>(request)\n : await sendWithTimeout<TResponse>(transport, request, FAILOVER_TIMEOUT_MS)\n preferred = index\n options.onRpcSuccess?.(urls[index] as string)\n return response\n } catch (error) {\n if (config.signal?.aborted) throw error\n lastError = error\n if (!getRateLimitContext(error)) mayHaveBeenProcessed.add(config)\n else rateLimitError ??= error\n }\n }\n throw rateLimitError ?? lastError\n }\n return failover as RpcTransport\n}\n\n/**\n * Returns a transport over all of the network's RPCs, in the given order. A request fails over to\n * the next RPC on error, and the RPC that answered is tried first for the next request. When every\n * RPC fails and one of them answered HTTP 429, the whole list is retried with backoff.\n */\nexport const getSolTransport = (\n _networkId: SolNetworkId,\n rpcs: string[],\n options: SolTransportOptions = {}\n): RpcTransport => {\n return withRetryOn429(withFailover(rpcs, options))\n}\n\nexport const getSolRpc = (\n networkId: SolNetworkId,\n rpcs: string[],\n options?: SolTransportOptions\n): SolRpc => createSolanaRpcFromTransport(getSolTransport(networkId, rpcs, options))\n","import type { RpcTransport } from \"@solana/kit\"\nimport { createSolanaRpcFromTransport } from \"@solana/kit\"\nimport type {\n IChaindataNetworkProvider,\n IChaindataTokenProvider,\n SolNetworkId,\n} from \"@talismn/chaindata-provider\"\n\nimport type { SolRpc } from \"./getSolRpc\"\nimport { getSolTransport } from \"./getSolRpc\"\nimport type { IChainConnectorSol } from \"./IChainConnectorSol\"\n\nexport class ChainConnectorSol implements IChainConnectorSol {\n #chaindataProvider: IChaindataNetworkProvider & IChaindataTokenProvider\n #transports = new Map<SolNetworkId, RpcTransport>()\n #rpcs = new Map<SolNetworkId, SolRpc>()\n\n constructor(chaindataProvider: IChaindataNetworkProvider & IChaindataTokenProvider) {\n this.#chaindataProvider = chaindataProvider\n }\n\n async #getNetworkRpcs(networkId: SolNetworkId): Promise<string[]> {\n const network = await this.#chaindataProvider.getNetworkById(networkId, \"solana\")\n if (!network) throw new Error(`Network not found: ${networkId}`)\n\n return network.rpcs\n }\n\n async getTransport(networkId: SolNetworkId): Promise<RpcTransport> {\n if (!this.#transports.has(networkId))\n this.#transports.set(\n networkId,\n getSolTransport(networkId, await this.#getNetworkRpcs(networkId))\n )\n\n return this.#transports.get(networkId)!\n }\n\n async getRpc(networkId: SolNetworkId): Promise<SolRpc> {\n if (!this.#rpcs.has(networkId))\n this.#rpcs.set(networkId, createSolanaRpcFromTransport(await this.getTransport(networkId)))\n\n return this.#rpcs.get(networkId)!\n }\n\n /** Drops cached transports/rpcs so the next call re-reads the network's rpcs from chaindata */\n clearRpcProvidersCache(networkId?: SolNetworkId) {\n if (networkId) {\n this.#transports.delete(networkId)\n this.#rpcs.delete(networkId)\n } else {\n this.#transports.clear()\n this.#rpcs.clear()\n }\n }\n}\n","import type { RpcTransport } from \"@solana/kit\"\nimport { createSolanaRpcFromTransport } from \"@solana/kit\"\nimport type { SolNetwork } from \"@talismn/chaindata-provider\"\n\nimport type { SolRpc } from \"./getSolRpc\"\nimport { getSolTransport } from \"./getSolRpc\"\nimport type { IChainConnectorSol } from \"./IChainConnectorSol\"\n\nexport class ChainConnectorSolStub implements IChainConnectorSol {\n #transport: RpcTransport\n #rpc: SolRpc\n\n constructor(network: Pick<SolNetwork, \"id\" | \"rpcs\">) {\n this.#transport = getSolTransport(network.id, network.rpcs)\n this.#rpc = createSolanaRpcFromTransport(this.#transport)\n }\n\n async getRpc(): Promise<SolRpc> {\n return this.#rpc\n }\n\n async getTransport(): Promise<RpcTransport> {\n return this.#transport\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACIA,IAAA,eAAA,GAAe,UAAA,QAAA,CAAUA,2BAAgB;;;ACUzC,MAAM,iBAAyC;CAC7C,UAAU;CACV,UAAU;AACZ;AAEA,MAAMC,qBAAmB;AACzB,MAAM,sBAAsB;;;;;;AAM5B,MAAM,mBAAmB;;AAGzB,MAAM,oBAAoB,UACxB,iBAAiB,SAAS,MAAM,SAAS;AAC3C,MAAM,uBAAuB;AAE7B,IAAa,uBAAb,cAA0C,MAAM;CAC9C;CACA;CAEA,YAAY,SAAiB,SAAwB;EACnD,MAAM,8BAA8B,WAAW,OAAO;EAEtD,KAAK,OAAO;EACZ,KAAK,UAAU;CACjB;AACF;;;;;AAMA,IAAa,gBAAb,cAAmC,MAAM;CACvC;CACA;CAEA,YAAY,SAAiB,SAAwB;EACnD,MAAM,wCAAwC,WAAW,OAAO;EAEhE,KAAK,OAAO;EACZ,KAAK,UAAU;CACjB;AACF;;;;;;;;;;;;;;;AAqDA,IAAa,oBAAb,MAA6D;CAC3D;CACA;CAEA,eAAiD,CAAC;CAClD,sBAAiE,CAAC;CAElE,YACE,wBACA,SACA;EACA,KAAK,0BAA0B;EAC/B,KAAK,qBAAqB,SAAS;CACrC;CAGA,MAAM,KACJ,SACA,QACA,QACA,cACA,cAYY;EACZ,MAAM,cAAc,KAAK,eAAe;EACxC,IAAI,gBAAgB,KAAA,GAClB,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,GAAWC,YAAAA,6BAAAA,CAA6B,MAAM,KAAK,aAAa,SAAS,CAAC,CAAC;EAE5F,OAAO,KAAK,MAAM,IAAI,SAAS;CACjC;;CAGA,uBAAuB,WAA0B;EAC/C,IAAI,WAAW;GACb,KAAK,YAAY,OAAO,SAAS;GACjC,KAAK,MAAM,OAAO,SAAS;EAC7B,OAAO;GACL,KAAK,YAAY,MAAM;GACvB,KAAK,MAAM,MAAM;EACnB;CACF;AACF;;;AC/CA,IAAa,wBAAb,MAAiE;CAC/D;CACA;CAEA,YAAY,SAA0C;EACpD,KAAK,aAAa,gBAAgB,QAAQ,IAAI,QAAQ,IAAI;EAC1D,KAAK,QAAA,GAAOC,YAAAA,6BAAAA,CAA6B,KAAK,UAAU;CAC1D;CAEA,MAAM,SAA0B;EAC9B,OAAO,KAAK;CACd;CAEA,MAAM,eAAsC;EAC1C,OAAO,KAAK;CACd;AACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["packageJson.name","RESPONSE_TIMEOUT","getWsProvider","createClient","WsEvent","log","createClient","getWsProvider","throwAfter","viemChains","fromPairs","toPairs","camelCase","shouldThrow","fallback","http","createPublicClient","createWalletClient","isSolanaError","createDefaultRpcTransport","createSolanaRpcFromTransport","createSolanaRpcFromTransport","createSolanaRpcFromTransport"],"sources":["../package.json","../src/log.ts","../src/dot/ChainConnectorDot.ts","../src/dot/ChainConnectorDotPapi.ts","../src/dot/ChainConnectorDotStub.ts","../src/eth/getChainFromEvmNetwork.ts","../src/eth/getTransportForEvmNetwork.ts","../src/eth/getEvmNetworkPublicClient.ts","../src/eth/getEvmNetworkWalletClient.ts","../src/eth/ChainConnectorEth.ts","../src/eth/ChainConnectorEthStub.ts","../src/sol/getSolRpc.ts","../src/sol/ChainConnectorSol.ts","../src/sol/ChainConnectorSolStub.ts"],"sourcesContent":["","import anylogger from \"anylogger\"\n\nimport packageJson from \"../package.json\"\n\nexport default anylogger(packageJson.name)\n","import { createClient, type SubstrateClient } from \"@polkadot-api/substrate-client\"\nimport {\n getWsProvider,\n type StatusChange,\n WsEvent,\n type WsJsonRpcProvider,\n} from \"@polkadot-api/ws-provider\"\nimport type { DotNetworkId, IChaindataNetworkProvider } from \"@talismn/chaindata-provider\"\n\nimport log from \"../log\"\nimport type { IChainConnectorDot, SubscriptionCallback } from \"./IChainConnectorDot\"\n\n// errors that require an rpc fallback\n// https://docs.blastapi.io/blast-documentation/things-you-need-to-know/error-reference\nconst BAD_RPC_ERRORS: Record<string, string> = {\n \"-32097\": \"Rate limit exceeded\",\n \"-32098\": \"Capacity exceeded\",\n}\n\nconst RESPONSE_TIMEOUT = 30_000 // max wait for an rpc response (including connection time)\nconst KEEP_ALIVE_INTERVAL = 20_000 // periodic system_health to keep idle sockets alive (ws-provider kills quiet sockets after its 40s heartbeat)\n/**\n * How long a connection stays open once its last user releases it. A one-off request is\n * often followed by more traffic to the same chain (balances read the runtime version,\n * then subscribe to storage), which then reuses the socket instead of opening a new one.\n */\nconst IDLE_CLOSE_DELAY = 30_000\n\n/** in-flight requests reject with DestroyedError when a connection is torn down - expected, not worth logging */\nconst isDestroyedError = (error: unknown): boolean =>\n error instanceof Error && error.name === \"DestroyedError\"\nconst STALE_NOTIFY_TIMEOUT = 30_000 // how long a chain can be disconnected before subscribers are notified\n\nexport class ChainConnectionError extends Error {\n type: \"CHAIN_CONNECTION_ERROR\"\n chainId: string\n\n constructor(chainId: string, options?: ErrorOptions) {\n super(`Unable to connect to chain ${chainId}`, options)\n\n this.type = \"CHAIN_CONNECTION_ERROR\"\n this.chainId = chainId\n }\n}\n\n/**\n * Passed to subscription callbacks when the chain has been unreachable for a while. Not\n * terminal: the subscription stays registered and is re-issued when a socket connects.\n */\nexport class StaleRpcError extends Error {\n type: \"STALE_RPC_ERROR\"\n chainId: string\n\n constructor(chainId: string, options?: ErrorOptions) {\n super(`RPCs are stale/unavailable for chain ${chainId}`, options)\n\n this.type = \"STALE_RPC_ERROR\"\n this.chainId = chainId\n }\n}\n\ntype SocketUserId = number\n\ntype Subscription = {\n subscribeMethod: string\n params: unknown[]\n callback: SubscriptionCallback\n /** cancels the pending subscribe request, if any */\n cancelRequest: (() => void) | null\n /** stops routing notifications to the callback */\n stopFollow: (() => void) | null\n serverSubId: string | number | null\n unsubscribed: boolean\n}\n\ntype Connection = {\n chainId: DotNetworkId\n provider: WsJsonRpcProvider\n client: SubstrateClient\n users: Set<SocketUserId>\n subscriptions: Set<Subscription>\n wasConnected: boolean\n keepAliveInterval: ReturnType<typeof setInterval> | null\n staleTimeout: ReturnType<typeof setTimeout> | null\n /** closes the connection once it has had no users for IDLE_CLOSE_DELAY */\n idleTimeout: ReturnType<typeof setTimeout> | null\n}\n\nexport type ChainConnectorDotOptions = {\n /**\n * How long a new socket may take to open before the provider gives up on the endpoint\n * and tries the next one. Defaults to polkadot-api's 5 seconds. A slow device or\n * network can take longer than that to connect while it is busy, as a phone app is\n * at startup, and every endpoint then times out in turn.\n */\n connectionTimeout?: number\n}\n\n/**\n * ChainConnector provides an interface similar to a websocket JSON-RPC provider, but with three points of difference:\n *\n * 1. ChainConnector methods all accept a `chainId` instead of an array of RPCs. RPCs are then fetched internally from chaindata.\n * 2. ChainConnector creates only one socket connection per chain (via polkadot-api's ws-provider, which handles\n * endpoint rotation, reconnection and stale-socket detection) and ensures that all downstream requests to a chain\n * share that connection.\n * 3. Subscriptions return a callable `unsubscribe` method instead of an id, and are automatically re-established\n * when the provider reconnects (possibly to another endpoint).\n *\n * Additionally, when run on the clientside of a dapp where `window.talismanSub` is available, instead of spinning up new websocket\n * connections this class will forward all requests through to the wallet backend - where another instance of this class will\n * handle the websocket connections.\n */\nexport class ChainConnectorDot implements IChainConnectorDot {\n #chaindataChainProvider: IChaindataNetworkProvider\n #connectionTimeout: number | undefined\n\n #connections: Record<DotNetworkId, Connection> = {}\n #pendingConnections: Record<DotNetworkId, Promise<Connection>> = {}\n\n constructor(\n chaindataChainProvider: IChaindataNetworkProvider,\n options?: ChainConnectorDotOptions\n ) {\n this.#chaindataChainProvider = chaindataChainProvider\n this.#connectionTimeout = options?.connectionTimeout\n }\n\n // biome-ignore lint/suspicious/noExplicitAny: legacy\n async send<T = any>(\n chainId: DotNetworkId,\n method: string,\n params: unknown[],\n _isCacheable?: boolean | undefined,\n extraOptions?: {\n /**\n * Set to `true` if this query is speculative, i.e. if on some chains it's expected that it will raise a wasm unreachable error of the form:\n *\n * 4003: Client error: Execution failed: Execution aborted due to trap: wasm trap: wasm `unreachable` instruction executed\n *\n * By setting expectErrors to true, this method won't pollute the logs with errors we intend to have happen.\n * An example use case of this is when you plan to catch the wasm unreachable error on chains that don't support the query, and then fall back\n * to another query or perhaps an empty result.\n */\n expectErrors?: boolean\n }\n ): Promise<T> {\n const talismanSub = this.getTalismanSub()\n if (talismanSub !== undefined) {\n try {\n const genesisHash = await this.getGenesisHash(chainId)\n return await talismanSub.send(genesisHash, method, params)\n } catch (error) {\n log.warn(\n `Failed to make wallet-proxied send request for chain ${chainId}. Falling back to plain websocket`,\n error\n )\n }\n }\n\n let socketUserId: SocketUserId\n let connection: Connection\n try {\n ;[socketUserId, connection] = await this.acquireConnection(chainId)\n } catch (error) {\n throw new StaleRpcError(chainId, { cause: error })\n }\n\n try {\n return await this.request<T>(connection, method, params)\n } catch (err) {\n const error = err as (Error & { code?: number; data?: unknown }) | null\n\n if (error?.message === \"TIMEOUT\") {\n log.error(`ChainConnector timeout`, { chainId, error })\n connection.provider.switch()\n throw new Error(\"Timeout\")\n }\n\n const badRpcError = BAD_RPC_ERRORS[error?.code?.toString() ?? \"\"]\n if (badRpcError) {\n log.error(`ChainConnector ${badRpcError}`, { error, chainId })\n connection.provider.switch()\n throw new Error(badRpcError)\n }\n\n if (!extraOptions?.expectErrors)\n log.error(\n `Failed to send ${method} on chain ${chainId}\\nparams: ${JSON.stringify(params)}`,\n {\n error,\n }\n )\n\n throw error\n } finally {\n this.releaseConnection(chainId, socketUserId)\n }\n }\n\n async subscribe(\n chainId: DotNetworkId,\n subscribeMethod: string,\n responseMethod: string,\n params: unknown[],\n callback: SubscriptionCallback,\n timeout: number | false = 30_000 // 30 seconds in milliseconds\n ): Promise<(unsubscribeMethod: string) => void> {\n const talismanSub = this.getTalismanSub()\n if (talismanSub !== undefined) {\n try {\n const genesisHash = await this.getGenesisHash(chainId)\n\n const subscriptionId = await talismanSub.subscribe(\n genesisHash,\n subscribeMethod,\n responseMethod,\n params,\n callback,\n timeout\n )\n\n return (unsubscribeMethod: string) =>\n talismanSub.unsubscribe(subscriptionId, unsubscribeMethod)\n } catch (error) {\n log.warn(\n `Failed to create wallet-proxied subscription for chain ${chainId}. Falling back to plain websocket`,\n error\n )\n }\n }\n\n let socketUserId: SocketUserId\n let connection: Connection\n try {\n ;[socketUserId, connection] = await this.acquireConnection(chainId)\n } catch (error) {\n throw new StaleRpcError(chainId, { cause: error })\n }\n\n const subscription: Subscription = {\n subscribeMethod,\n params,\n callback,\n cancelRequest: null,\n stopFollow: null,\n serverSubId: null,\n unsubscribed: false,\n }\n connection.subscriptions.add(subscription)\n\n // if the chain can't be reached at all, let the caller know after a while (the provider keeps retrying)\n if (timeout && !connection.wasConnected) {\n const staleWarning = setTimeout(() => {\n if (!subscription.unsubscribed && !connection.wasConnected)\n callback(new StaleRpcError(chainId), null)\n }, timeout)\n const clear = () => clearTimeout(staleWarning)\n // piggyback on the follow setup to clear the warning once anything happens\n const originalCallback = subscription.callback\n subscription.callback = (error, result) => {\n clear()\n subscription.callback = originalCallback\n originalCallback(error, result)\n }\n }\n\n this.startSubscription(connection, subscription)\n\n return (unsubscribeMethod: string) => {\n if (subscription.unsubscribed) return\n subscription.unsubscribed = true\n\n subscription.cancelRequest?.()\n subscription.stopFollow?.()\n\n // the connection may have been replaced by a reset() since we subscribed. It stays\n // open for a while after its last user leaves, so unsubscribe on the server even then\n const current = this.#connections[chainId]\n if (subscription.serverSubId !== null && current)\n try {\n current.client.request(unsubscribeMethod, [subscription.serverSubId]).catch((error) => {\n if (!isDestroyedError(error)) log.warn(`Failed to unsubscribe from ${chainId}`, error)\n })\n } catch (error) {\n if (!isDestroyedError(error)) log.warn(`Failed to unsubscribe from ${chainId}`, error)\n }\n\n current?.subscriptions.delete(subscription)\n this.releaseConnection(chainId, socketUserId)\n }\n }\n\n /**\n * Kills and recreates the connection for a chain, if any.\n * Useful after changing a network's rpcs to make sure the new list is applied for further requests.\n * Active subscriptions are automatically re-established on the new connection.\n */\n async reset(chainId: DotNetworkId) {\n log.info(\"ChainConnector reset\", chainId)\n const connection = this.#connections[chainId]\n if (!connection) return\n\n this.destroyConnection(connection)\n delete this.#connections[chainId]\n\n // recreate a connection for the active subscriptions, if any\n if (connection.subscriptions.size) {\n try {\n const fresh = await this.createConnection(chainId)\n fresh.users = connection.users\n fresh.subscriptions = connection.subscriptions\n this.#connections[chainId] = fresh\n for (const subscription of fresh.subscriptions) this.startSubscription(fresh, subscription)\n } catch (error) {\n log.warn(`Failed to recreate connection for ${chainId} after reset`, error)\n // not a StaleRpcError: no connection is left to re-issue these subscriptions,\n // so subscribers must treat this one as terminal\n for (const subscription of connection.subscriptions)\n subscription.callback(new ChainConnectionError(chainId, { cause: error }), null)\n }\n }\n }\n\n /** Sends a request over a connection, throwing `Error(\"TIMEOUT\")` if no response arrives in time */\n private request<T>(\n connection: Connection,\n method: string,\n params: unknown[],\n timeoutMs = RESPONSE_TIMEOUT\n ): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n const timer = setTimeout(() => {\n cancel()\n reject(new Error(\"TIMEOUT\"))\n }, timeoutMs)\n\n const cancel = connection.client._request<T, unknown>(method, params, {\n onSuccess: (result) => {\n clearTimeout(timer)\n resolve(result)\n },\n onError: (error) => {\n clearTimeout(timer)\n reject(error)\n },\n })\n })\n }\n\n /** Issues the subscribe request and routes notifications to the subscription callback */\n private startSubscription(connection: Connection, subscription: Subscription) {\n subscription.serverSubId = null\n subscription.stopFollow = null\n\n subscription.cancelRequest = connection.client._request<string | number, unknown>(\n subscription.subscribeMethod,\n subscription.params,\n {\n onSuccess: (serverSubId, follow) => {\n subscription.cancelRequest = null\n if (subscription.unsubscribed) return\n\n subscription.serverSubId = serverSubId\n // raw-client matches notifications by the raw (not stringified) subscription id, but types it as string\n subscription.stopFollow = follow(serverSubId as string, {\n next: (result) => subscription.callback(null, result),\n error: (error) => subscription.callback(error, null),\n })\n },\n onError: (error) => {\n subscription.cancelRequest = null\n if (!subscription.unsubscribed) subscription.callback(error, null)\n },\n }\n )\n }\n\n /**\n * Get (or create) the shared connection for a chain.\n *\n * The caller must call releaseConnection with the returned SocketUserId once they are finished with it.\n */\n private async acquireConnection(chainId: DotNetworkId): Promise<[SocketUserId, Connection]> {\n // a single creation promise per chain guarantees that concurrent callers share the same connection\n let connection = this.#connections[chainId]\n if (!connection) {\n if (!this.#pendingConnections[chainId]) {\n this.#pendingConnections[chainId] = this.createConnection(chainId)\n .then((created) => {\n this.#connections[chainId] = created\n return created\n })\n .finally(() => {\n delete this.#pendingConnections[chainId]\n })\n }\n connection = await this.#pendingConnections[chainId]\n }\n\n if (connection.idleTimeout) {\n clearTimeout(connection.idleTimeout)\n connection.idleTimeout = null\n }\n const socketUserId = this.getExclusiveRandomId([...connection.users])\n connection.users.add(socketUserId)\n\n return [socketUserId, connection]\n }\n\n private async createConnection(chainId: DotNetworkId): Promise<Connection> {\n const chain = await this.#chaindataChainProvider.getNetworkById(chainId, \"polkadot\")\n if (!chain) throw new Error(`Chain ${chainId} not found in store`)\n\n const rpcs = chain.rpcs.concat()\n if (!rpcs.length) throw new Error(`No healthy RPCs available for chain ${chainId}`)\n\n // will be assigned below - the provider config needs to reference the connection\n let connection: Connection = null as unknown as Connection\n\n const provider = getWsProvider(rpcs, {\n onStatusChanged: (status: StatusChange) => this.handleStatusChange(connection, status),\n ...(this.#connectionTimeout !== undefined && { timeout: this.#connectionTimeout }),\n })\n\n const client = createClient(provider)\n\n connection = {\n chainId,\n provider,\n client,\n users: new Set(),\n subscriptions: new Set(),\n wasConnected: false,\n keepAliveInterval: null,\n staleTimeout: null,\n idleTimeout: null,\n }\n\n return connection\n }\n\n private handleStatusChange(connection: Connection, status: StatusChange) {\n // connection is still being constructed on the initial CONNECTING event\n if (!connection) return\n // ignore events from a connection that has been reset/destroyed\n if (this.#connections[connection.chainId] !== connection) return\n\n if (status.type === WsEvent.CONNECTED) {\n if (connection.staleTimeout) {\n clearTimeout(connection.staleTimeout)\n connection.staleTimeout = null\n }\n\n const isReconnect = connection.wasConnected\n connection.wasConnected = true\n\n // periodically send a request to keep the socket alive when there is no other traffic\n if (connection.keepAliveInterval) clearInterval(connection.keepAliveInterval)\n connection.keepAliveInterval = setInterval(() => {\n this.request(connection, \"system_health\", [], KEEP_ALIVE_INTERVAL).catch((error) => {\n if (!isDestroyedError(error))\n log.warn(`Failed keep-alive for socket ${connection.chainId}`, error)\n })\n }, KEEP_ALIVE_INTERVAL)\n\n // server-side subscriptions died with the previous socket : re-establish them\n // (skip author_* subscriptions : resubmitting an extrinsic is not safe)\n if (isReconnect)\n for (const subscription of connection.subscriptions) {\n if (subscription.unsubscribed) continue\n if (subscription.subscribeMethod.startsWith(\"author_\")) continue\n subscription.stopFollow?.()\n subscription.cancelRequest?.()\n this.startSubscription(connection, subscription)\n }\n } else {\n if (connection.keepAliveInterval) {\n clearInterval(connection.keepAliveInterval)\n connection.keepAliveInterval = null\n }\n\n // notify subscribers if the chain stays unreachable for too long\n if (!connection.staleTimeout && connection.subscriptions.size) {\n connection.staleTimeout = setTimeout(() => {\n connection.staleTimeout = null\n for (const subscription of connection.subscriptions)\n if (!subscription.unsubscribed)\n subscription.callback(new StaleRpcError(connection.chainId), null)\n }, STALE_NOTIFY_TIMEOUT)\n }\n }\n }\n\n private releaseConnection(chainId: DotNetworkId, socketUserId: SocketUserId): void {\n const connection = this.#connections[chainId]\n if (!connection) return\n\n connection.users.delete(socketUserId)\n if (connection.users.size > 0 || connection.idleTimeout) return\n\n connection.idleTimeout = setTimeout(() => {\n connection.idleTimeout = null\n if (connection.users.size > 0 || this.#connections[chainId] !== connection) return\n this.destroyConnection(connection)\n delete this.#connections[chainId]\n }, IDLE_CLOSE_DELAY)\n }\n\n private destroyConnection(connection: Connection): void {\n if (connection.keepAliveInterval) clearInterval(connection.keepAliveInterval)\n if (connection.staleTimeout) clearTimeout(connection.staleTimeout)\n if (connection.idleTimeout) clearTimeout(connection.idleTimeout)\n connection.keepAliveInterval = null\n connection.staleTimeout = null\n connection.idleTimeout = null\n\n // detach subscriptions before destroying the client so their callbacks don't receive a DestroyedError\n for (const subscription of connection.subscriptions) {\n subscription.stopFollow?.()\n subscription.cancelRequest?.()\n subscription.stopFollow = null\n subscription.cancelRequest = null\n subscription.serverSubId = null\n }\n\n try {\n connection.client.destroy()\n } catch (error) {\n log.warn(`Error occurred destroying connection ${connection.chainId}`, error)\n }\n }\n\n private async getGenesisHash(chainId: DotNetworkId): Promise<string> {\n const chain = await this.#chaindataChainProvider.getNetworkById(chainId, \"polkadot\")\n if (!chain) throw new Error(`Chain ${chainId} not found in store`)\n\n const { genesisHash } = chain\n if (typeof genesisHash !== \"string\")\n throw new Error(`Chain ${chainId} has no genesisHash in store`)\n\n return genesisHash\n }\n\n /** continues to generate a random number until it finds one which is not present in the exclude list */\n private getExclusiveRandomId(exclude: number[] = []): number {\n let id = this.getRandomId()\n while (exclude.includes(id)) {\n id = this.getRandomId()\n }\n return id\n }\n /** generates a random number */\n private getRandomId(): number {\n return Math.trunc(Math.random() * 10 ** 8)\n }\n\n private getTalismanSub() {\n // biome-ignore lint/suspicious/noExplicitAny: legacy\n const talismanSub = typeof window !== \"undefined\" && (window as any).talismanSub\n\n // biome-ignore lint/complexity/noBannedTypes: legacy\n const rpcByGenesisHashSend: Function | undefined = talismanSub?.rpcByGenesisHashSend\n // biome-ignore lint/complexity/noBannedTypes: legacy\n const rpcByGenesisHashSubscribe: Function | undefined = talismanSub?.rpcByGenesisHashSubscribe\n // biome-ignore lint/complexity/noBannedTypes: legacy\n const rpcByGenesisHashUnsubscribe: Function | undefined =\n talismanSub?.rpcByGenesisHashUnsubscribe\n\n if (typeof rpcByGenesisHashSend !== \"function\") return\n if (typeof rpcByGenesisHashSubscribe !== \"function\") return\n if (typeof rpcByGenesisHashUnsubscribe !== \"function\") return\n\n return {\n // biome-ignore lint/suspicious/noExplicitAny: legacy\n send: <T = any>(genesisHash: string, method: string, params: unknown[]): Promise<T> =>\n rpcByGenesisHashSend(genesisHash, method, params),\n\n subscribe: (\n genesisHash: string,\n subscribeMethod: string,\n responseMethod: string,\n params: unknown[],\n callback: SubscriptionCallback,\n timeout: number | false\n ): Promise<string> =>\n rpcByGenesisHashSubscribe(\n genesisHash,\n subscribeMethod,\n responseMethod,\n params,\n callback,\n timeout\n ),\n\n unsubscribe: (subscriptionId: string, unsubscribeMethod: string): Promise<void> =>\n rpcByGenesisHashUnsubscribe(subscriptionId, unsubscribeMethod),\n }\n }\n}\n","import type { DotNetworkId } from \"@talismn/chaindata-provider\"\n\nimport log from \"../log\"\nimport { StaleRpcError } from \"./ChainConnectorDot\"\nimport type { IChainConnectorDot, SubscriptionCallback } from \"./IChainConnectorDot\"\n\nconst RESPONSE_TIMEOUT = 30_000\nconst FAILURES_BEFORE_FIRST_RESULT = 3\n\ntype HexString = `0x${string}`\ntype StorageChanges = { block: HexString; changes: [HexString, HexString | null][] }\n\n/** The parts of a polkadot-api `PolkadotClient` that the connector uses */\nexport type PapiClient = {\n /** `PolkadotClient` types it without `abortSignal`, but it is substrate-client's `request`, which honours it */\n _request: <Reply>(method: string, params: unknown[], abortSignal?: AbortSignal) => Promise<Reply>\n bestBlocks$: {\n subscribe: (observer: {\n next: (blocks: { hash: string }[]) => void\n error: (error: unknown) => void\n complete: () => void\n }) => { unsubscribe: () => void }\n }\n}\n\n/**\n * Runs `@talismn/balances` over a dapp's polkadot-api clients, so the dapp and its balances share one socket per chain.\n *\n * `state_subscribeStorage` is the only subscription balances uses. It is served by querying the keys at each new\n * best block and reporting the values that changed, like the node does. One query runs at a time, for the latest\n * best block. A failed query is retried at the next block, because balances treats a subscription error as final\n * and would stop updating that network. Only when the first three queries fail does the subscription report the error.\n */\nexport class ChainConnectorDotPapi implements IChainConnectorDot {\n #clientFor: (networkId: DotNetworkId) => PapiClient | undefined\n\n constructor(clientFor: (networkId: DotNetworkId) => PapiClient | undefined) {\n this.#clientFor = clientFor\n }\n\n async send<T = unknown>(networkId: DotNetworkId, method: string, params: unknown[]): Promise<T> {\n return requestWithTimeout<T>(this.getClient(networkId), method, params, new AbortController())\n }\n\n async subscribe(\n networkId: DotNetworkId,\n subscribeMethod: string,\n _responseMethod: string,\n params: unknown[],\n callback: SubscriptionCallback,\n timeout: number | false = 30_000\n ): Promise<(unsubscribeMethod: string) => void> {\n const client = this.getClient(networkId)\n if (subscribeMethod !== \"state_subscribeStorage\")\n throw new Error(`ChainConnectorDotPapi does not support ${subscribeMethod}`)\n\n const [keys] = params as [HexString[]]\n const values = new Map<HexString, HexString | null>()\n let bestBlockHash: string | undefined\n let queriedBlockHash: string | undefined\n let inFlight: AbortController | undefined\n let delivered = false\n let failures = 0\n let active = true\n let subscription: { unsubscribe: () => void } | undefined\n const staleTimer = timeout\n ? setTimeout(() => callback(new StaleRpcError(networkId), null), timeout)\n : undefined\n\n const stop = () => {\n active = false\n clearTimeout(staleTimer)\n inFlight?.abort()\n subscription?.unsubscribe()\n }\n\n const finish = (error: Error) => {\n if (!active) return\n stop()\n callback(error, null)\n }\n\n const reportChanges = (result: StorageChanges) => {\n const changes = result.changes.filter(([key, value]) => values.get(key) !== value)\n for (const [key, value] of changes) values.set(key, value)\n if (!changes.length) return\n\n delivered = true\n clearTimeout(staleTimer)\n callback(null, { block: result.block, changes })\n }\n\n const reportFailure = (error: Error) => {\n if (delivered || ++failures < FAILURES_BEFORE_FIRST_RESULT)\n return log.warn(\n `state_queryStorageAt failed on ${networkId}, retrying at the next block`,\n error\n )\n finish(error)\n }\n\n const queryBestBlock = async () => {\n if (!active || inFlight || !bestBlockHash || bestBlockHash === queriedBlockHash) return\n const blockHash = bestBlockHash\n queriedBlockHash = blockHash\n const controller = new AbortController()\n inFlight = controller\n\n try {\n const [result] = await requestWithTimeout<StorageChanges[]>(\n client,\n \"state_queryStorageAt\",\n [keys, blockHash],\n controller\n )\n if (!active) return\n if (!result) throw new Error(`Empty state_queryStorageAt response on ${networkId}`)\n reportChanges(result)\n } catch (error) {\n if (active) reportFailure(error as Error)\n } finally {\n if (inFlight === controller) inFlight = undefined\n queryBestBlock()\n }\n }\n\n try {\n subscription = client.bestBlocks$.subscribe({\n next: ([best]) => {\n bestBlockHash = best?.hash\n queryBestBlock()\n },\n error: (error) => finish(error as Error),\n complete: () =>\n finish(new Error(`polkadot-api client for ${networkId} stopped following blocks`)),\n })\n } catch (error) {\n stop()\n throw error\n }\n if (!active) subscription.unsubscribe()\n\n return stop\n }\n\n async reset() {}\n\n private getClient(networkId: DotNetworkId): PapiClient {\n const client = this.#clientFor(networkId)\n if (!client) throw new Error(`No polkadot-api client for network ${networkId}`)\n return client\n }\n}\n\n/** rejects on its own timer too, so a client that ignores the abort signal cannot hang the caller */\nconst requestWithTimeout = <T>(\n client: PapiClient,\n method: string,\n params: unknown[],\n controller: AbortController\n) =>\n new Promise<T>((resolve, reject) => {\n const timer = setTimeout(() => {\n controller.abort()\n reject(new Error(\"Timeout\"))\n }, RESPONSE_TIMEOUT)\n try {\n client\n ._request<T>(method, params, controller.signal)\n .then(resolve, reject)\n .finally(() => clearTimeout(timer))\n } catch (error) {\n clearTimeout(timer)\n reject(error)\n }\n })\n","import { createClient, type SubstrateClient } from \"@polkadot-api/substrate-client\"\nimport { getWsProvider } from \"@polkadot-api/ws-provider\"\nimport type { DotNetwork, DotNetworkId } from \"@talismn/chaindata-provider\"\nimport { throwAfter } from \"@talismn/util\"\n\nimport type { IChainConnectorDot, SubscriptionCallback } from \"./IChainConnectorDot\"\n\nconst TIMEOUT = 10_000\n\nexport class ChainConnectorDotStub implements IChainConnectorDot {\n #client: SubstrateClient\n\n constructor(network: DotNetwork) {\n this.#client = createClient(getWsProvider(network.rpcs.concat()))\n }\n\n async send<T = unknown>(\n _chainId: DotNetworkId,\n method: string,\n params: unknown[],\n _isCacheable?: boolean\n ): Promise<T> {\n return await Promise.race([\n this.#client.request<T>(method, params),\n throwAfter(TIMEOUT, `Request ${method} timed out after ${TIMEOUT}ms`),\n ])\n }\n\n async subscribe(\n _chainId: DotNetworkId,\n subscribeMethod: string,\n _responseMethod: string,\n params: unknown[],\n callback: SubscriptionCallback,\n timeout?: number | false\n ): Promise<(unsubscribeMethod: string) => void> {\n let stopFollow: (() => void) | null = null\n let unsubscribed = false\n\n const serverSubId = await Promise.race([\n new Promise<string | number>((resolve, reject) => {\n this.#client._request<string | number, unknown>(subscribeMethod, params, {\n onSuccess: (subId, follow) => {\n stopFollow = follow(subId as string, {\n next: (result) => callback(null, result),\n error: (error) => callback(error, null),\n })\n resolve(subId)\n },\n onError: reject,\n })\n }),\n throwAfter(timeout || TIMEOUT, `Subscription timed out after ${timeout || TIMEOUT}ms`),\n ])\n\n return (unsubscribeMethod: string) => {\n if (unsubscribed) return\n unsubscribed = true\n stopFollow?.()\n this.#client.request(unsubscribeMethod, [serverSubId]).catch(() => {}) // connection may already be gone\n }\n }\n\n reset(): Promise<void> {\n throw new Error(\"ChainConnectorDotStub does not implement reset\")\n }\n\n destroy() {\n this.#client.destroy()\n }\n}\n","import type { EthNetwork, EthNetworkId } from \"@talismn/chaindata-provider\"\nimport { camelCase, fromPairs, toPairs } from \"lodash-es\"\nimport type { Chain, ChainContract } from \"viem\"\nimport * as viemChains from \"viem/chains\"\n\n// exclude zoraTestnet which uses Hyperliquid's chain id\nconst { zoraTestnet, ...validViemChains } = viemChains\n\n// viem chains benefit from multicall config & other viem goodies\nconst VIEM_CHAINS = Object.keys(validViemChains).reduce(\n (acc, curr) => {\n const chain = validViemChains[curr as keyof typeof validViemChains]\n acc[chain.id] = chain\n return acc\n },\n {} as Record<number, Chain>\n)\n\nconst chainsCache = new Map<string, Chain>()\n\nexport const clearChainsCache = (networkId?: EthNetworkId) => {\n if (networkId) chainsCache.delete(networkId)\n else chainsCache.clear()\n}\n\nexport const getChainFromEvmNetwork = (network: EthNetwork): Chain => {\n const { symbol, decimals } = network.nativeCurrency\n\n if (!chainsCache.has(network.id)) {\n const chainRpcs = network.rpcs ?? []\n\n const viemChain = VIEM_CHAINS[Number(network.id)] ?? {}\n\n const chain: Chain = {\n ...viemChain,\n id: Number(network.id),\n name: network.name ?? `Ethereum Chain ${network.id}`,\n rpcUrls: {\n public: { http: chainRpcs },\n default: { http: chainRpcs },\n },\n nativeCurrency: {\n symbol,\n decimals,\n name: symbol,\n },\n contracts: {\n ...viemChain.contracts,\n ...(network.contracts\n ? fromPairs(\n toPairs(network.contracts).map(([name, address]): [string, ChainContract] => [\n camelCase(name),\n { address },\n ])\n )\n : {}),\n },\n }\n\n chainsCache.set(network.id, chain)\n }\n\n return chainsCache.get(network.id) as Chain\n}\n","import type { EthNetwork } from \"@talismn/chaindata-provider\"\nimport { fallback, http, shouldThrow } from \"viem\"\n\nexport type TransportOptions = {\n batch?:\n | boolean\n | {\n batchSize?: number | undefined\n wait?: number | undefined\n }\n}\n\n// Frontier nodes report reverts with a message viem does not recognize, which makes fallback retry every rpc\nconst FRONTIER_EXECUTION_ERROR = /VM Exception while processing transaction/\n\nconst isFinalError = (error: Error) =>\n shouldThrow(error) || FRONTIER_EXECUTION_ERROR.test(error.message)\n\nexport const getTransportForEvmNetwork = (\n evmNetwork: EthNetwork,\n options: TransportOptions = {}\n) => {\n if (!evmNetwork.rpcs?.length) throw new Error(\"No RPCs found for EVM network\")\n\n const { batch } = options\n\n return fallback(\n evmNetwork.rpcs.map((url) => http(url, { batch, retryCount: 0 })),\n { retryCount: 0, shouldThrow: isFinalError }\n )\n}\n","import type { EthNetwork } from \"@talismn/chaindata-provider\"\nimport { createPublicClient, type PublicClient } from \"viem\"\n\nimport { clearChainsCache, getChainFromEvmNetwork } from \"./getChainFromEvmNetwork\"\nimport { getTransportForEvmNetwork, type TransportOptions } from \"./getTransportForEvmNetwork\"\n\nconst MUTLICALL_BATCH_WAIT = 25\nconst MUTLICALL_BATCH_SIZE = 100\n\nconst HTTP_BATCH_WAIT = 25\nconst HTTP_BATCH_SIZE_WITH_MULTICALL = 10\nconst HTTP_BATCH_SIZE_WITHOUT_MULTICALL = 30\n\n// cache to reuse previously created public clients\nconst publicClientCache = new Map<string, PublicClient>()\n\nexport const clearPublicClientCache = (evmNetworkId?: string) => {\n clearChainsCache(evmNetworkId)\n\n if (evmNetworkId) publicClientCache.delete(evmNetworkId)\n else publicClientCache.clear()\n}\n\nexport const getEvmNetworkPublicClient = (network: EthNetwork): PublicClient => {\n const chain = getChainFromEvmNetwork(network)\n\n if (!publicClientCache.has(network.id)) {\n if (!network.rpcs.length) throw new Error(\"No RPCs found for Ethereum network\")\n\n const batch = chain.contracts?.multicall3\n ? { multicall: { wait: MUTLICALL_BATCH_WAIT, batchSize: MUTLICALL_BATCH_SIZE } }\n : undefined\n\n const transportOptions: TransportOptions = {\n batch: {\n batchSize: chain.contracts?.multicall3\n ? HTTP_BATCH_SIZE_WITH_MULTICALL\n : HTTP_BATCH_SIZE_WITHOUT_MULTICALL,\n wait: HTTP_BATCH_WAIT,\n },\n }\n\n const transport = getTransportForEvmNetwork(network, transportOptions)\n\n publicClientCache.set(\n network.id,\n createPublicClient({\n chain,\n transport,\n batch,\n })\n )\n }\n\n return publicClientCache.get(network.id) as PublicClient\n}\n","import type { EthNetwork } from \"@talismn/chaindata-provider\"\nimport { type Account, createWalletClient, type WalletClient } from \"viem\"\n\nimport { getChainFromEvmNetwork } from \"./getChainFromEvmNetwork\"\nimport { getTransportForEvmNetwork } from \"./getTransportForEvmNetwork\"\n\ntype WalletClientOptions = {\n account?: `0x${string}` | Account\n}\n\nexport const getEvmNetworkWalletClient = (\n network: EthNetwork,\n options: WalletClientOptions = {}\n): WalletClient => {\n const chain = getChainFromEvmNetwork(network)\n\n const transport = getTransportForEvmNetwork(network)\n\n return createWalletClient({ chain, transport, account: options.account })\n}\n","import type {\n EthNetworkId,\n IChaindataNetworkProvider,\n IChaindataTokenProvider,\n} from \"@talismn/chaindata-provider\"\nimport type { Account, PublicClient, WalletClient } from \"viem\"\n\nimport { clearPublicClientCache, getEvmNetworkPublicClient } from \"./getEvmNetworkPublicClient\"\nimport { getEvmNetworkWalletClient } from \"./getEvmNetworkWalletClient\"\nimport type { IChainConnectorEth } from \"./IChainConnectorEth\"\n\nexport class ChainConnectorEth implements IChainConnectorEth {\n #chaindataProvider: IChaindataNetworkProvider & IChaindataTokenProvider\n\n constructor(chaindataProvider: IChaindataNetworkProvider & IChaindataTokenProvider) {\n this.#chaindataProvider = chaindataProvider\n }\n\n async getPublicClientForEvmNetwork(evmNetworkId: EthNetworkId): Promise<PublicClient | null> {\n const network = await this.#chaindataProvider.getNetworkById(evmNetworkId, \"ethereum\")\n if (!network) return null\n\n return getEvmNetworkPublicClient(network)\n }\n\n async getWalletClientForEvmNetwork(\n evmNetworkId: EthNetworkId,\n account?: `0x${string}` | Account\n ): Promise<WalletClient | null> {\n const network = await this.#chaindataProvider.getNetworkById(evmNetworkId, \"ethereum\")\n if (!network) return null\n\n return getEvmNetworkWalletClient(network, { account })\n }\n\n public clearRpcProvidersCache(evmNetworkId?: EthNetworkId) {\n clearPublicClientCache(evmNetworkId)\n }\n}\n","import type { EthNetwork, EthNetworkId } from \"@talismn/chaindata-provider\"\nimport type { Account, PublicClient, WalletClient } from \"viem\"\n\nimport { getEvmNetworkPublicClient } from \"./getEvmNetworkPublicClient\"\nimport { getEvmNetworkWalletClient } from \"./getEvmNetworkWalletClient\"\nimport type { IChainConnectorEth } from \"./IChainConnectorEth\"\n\nexport class ChainConnectorEthStub implements IChainConnectorEth {\n #network: EthNetwork\n\n constructor(network: EthNetwork) {\n this.#network = network\n }\n\n async getPublicClientForEvmNetwork(): Promise<PublicClient | null> {\n return getEvmNetworkPublicClient(this.#network)\n }\n\n async getWalletClientForEvmNetwork(\n _networkId: EthNetworkId,\n account?: `0x${string}` | Account\n ): Promise<WalletClient | null> {\n return getEvmNetworkWalletClient(this.#network, { account })\n }\n\n clearRpcProvidersCache(): void {\n // No-op for stub\n }\n}\n","import type { Rpc, RpcTransport, SolanaRpcApi } from \"@solana/kit\"\nimport { createDefaultRpcTransport, createSolanaRpcFromTransport, isSolanaError } from \"@solana/kit\"\nimport type { SolNetworkId } from \"@talismn/chaindata-provider\"\n\nexport type SolRpc = Rpc<SolanaRpcApi>\n\n// Public Solana RPC nodes rate-limit aggressively with HTTP 429. kit's default transport is\n// single-shot, unlike the old web3.js `Connection` which retried 429 up to 5x with backoff, so a\n// single 429 would fail an otherwise-valid request (e.g. a user's transaction submission, or token\n// discovery silently returning no tokens). This wrapper restores that behaviour.\nconst MAX_429_RETRIES = 5\nconst BASE_BACKOFF_MS = 500\n\ntype HttpErrorContext = { statusCode?: number; headers?: Headers }\n\nconst getRateLimitContext = (error: unknown): HttpErrorContext | null => {\n if (!isSolanaError(error)) return null\n\n const context = error.context as HttpErrorContext\n return context.statusCode === 429 ? context : null\n}\n\n/** Returns the delay to wait before retrying, or `null` if the error is not a retryable 429. */\nconst get429RetryDelay = (error: unknown, attempt: number): number | null => {\n const context = getRateLimitContext(error)\n if (!context) return null\n\n // honour the server's Retry-After header (delta-seconds) when present\n const retryAfter = Number(context.headers?.get(\"retry-after\"))\n if (Number.isFinite(retryAfter) && retryAfter > 0) return retryAfter * 1000\n\n // otherwise exponential backoff: 500ms, 1s, 2s, 4s, 8s\n return BASE_BACKOFF_MS * 2 ** attempt\n}\n\nconst sleep = (ms: number, signal?: AbortSignal): Promise<void> =>\n new Promise((resolve, reject) => {\n if (signal?.aborted) return reject(signal.reason)\n\n const onAbort = () => {\n clearTimeout(timeout)\n reject(signal?.reason)\n }\n const timeout = setTimeout(() => {\n signal?.removeEventListener(\"abort\", onAbort)\n resolve()\n }, ms)\n signal?.addEventListener(\"abort\", onAbort, { once: true })\n })\n\n/**\n * Wraps a transport so HTTP 429 responses are retried with backoff. Solana RPC requests are\n * idempotent (`sendTransaction` is keyed by signature), so replaying a rate-limited request is safe.\n */\nconst withRetryOn429 = (transport: RpcTransport): RpcTransport => {\n const wrapped = async (config: Parameters<RpcTransport>[0]) => {\n for (let attempt = 0; ; attempt++) {\n try {\n return await transport(config)\n } catch (error) {\n const delay = attempt < MAX_429_RETRIES ? get429RetryDelay(error, attempt) : null\n if (delay === null) throw error\n await sleep(delay, config.signal)\n }\n }\n }\n return wrapped as RpcTransport\n}\n\n/**\n * How long a request may wait on an RPC before moving on to the next one. The last RPC tried gets\n * no timeout, so a slow but working node still answers when every other one has failed.\n */\nconst FAILOVER_TIMEOUT_MS = 20_000\n\nconst sendWithTimeout = async <TResponse>(\n transport: RpcTransport,\n config: RpcTransportConfig,\n timeoutMs: number\n): Promise<TResponse> => {\n const controller = new AbortController()\n const onAbort = () => controller.abort(config.signal?.reason)\n config.signal?.addEventListener(\"abort\", onAbort, { once: true })\n const timeout = setTimeout(\n () => controller.abort(new Error(`RPC request timed out after ${timeoutMs}ms`)),\n timeoutMs\n )\n\n try {\n return await transport<TResponse>({ ...config, signal: controller.signal })\n } finally {\n clearTimeout(timeout)\n config.signal?.removeEventListener(\"abort\", onAbort)\n }\n}\n\ntype RpcTransportConfig = Parameters<RpcTransport>[0]\n\nconst isSendTransactionPayload = (\n payload: unknown\n): payload is { method: \"sendTransaction\"; params: unknown[] } =>\n typeof payload === \"object\" &&\n payload !== null &&\n \"method\" in payload &&\n payload.method === \"sendTransaction\" &&\n \"params\" in payload &&\n Array.isArray(payload.params)\n\nconst withoutPreflight = (config: RpcTransportConfig): RpcTransportConfig => {\n if (!isSendTransactionPayload(config.payload)) return config\n\n const [transaction, sendConfig] = config.payload.params\n return {\n ...config,\n payload: {\n ...config.payload,\n params: [transaction, { ...(sendConfig as object | undefined), skipPreflight: true }],\n },\n }\n}\n\nexport type SolTransportOptions = {\n /** Called with the url of the RPC that answered, after every successful request */\n onRpcSuccess?: (url: string) => void\n}\n\n/**\n * Sends each request to one RPC at a time, starting from the one that answered last, and moves on to\n * the next when the request fails. A transport only throws for connection, timeout and HTTP errors:\n * JSON-RPC errors come back in the response body and are returned as is.\n *\n * A failed RPC other than a rate limited one may still have forwarded a transaction. Resending it is\n * safe, as the network processes a signature once, but its preflight simulation on the next RPC\n * could then fail although it landed. So after such a failure, every resend of that transaction,\n * including the retries after a rate limit, skips preflight.\n */\nconst withFailover = (urls: string[], options: SolTransportOptions): RpcTransport => {\n const transports = urls.map((url) => createDefaultRpcTransport({ url }))\n let preferred = 0\n const mayHaveBeenProcessed = new WeakSet<RpcTransportConfig>()\n\n const failover = async <TResponse>(config: RpcTransportConfig): Promise<TResponse> => {\n if (!transports.length) throw new Error(\"No RPCs found for Solana network\")\n\n const start = preferred\n let lastError: unknown\n let rateLimitError: unknown\n for (let attempt = 0; attempt < transports.length; attempt++) {\n config.signal?.throwIfAborted()\n const index = (start + attempt) % transports.length\n const transport = transports[index] as RpcTransport\n const isLastAttempt = attempt === transports.length - 1\n const request = mayHaveBeenProcessed.has(config) ? withoutPreflight(config) : config\n\n try {\n const response = isLastAttempt\n ? await transport<TResponse>(request)\n : await sendWithTimeout<TResponse>(transport, request, FAILOVER_TIMEOUT_MS)\n preferred = index\n options.onRpcSuccess?.(urls[index] as string)\n return response\n } catch (error) {\n if (config.signal?.aborted) throw error\n lastError = error\n if (!getRateLimitContext(error)) mayHaveBeenProcessed.add(config)\n else rateLimitError ??= error\n }\n }\n throw rateLimitError ?? lastError\n }\n return failover as RpcTransport\n}\n\n/**\n * Returns a transport over all of the network's RPCs, in the given order. A request fails over to\n * the next RPC on error, and the RPC that answered is tried first for the next request. When every\n * RPC fails and one of them answered HTTP 429, the whole list is retried with backoff.\n */\nexport const getSolTransport = (\n _networkId: SolNetworkId,\n rpcs: string[],\n options: SolTransportOptions = {}\n): RpcTransport => {\n return withRetryOn429(withFailover(rpcs, options))\n}\n\nexport const getSolRpc = (\n networkId: SolNetworkId,\n rpcs: string[],\n options?: SolTransportOptions\n): SolRpc => createSolanaRpcFromTransport(getSolTransport(networkId, rpcs, options))\n","import type { RpcTransport } from \"@solana/kit\"\nimport { createSolanaRpcFromTransport } from \"@solana/kit\"\nimport type {\n IChaindataNetworkProvider,\n IChaindataTokenProvider,\n SolNetworkId,\n} from \"@talismn/chaindata-provider\"\n\nimport type { SolRpc } from \"./getSolRpc\"\nimport { getSolTransport } from \"./getSolRpc\"\nimport type { IChainConnectorSol } from \"./IChainConnectorSol\"\n\nexport class ChainConnectorSol implements IChainConnectorSol {\n #chaindataProvider: IChaindataNetworkProvider & IChaindataTokenProvider\n #transports = new Map<SolNetworkId, RpcTransport>()\n #rpcs = new Map<SolNetworkId, SolRpc>()\n\n constructor(chaindataProvider: IChaindataNetworkProvider & IChaindataTokenProvider) {\n this.#chaindataProvider = chaindataProvider\n }\n\n async #getNetworkRpcs(networkId: SolNetworkId): Promise<string[]> {\n const network = await this.#chaindataProvider.getNetworkById(networkId, \"solana\")\n if (!network) throw new Error(`Network not found: ${networkId}`)\n\n return network.rpcs\n }\n\n async getTransport(networkId: SolNetworkId): Promise<RpcTransport> {\n if (!this.#transports.has(networkId))\n this.#transports.set(\n networkId,\n getSolTransport(networkId, await this.#getNetworkRpcs(networkId))\n )\n\n return this.#transports.get(networkId)!\n }\n\n async getRpc(networkId: SolNetworkId): Promise<SolRpc> {\n if (!this.#rpcs.has(networkId))\n this.#rpcs.set(networkId, createSolanaRpcFromTransport(await this.getTransport(networkId)))\n\n return this.#rpcs.get(networkId)!\n }\n\n /** Drops cached transports/rpcs so the next call re-reads the network's rpcs from chaindata */\n clearRpcProvidersCache(networkId?: SolNetworkId) {\n if (networkId) {\n this.#transports.delete(networkId)\n this.#rpcs.delete(networkId)\n } else {\n this.#transports.clear()\n this.#rpcs.clear()\n }\n }\n}\n","import type { RpcTransport } from \"@solana/kit\"\nimport { createSolanaRpcFromTransport } from \"@solana/kit\"\nimport type { SolNetwork } from \"@talismn/chaindata-provider\"\n\nimport type { SolRpc } from \"./getSolRpc\"\nimport { getSolTransport } from \"./getSolRpc\"\nimport type { IChainConnectorSol } from \"./IChainConnectorSol\"\n\nexport class ChainConnectorSolStub implements IChainConnectorSol {\n #transport: RpcTransport\n #rpc: SolRpc\n\n constructor(network: Pick<SolNetwork, \"id\" | \"rpcs\">) {\n this.#transport = getSolTransport(network.id, network.rpcs)\n this.#rpc = createSolanaRpcFromTransport(this.#transport)\n }\n\n async getRpc(): Promise<SolRpc> {\n return this.#rpc\n }\n\n async getTransport(): Promise<RpcTransport> {\n return this.#transport\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACIA,IAAA,eAAA,GAAe,UAAA,QAAA,CAAUA,2BAAgB;;ACUzC,MAAM,iBAAyC;CAC7C,UAAU;CACV,UAAU;AACZ;AAEA,MAAMC,qBAAmB;AACzB,MAAM,sBAAsB;;;;;;AAM5B,MAAM,mBAAmB;;AAGzB,MAAM,oBAAoB,UACxB,iBAAiB,SAAS,MAAM,SAAS;AAC3C,MAAM,uBAAuB;AAE7B,IAAa,uBAAb,cAA0C,MAAM;CAC9C;CACA;CAEA,YAAY,SAAiB,SAAwB;EACnD,MAAM,8BAA8B,WAAW,OAAO;EAEtD,KAAK,OAAO;EACZ,KAAK,UAAU;CACjB;AACF;;;;;AAMA,IAAa,gBAAb,cAAmC,MAAM;CACvC;CACA;CAEA,YAAY,SAAiB,SAAwB;EACnD,MAAM,wCAAwC,WAAW,OAAO;EAEhE,KAAK,OAAO;EACZ,KAAK,UAAU;CACjB;AACF;;;;;;;;;;;;;;;AAqDA,IAAa,oBAAb,MAA6D;CAC3D;CACA;CAEA,eAAiD,CAAC;CAClD,sBAAiE,CAAC;CAElE,YACE,wBACA,SACA;EACA,KAAK,0BAA0B;EAC/B,KAAK,qBAAqB,SAAS;CACrC;CAGA,MAAM,KACJ,SACA,QACA,QACA,cACA,cAYY;EACZ,MAAM,cAAc,KAAK,eAAe;EACxC,IAAI,gBAAgB,KAAA,GAClB,IAAI;GACF,MAAM,cAAc,MAAM,KA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aAAa,SAAS,CAAC,CAAC;EAE5F,OAAO,KAAK,MAAM,IAAI,SAAS;CACjC;;CAGA,uBAAuB,WAA0B;EAC/C,IAAI,WAAW;GACb,KAAK,YAAY,OAAO,SAAS;GACjC,KAAK,MAAM,OAAO,SAAS;EAC7B,OAAO;GACL,KAAK,YAAY,MAAM;GACvB,KAAK,MAAM,MAAM;EACnB;CACF;AACF;;AC/CA,IAAa,wBAAb,MAAiE;CAC/D;CACA;CAEA,YAAY,SAA0C;EACpD,KAAK,aAAa,gBAAgB,QAAQ,IAAI,QAAQ,IAAI;EAC1D,KAAK,QAAA,GAAOC,YAAAA,6BAAAA,CAA6B,KAAK,UAAU;CAC1D;CAEA,MAAM,SAA0B;EAC9B,OAAO,KAAK;CACd;CAEA,MAAM,eAAsC;EAC1C,OAAO,KAAK;CACd;AACF"}
|
package/dist/index.mjs
CHANGED
|
@@ -6,11 +6,9 @@ import { createPublicClient, createWalletClient, fallback, http, shouldThrow } f
|
|
|
6
6
|
import { camelCase, fromPairs, toPairs } from "lodash-es";
|
|
7
7
|
import * as viemChains from "viem/chains";
|
|
8
8
|
import { createDefaultRpcTransport, createSolanaRpcFromTransport, isSolanaError } from "@solana/kit";
|
|
9
|
-
|
|
10
|
-
//#region src/log.ts
|
|
9
|
+
// src/log.ts
|
|
11
10
|
var log_default = anylogger("@talismn/chain-connectors");
|
|
12
|
-
|
|
13
|
-
//#region src/dot/ChainConnectorDot.ts
|
|
11
|
+
// src/dot/ChainConnectorDot.ts
|
|
14
12
|
const BAD_RPC_ERRORS = {
|
|
15
13
|
"-32097": "Rate limit exceeded",
|
|
16
14
|
"-32098": "Capacity exceeded"
|
|
@@ -375,8 +373,7 @@ var ChainConnectorDot = class {
|
|
|
375
373
|
};
|
|
376
374
|
}
|
|
377
375
|
};
|
|
378
|
-
|
|
379
|
-
//#region src/dot/ChainConnectorDotPapi.ts
|
|
376
|
+
// src/dot/ChainConnectorDotPapi.ts
|
|
380
377
|
const RESPONSE_TIMEOUT = 3e4;
|
|
381
378
|
const FAILURES_BEFORE_FIRST_RESULT = 3;
|
|
382
379
|
/**
|
|
@@ -488,8 +485,7 @@ const requestWithTimeout = (client, method, params, controller) => new Promise((
|
|
|
488
485
|
reject(error);
|
|
489
486
|
}
|
|
490
487
|
});
|
|
491
|
-
|
|
492
|
-
//#region src/dot/ChainConnectorDotStub.ts
|
|
488
|
+
// src/dot/ChainConnectorDotStub.ts
|
|
493
489
|
const TIMEOUT = 1e4;
|
|
494
490
|
var ChainConnectorDotStub = class {
|
|
495
491
|
#client;
|
|
@@ -528,8 +524,7 @@ var ChainConnectorDotStub = class {
|
|
|
528
524
|
this.#client.destroy();
|
|
529
525
|
}
|
|
530
526
|
};
|
|
531
|
-
|
|
532
|
-
//#region src/eth/getChainFromEvmNetwork.ts
|
|
527
|
+
// src/eth/getChainFromEvmNetwork.ts
|
|
533
528
|
const { zoraTestnet, ...validViemChains } = viemChains;
|
|
534
529
|
const VIEM_CHAINS = Object.keys(validViemChains).reduce((acc, curr) => {
|
|
535
530
|
const chain = validViemChains[curr];
|
|
@@ -568,8 +563,7 @@ const getChainFromEvmNetwork = (network) => {
|
|
|
568
563
|
}
|
|
569
564
|
return chainsCache.get(network.id);
|
|
570
565
|
};
|
|
571
|
-
|
|
572
|
-
//#region src/eth/getTransportForEvmNetwork.ts
|
|
566
|
+
// src/eth/getTransportForEvmNetwork.ts
|
|
573
567
|
const FRONTIER_EXECUTION_ERROR = /VM Exception while processing transaction/;
|
|
574
568
|
const isFinalError = (error) => shouldThrow(error) || FRONTIER_EXECUTION_ERROR.test(error.message);
|
|
575
569
|
const getTransportForEvmNetwork = (evmNetwork, options = {}) => {
|
|
@@ -583,8 +577,7 @@ const getTransportForEvmNetwork = (evmNetwork, options = {}) => {
|
|
|
583
577
|
shouldThrow: isFinalError
|
|
584
578
|
});
|
|
585
579
|
};
|
|
586
|
-
|
|
587
|
-
//#region src/eth/getEvmNetworkPublicClient.ts
|
|
580
|
+
// src/eth/getEvmNetworkPublicClient.ts
|
|
588
581
|
const MUTLICALL_BATCH_WAIT = 25;
|
|
589
582
|
const MUTLICALL_BATCH_SIZE = 100;
|
|
590
583
|
const HTTP_BATCH_WAIT = 25;
|
|
@@ -617,8 +610,7 @@ const getEvmNetworkPublicClient = (network) => {
|
|
|
617
610
|
}
|
|
618
611
|
return publicClientCache.get(network.id);
|
|
619
612
|
};
|
|
620
|
-
|
|
621
|
-
//#region src/eth/getEvmNetworkWalletClient.ts
|
|
613
|
+
// src/eth/getEvmNetworkWalletClient.ts
|
|
622
614
|
const getEvmNetworkWalletClient = (network, options = {}) => {
|
|
623
615
|
const chain = getChainFromEvmNetwork(network);
|
|
624
616
|
const transport = getTransportForEvmNetwork(network);
|
|
@@ -628,8 +620,7 @@ const getEvmNetworkWalletClient = (network, options = {}) => {
|
|
|
628
620
|
account: options.account
|
|
629
621
|
});
|
|
630
622
|
};
|
|
631
|
-
|
|
632
|
-
//#region src/eth/ChainConnectorEth.ts
|
|
623
|
+
// src/eth/ChainConnectorEth.ts
|
|
633
624
|
var ChainConnectorEth = class {
|
|
634
625
|
#chaindataProvider;
|
|
635
626
|
constructor(chaindataProvider) {
|
|
@@ -649,8 +640,7 @@ var ChainConnectorEth = class {
|
|
|
649
640
|
clearPublicClientCache(evmNetworkId);
|
|
650
641
|
}
|
|
651
642
|
};
|
|
652
|
-
|
|
653
|
-
//#region src/eth/ChainConnectorEthStub.ts
|
|
643
|
+
// src/eth/ChainConnectorEthStub.ts
|
|
654
644
|
var ChainConnectorEthStub = class {
|
|
655
645
|
#network;
|
|
656
646
|
constructor(network) {
|
|
@@ -664,8 +654,7 @@ var ChainConnectorEthStub = class {
|
|
|
664
654
|
}
|
|
665
655
|
clearRpcProvidersCache() {}
|
|
666
656
|
};
|
|
667
|
-
|
|
668
|
-
//#region src/sol/getSolRpc.ts
|
|
657
|
+
// src/sol/getSolRpc.ts
|
|
669
658
|
const MAX_429_RETRIES = 5;
|
|
670
659
|
const BASE_BACKOFF_MS = 500;
|
|
671
660
|
const getRateLimitContext = (error) => {
|
|
@@ -794,8 +783,7 @@ const getSolTransport = (_networkId, rpcs, options = {}) => {
|
|
|
794
783
|
return withRetryOn429(withFailover(rpcs, options));
|
|
795
784
|
};
|
|
796
785
|
const getSolRpc = (networkId, rpcs, options) => createSolanaRpcFromTransport(getSolTransport(networkId, rpcs, options));
|
|
797
|
-
|
|
798
|
-
//#region src/sol/ChainConnectorSol.ts
|
|
786
|
+
// src/sol/ChainConnectorSol.ts
|
|
799
787
|
var ChainConnectorSol = class {
|
|
800
788
|
#chaindataProvider;
|
|
801
789
|
#transports = /* @__PURE__ */ new Map();
|
|
@@ -827,8 +815,7 @@ var ChainConnectorSol = class {
|
|
|
827
815
|
}
|
|
828
816
|
}
|
|
829
817
|
};
|
|
830
|
-
|
|
831
|
-
//#region src/sol/ChainConnectorSolStub.ts
|
|
818
|
+
// src/sol/ChainConnectorSolStub.ts
|
|
832
819
|
var ChainConnectorSolStub = class {
|
|
833
820
|
#transport;
|
|
834
821
|
#rpc;
|
|
@@ -843,7 +830,6 @@ var ChainConnectorSolStub = class {
|
|
|
843
830
|
return this.#transport;
|
|
844
831
|
}
|
|
845
832
|
};
|
|
846
|
-
//#endregion
|
|
847
833
|
export { ChainConnectionError, ChainConnectorDot, ChainConnectorDotPapi, ChainConnectorDotStub, ChainConnectorEth, ChainConnectorEthStub, ChainConnectorSol, ChainConnectorSolStub, StaleRpcError, getSolRpc, getSolTransport };
|
|
848
834
|
|
|
849
835
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["packageJson.name","RESPONSE_TIMEOUT","log"],"sources":["../package.json","../src/log.ts","../src/dot/ChainConnectorDot.ts","../src/dot/ChainConnectorDotPapi.ts","../src/dot/ChainConnectorDotStub.ts","../src/eth/getChainFromEvmNetwork.ts","../src/eth/getTransportForEvmNetwork.ts","../src/eth/getEvmNetworkPublicClient.ts","../src/eth/getEvmNetworkWalletClient.ts","../src/eth/ChainConnectorEth.ts","../src/eth/ChainConnectorEthStub.ts","../src/sol/getSolRpc.ts","../src/sol/ChainConnectorSol.ts","../src/sol/ChainConnectorSolStub.ts"],"sourcesContent":["","import anylogger from \"anylogger\"\n\nimport packageJson from \"../package.json\"\n\nexport default anylogger(packageJson.name)\n","import { createClient, type SubstrateClient } from \"@polkadot-api/substrate-client\"\nimport {\n getWsProvider,\n type StatusChange,\n WsEvent,\n type WsJsonRpcProvider,\n} from \"@polkadot-api/ws-provider\"\nimport type { DotNetworkId, IChaindataNetworkProvider } from \"@talismn/chaindata-provider\"\n\nimport log from \"../log\"\nimport type { IChainConnectorDot, SubscriptionCallback } from \"./IChainConnectorDot\"\n\n// errors that require an rpc fallback\n// https://docs.blastapi.io/blast-documentation/things-you-need-to-know/error-reference\nconst BAD_RPC_ERRORS: Record<string, string> = {\n \"-32097\": \"Rate limit exceeded\",\n \"-32098\": \"Capacity exceeded\",\n}\n\nconst RESPONSE_TIMEOUT = 30_000 // max wait for an rpc response (including connection time)\nconst KEEP_ALIVE_INTERVAL = 20_000 // periodic system_health to keep idle sockets alive (ws-provider kills quiet sockets after its 40s heartbeat)\n/**\n * How long a connection stays open once its last user releases it. A one-off request is\n * often followed by more traffic to the same chain (balances read the runtime version,\n * then subscribe to storage), which then reuses the socket instead of opening a new one.\n */\nconst IDLE_CLOSE_DELAY = 30_000\n\n/** in-flight requests reject with DestroyedError when a connection is torn down - expected, not worth logging */\nconst isDestroyedError = (error: unknown): boolean =>\n error instanceof Error && error.name === \"DestroyedError\"\nconst STALE_NOTIFY_TIMEOUT = 30_000 // how long a chain can be disconnected before subscribers are notified\n\nexport class ChainConnectionError extends Error {\n type: \"CHAIN_CONNECTION_ERROR\"\n chainId: string\n\n constructor(chainId: string, options?: ErrorOptions) {\n super(`Unable to connect to chain ${chainId}`, options)\n\n this.type = \"CHAIN_CONNECTION_ERROR\"\n this.chainId = chainId\n }\n}\n\n/**\n * Passed to subscription callbacks when the chain has been unreachable for a while. Not\n * terminal: the subscription stays registered and is re-issued when a socket connects.\n */\nexport class StaleRpcError extends Error {\n type: \"STALE_RPC_ERROR\"\n chainId: string\n\n constructor(chainId: string, options?: ErrorOptions) {\n super(`RPCs are stale/unavailable for chain ${chainId}`, options)\n\n this.type = \"STALE_RPC_ERROR\"\n this.chainId = chainId\n }\n}\n\ntype SocketUserId = number\n\ntype Subscription = {\n subscribeMethod: string\n params: unknown[]\n callback: SubscriptionCallback\n /** cancels the pending subscribe request, if any */\n cancelRequest: (() => void) | null\n /** stops routing notifications to the callback */\n stopFollow: (() => void) | null\n serverSubId: string | number | null\n unsubscribed: boolean\n}\n\ntype Connection = {\n chainId: DotNetworkId\n provider: WsJsonRpcProvider\n client: SubstrateClient\n users: Set<SocketUserId>\n subscriptions: Set<Subscription>\n wasConnected: boolean\n keepAliveInterval: ReturnType<typeof setInterval> | null\n staleTimeout: ReturnType<typeof setTimeout> | null\n /** closes the connection once it has had no users for IDLE_CLOSE_DELAY */\n idleTimeout: ReturnType<typeof setTimeout> | null\n}\n\nexport type ChainConnectorDotOptions = {\n /**\n * How long a new socket may take to open before the provider gives up on the endpoint\n * and tries the next one. Defaults to polkadot-api's 5 seconds. A slow device or\n * network can take longer than that to connect while it is busy, as a phone app is\n * at startup, and every endpoint then times out in turn.\n */\n connectionTimeout?: number\n}\n\n/**\n * ChainConnector provides an interface similar to a websocket JSON-RPC provider, but with three points of difference:\n *\n * 1. ChainConnector methods all accept a `chainId` instead of an array of RPCs. RPCs are then fetched internally from chaindata.\n * 2. ChainConnector creates only one socket connection per chain (via polkadot-api's ws-provider, which handles\n * endpoint rotation, reconnection and stale-socket detection) and ensures that all downstream requests to a chain\n * share that connection.\n * 3. Subscriptions return a callable `unsubscribe` method instead of an id, and are automatically re-established\n * when the provider reconnects (possibly to another endpoint).\n *\n * Additionally, when run on the clientside of a dapp where `window.talismanSub` is available, instead of spinning up new websocket\n * connections this class will forward all requests through to the wallet backend - where another instance of this class will\n * handle the websocket connections.\n */\nexport class ChainConnectorDot implements IChainConnectorDot {\n #chaindataChainProvider: IChaindataNetworkProvider\n #connectionTimeout: number | undefined\n\n #connections: Record<DotNetworkId, Connection> = {}\n #pendingConnections: Record<DotNetworkId, Promise<Connection>> = {}\n\n constructor(\n chaindataChainProvider: IChaindataNetworkProvider,\n options?: ChainConnectorDotOptions\n ) {\n this.#chaindataChainProvider = chaindataChainProvider\n this.#connectionTimeout = options?.connectionTimeout\n }\n\n // biome-ignore lint/suspicious/noExplicitAny: legacy\n async send<T = any>(\n chainId: DotNetworkId,\n method: string,\n params: unknown[],\n _isCacheable?: boolean | undefined,\n extraOptions?: {\n /**\n * Set to `true` if this query is speculative, i.e. if on some chains it's expected that it will raise a wasm unreachable error of the form:\n *\n * 4003: Client error: Execution failed: Execution aborted due to trap: wasm trap: wasm `unreachable` instruction executed\n *\n * By setting expectErrors to true, this method won't pollute the logs with errors we intend to have happen.\n * An example use case of this is when you plan to catch the wasm unreachable error on chains that don't support the query, and then fall back\n * to another query or perhaps an empty result.\n */\n expectErrors?: boolean\n }\n ): Promise<T> {\n const talismanSub = this.getTalismanSub()\n if (talismanSub !== undefined) {\n try {\n const genesisHash = await this.getGenesisHash(chainId)\n return await talismanSub.send(genesisHash, method, params)\n } catch (error) {\n log.warn(\n `Failed to make wallet-proxied send request for chain ${chainId}. Falling back to plain websocket`,\n error\n )\n }\n }\n\n let socketUserId: SocketUserId\n let connection: Connection\n try {\n ;[socketUserId, connection] = await this.acquireConnection(chainId)\n } catch (error) {\n throw new StaleRpcError(chainId, { cause: error })\n }\n\n try {\n return await this.request<T>(connection, method, params)\n } catch (err) {\n const error = err as (Error & { code?: number; data?: unknown }) | null\n\n if (error?.message === \"TIMEOUT\") {\n log.error(`ChainConnector timeout`, { chainId, error })\n connection.provider.switch()\n throw new Error(\"Timeout\")\n }\n\n const badRpcError = BAD_RPC_ERRORS[error?.code?.toString() ?? \"\"]\n if (badRpcError) {\n log.error(`ChainConnector ${badRpcError}`, { error, chainId })\n connection.provider.switch()\n throw new Error(badRpcError)\n }\n\n if (!extraOptions?.expectErrors)\n log.error(\n `Failed to send ${method} on chain ${chainId}\\nparams: ${JSON.stringify(params)}`,\n {\n error,\n }\n )\n\n throw error\n } finally {\n this.releaseConnection(chainId, socketUserId)\n }\n }\n\n async subscribe(\n chainId: DotNetworkId,\n subscribeMethod: string,\n responseMethod: string,\n params: unknown[],\n callback: SubscriptionCallback,\n timeout: number | false = 30_000 // 30 seconds in milliseconds\n ): Promise<(unsubscribeMethod: string) => void> {\n const talismanSub = this.getTalismanSub()\n if (talismanSub !== undefined) {\n try {\n const genesisHash = await this.getGenesisHash(chainId)\n\n const subscriptionId = await talismanSub.subscribe(\n genesisHash,\n subscribeMethod,\n responseMethod,\n params,\n callback,\n timeout\n )\n\n return (unsubscribeMethod: string) =>\n talismanSub.unsubscribe(subscriptionId, unsubscribeMethod)\n } catch (error) {\n log.warn(\n `Failed to create wallet-proxied subscription for chain ${chainId}. Falling back to plain websocket`,\n error\n )\n }\n }\n\n let socketUserId: SocketUserId\n let connection: Connection\n try {\n ;[socketUserId, connection] = await this.acquireConnection(chainId)\n } catch (error) {\n throw new StaleRpcError(chainId, { cause: error })\n }\n\n const subscription: Subscription = {\n subscribeMethod,\n params,\n callback,\n cancelRequest: null,\n stopFollow: null,\n serverSubId: null,\n unsubscribed: false,\n }\n connection.subscriptions.add(subscription)\n\n // if the chain can't be reached at all, let the caller know after a while (the provider keeps retrying)\n if (timeout && !connection.wasConnected) {\n const staleWarning = setTimeout(() => {\n if (!subscription.unsubscribed && !connection.wasConnected)\n callback(new StaleRpcError(chainId), null)\n }, timeout)\n const clear = () => clearTimeout(staleWarning)\n // piggyback on the follow setup to clear the warning once anything happens\n const originalCallback = subscription.callback\n subscription.callback = (error, result) => {\n clear()\n subscription.callback = originalCallback\n originalCallback(error, result)\n }\n }\n\n this.startSubscription(connection, subscription)\n\n return (unsubscribeMethod: string) => {\n if (subscription.unsubscribed) return\n subscription.unsubscribed = true\n\n subscription.cancelRequest?.()\n subscription.stopFollow?.()\n\n // the connection may have been replaced by a reset() since we subscribed. It stays\n // open for a while after its last user leaves, so unsubscribe on the server even then\n const current = this.#connections[chainId]\n if (subscription.serverSubId !== null && current)\n try {\n current.client.request(unsubscribeMethod, [subscription.serverSubId]).catch((error) => {\n if (!isDestroyedError(error)) log.warn(`Failed to unsubscribe from ${chainId}`, error)\n })\n } catch (error) {\n if (!isDestroyedError(error)) log.warn(`Failed to unsubscribe from ${chainId}`, error)\n }\n\n current?.subscriptions.delete(subscription)\n this.releaseConnection(chainId, socketUserId)\n }\n }\n\n /**\n * Kills and recreates the connection for a chain, if any.\n * Useful after changing a network's rpcs to make sure the new list is applied for further requests.\n * Active subscriptions are automatically re-established on the new connection.\n */\n async reset(chainId: DotNetworkId) {\n log.info(\"ChainConnector reset\", chainId)\n const connection = this.#connections[chainId]\n if (!connection) return\n\n this.destroyConnection(connection)\n delete this.#connections[chainId]\n\n // recreate a connection for the active subscriptions, if any\n if (connection.subscriptions.size) {\n try {\n const fresh = await this.createConnection(chainId)\n fresh.users = connection.users\n fresh.subscriptions = connection.subscriptions\n this.#connections[chainId] = fresh\n for (const subscription of fresh.subscriptions) this.startSubscription(fresh, subscription)\n } catch (error) {\n log.warn(`Failed to recreate connection for ${chainId} after reset`, error)\n // not a StaleRpcError: no connection is left to re-issue these subscriptions,\n // so subscribers must treat this one as terminal\n for (const subscription of connection.subscriptions)\n subscription.callback(new ChainConnectionError(chainId, { cause: error }), null)\n }\n }\n }\n\n /** Sends a request over a connection, throwing `Error(\"TIMEOUT\")` if no response arrives in time */\n private request<T>(\n connection: Connection,\n method: string,\n params: unknown[],\n timeoutMs = RESPONSE_TIMEOUT\n ): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n const timer = setTimeout(() => {\n cancel()\n reject(new Error(\"TIMEOUT\"))\n }, timeoutMs)\n\n const cancel = connection.client._request<T, unknown>(method, params, {\n onSuccess: (result) => {\n clearTimeout(timer)\n resolve(result)\n },\n onError: (error) => {\n clearTimeout(timer)\n reject(error)\n },\n })\n })\n }\n\n /** Issues the subscribe request and routes notifications to the subscription callback */\n private startSubscription(connection: Connection, subscription: Subscription) {\n subscription.serverSubId = null\n subscription.stopFollow = null\n\n subscription.cancelRequest = connection.client._request<string | number, unknown>(\n subscription.subscribeMethod,\n subscription.params,\n {\n onSuccess: (serverSubId, follow) => {\n subscription.cancelRequest = null\n if (subscription.unsubscribed) return\n\n subscription.serverSubId = serverSubId\n // raw-client matches notifications by the raw (not stringified) subscription id, but types it as string\n subscription.stopFollow = follow(serverSubId as string, {\n next: (result) => subscription.callback(null, result),\n error: (error) => subscription.callback(error, null),\n })\n },\n onError: (error) => {\n subscription.cancelRequest = null\n if (!subscription.unsubscribed) subscription.callback(error, null)\n },\n }\n )\n }\n\n /**\n * Get (or create) the shared connection for a chain.\n *\n * The caller must call releaseConnection with the returned SocketUserId once they are finished with it.\n */\n private async acquireConnection(chainId: DotNetworkId): Promise<[SocketUserId, Connection]> {\n // a single creation promise per chain guarantees that concurrent callers share the same connection\n let connection = this.#connections[chainId]\n if (!connection) {\n if (!this.#pendingConnections[chainId]) {\n this.#pendingConnections[chainId] = this.createConnection(chainId)\n .then((created) => {\n this.#connections[chainId] = created\n return created\n })\n .finally(() => {\n delete this.#pendingConnections[chainId]\n })\n }\n connection = await this.#pendingConnections[chainId]\n }\n\n if (connection.idleTimeout) {\n clearTimeout(connection.idleTimeout)\n connection.idleTimeout = null\n }\n const socketUserId = this.getExclusiveRandomId([...connection.users])\n connection.users.add(socketUserId)\n\n return [socketUserId, connection]\n }\n\n private async createConnection(chainId: DotNetworkId): Promise<Connection> {\n const chain = await this.#chaindataChainProvider.getNetworkById(chainId, \"polkadot\")\n if (!chain) throw new Error(`Chain ${chainId} not found in store`)\n\n const rpcs = chain.rpcs.concat()\n if (!rpcs.length) throw new Error(`No healthy RPCs available for chain ${chainId}`)\n\n // will be assigned below - the provider config needs to reference the connection\n let connection: Connection = null as unknown as Connection\n\n const provider = getWsProvider(rpcs, {\n onStatusChanged: (status: StatusChange) => this.handleStatusChange(connection, status),\n ...(this.#connectionTimeout !== undefined && { timeout: this.#connectionTimeout }),\n })\n\n const client = createClient(provider)\n\n connection = {\n chainId,\n provider,\n client,\n users: new Set(),\n subscriptions: new Set(),\n wasConnected: false,\n keepAliveInterval: null,\n staleTimeout: null,\n idleTimeout: null,\n }\n\n return connection\n }\n\n private handleStatusChange(connection: Connection, status: StatusChange) {\n // connection is still being constructed on the initial CONNECTING event\n if (!connection) return\n // ignore events from a connection that has been reset/destroyed\n if (this.#connections[connection.chainId] !== connection) return\n\n if (status.type === WsEvent.CONNECTED) {\n if (connection.staleTimeout) {\n clearTimeout(connection.staleTimeout)\n connection.staleTimeout = null\n }\n\n const isReconnect = connection.wasConnected\n connection.wasConnected = true\n\n // periodically send a request to keep the socket alive when there is no other traffic\n if (connection.keepAliveInterval) clearInterval(connection.keepAliveInterval)\n connection.keepAliveInterval = setInterval(() => {\n this.request(connection, \"system_health\", [], KEEP_ALIVE_INTERVAL).catch((error) => {\n if (!isDestroyedError(error))\n log.warn(`Failed keep-alive for socket ${connection.chainId}`, error)\n })\n }, KEEP_ALIVE_INTERVAL)\n\n // server-side subscriptions died with the previous socket : re-establish them\n // (skip author_* subscriptions : resubmitting an extrinsic is not safe)\n if (isReconnect)\n for (const subscription of connection.subscriptions) {\n if (subscription.unsubscribed) continue\n if (subscription.subscribeMethod.startsWith(\"author_\")) continue\n subscription.stopFollow?.()\n subscription.cancelRequest?.()\n this.startSubscription(connection, subscription)\n }\n } else {\n if (connection.keepAliveInterval) {\n clearInterval(connection.keepAliveInterval)\n connection.keepAliveInterval = null\n }\n\n // notify subscribers if the chain stays unreachable for too long\n if (!connection.staleTimeout && connection.subscriptions.size) {\n connection.staleTimeout = setTimeout(() => {\n connection.staleTimeout = null\n for (const subscription of connection.subscriptions)\n if (!subscription.unsubscribed)\n subscription.callback(new StaleRpcError(connection.chainId), null)\n }, STALE_NOTIFY_TIMEOUT)\n }\n }\n }\n\n private releaseConnection(chainId: DotNetworkId, socketUserId: SocketUserId): void {\n const connection = this.#connections[chainId]\n if (!connection) return\n\n connection.users.delete(socketUserId)\n if (connection.users.size > 0 || connection.idleTimeout) return\n\n connection.idleTimeout = setTimeout(() => {\n connection.idleTimeout = null\n if (connection.users.size > 0 || this.#connections[chainId] !== connection) return\n this.destroyConnection(connection)\n delete this.#connections[chainId]\n }, IDLE_CLOSE_DELAY)\n }\n\n private destroyConnection(connection: Connection): void {\n if (connection.keepAliveInterval) clearInterval(connection.keepAliveInterval)\n if (connection.staleTimeout) clearTimeout(connection.staleTimeout)\n if (connection.idleTimeout) clearTimeout(connection.idleTimeout)\n connection.keepAliveInterval = null\n connection.staleTimeout = null\n connection.idleTimeout = null\n\n // detach subscriptions before destroying the client so their callbacks don't receive a DestroyedError\n for (const subscription of connection.subscriptions) {\n subscription.stopFollow?.()\n subscription.cancelRequest?.()\n subscription.stopFollow = null\n subscription.cancelRequest = null\n subscription.serverSubId = null\n }\n\n try {\n connection.client.destroy()\n } catch (error) {\n log.warn(`Error occurred destroying connection ${connection.chainId}`, error)\n }\n }\n\n private async getGenesisHash(chainId: DotNetworkId): Promise<string> {\n const chain = await this.#chaindataChainProvider.getNetworkById(chainId, \"polkadot\")\n if (!chain) throw new Error(`Chain ${chainId} not found in store`)\n\n const { genesisHash } = chain\n if (typeof genesisHash !== \"string\")\n throw new Error(`Chain ${chainId} has no genesisHash in store`)\n\n return genesisHash\n }\n\n /** continues to generate a random number until it finds one which is not present in the exclude list */\n private getExclusiveRandomId(exclude: number[] = []): number {\n let id = this.getRandomId()\n while (exclude.includes(id)) {\n id = this.getRandomId()\n }\n return id\n }\n /** generates a random number */\n private getRandomId(): number {\n return Math.trunc(Math.random() * 10 ** 8)\n }\n\n private getTalismanSub() {\n // biome-ignore lint/suspicious/noExplicitAny: legacy\n const talismanSub = typeof window !== \"undefined\" && (window as any).talismanSub\n\n // biome-ignore lint/complexity/noBannedTypes: legacy\n const rpcByGenesisHashSend: Function | undefined = talismanSub?.rpcByGenesisHashSend\n // biome-ignore lint/complexity/noBannedTypes: legacy\n const rpcByGenesisHashSubscribe: Function | undefined = talismanSub?.rpcByGenesisHashSubscribe\n // biome-ignore lint/complexity/noBannedTypes: legacy\n const rpcByGenesisHashUnsubscribe: Function | undefined =\n talismanSub?.rpcByGenesisHashUnsubscribe\n\n if (typeof rpcByGenesisHashSend !== \"function\") return\n if (typeof rpcByGenesisHashSubscribe !== \"function\") return\n if (typeof rpcByGenesisHashUnsubscribe !== \"function\") return\n\n return {\n // biome-ignore lint/suspicious/noExplicitAny: legacy\n send: <T = any>(genesisHash: string, method: string, params: unknown[]): Promise<T> =>\n rpcByGenesisHashSend(genesisHash, method, params),\n\n subscribe: (\n genesisHash: string,\n subscribeMethod: string,\n responseMethod: string,\n params: unknown[],\n callback: SubscriptionCallback,\n timeout: number | false\n ): Promise<string> =>\n rpcByGenesisHashSubscribe(\n genesisHash,\n subscribeMethod,\n responseMethod,\n params,\n callback,\n timeout\n ),\n\n unsubscribe: (subscriptionId: string, unsubscribeMethod: string): Promise<void> =>\n rpcByGenesisHashUnsubscribe(subscriptionId, unsubscribeMethod),\n }\n }\n}\n","import type { DotNetworkId } from \"@talismn/chaindata-provider\"\n\nimport log from \"../log\"\nimport { StaleRpcError } from \"./ChainConnectorDot\"\nimport type { IChainConnectorDot, SubscriptionCallback } from \"./IChainConnectorDot\"\n\nconst RESPONSE_TIMEOUT = 30_000\nconst FAILURES_BEFORE_FIRST_RESULT = 3\n\ntype HexString = `0x${string}`\ntype StorageChanges = { block: HexString; changes: [HexString, HexString | null][] }\n\n/** The parts of a polkadot-api `PolkadotClient` that the connector uses */\nexport type PapiClient = {\n /** `PolkadotClient` types it without `abortSignal`, but it is substrate-client's `request`, which honours it */\n _request: <Reply>(method: string, params: unknown[], abortSignal?: AbortSignal) => Promise<Reply>\n bestBlocks$: {\n subscribe: (observer: {\n next: (blocks: { hash: string }[]) => void\n error: (error: unknown) => void\n complete: () => void\n }) => { unsubscribe: () => void }\n }\n}\n\n/**\n * Runs `@talismn/balances` over a dapp's polkadot-api clients, so the dapp and its balances share one socket per chain.\n *\n * `state_subscribeStorage` is the only subscription balances uses. It is served by querying the keys at each new\n * best block and reporting the values that changed, like the node does. One query runs at a time, for the latest\n * best block. A failed query is retried at the next block, because balances treats a subscription error as final\n * and would stop updating that network. Only when the first three queries fail does the subscription report the error.\n */\nexport class ChainConnectorDotPapi implements IChainConnectorDot {\n #clientFor: (networkId: DotNetworkId) => PapiClient | undefined\n\n constructor(clientFor: (networkId: DotNetworkId) => PapiClient | undefined) {\n this.#clientFor = clientFor\n }\n\n async send<T = unknown>(networkId: DotNetworkId, method: string, params: unknown[]): Promise<T> {\n return requestWithTimeout<T>(this.getClient(networkId), method, params, new AbortController())\n }\n\n async subscribe(\n networkId: DotNetworkId,\n subscribeMethod: string,\n _responseMethod: string,\n params: unknown[],\n callback: SubscriptionCallback,\n timeout: number | false = 30_000\n ): Promise<(unsubscribeMethod: string) => void> {\n const client = this.getClient(networkId)\n if (subscribeMethod !== \"state_subscribeStorage\")\n throw new Error(`ChainConnectorDotPapi does not support ${subscribeMethod}`)\n\n const [keys] = params as [HexString[]]\n const values = new Map<HexString, HexString | null>()\n let bestBlockHash: string | undefined\n let queriedBlockHash: string | undefined\n let inFlight: AbortController | undefined\n let delivered = false\n let failures = 0\n let active = true\n let subscription: { unsubscribe: () => void } | undefined\n const staleTimer = timeout\n ? setTimeout(() => callback(new StaleRpcError(networkId), null), timeout)\n : undefined\n\n const stop = () => {\n active = false\n clearTimeout(staleTimer)\n inFlight?.abort()\n subscription?.unsubscribe()\n }\n\n const finish = (error: Error) => {\n if (!active) return\n stop()\n callback(error, null)\n }\n\n const reportChanges = (result: StorageChanges) => {\n const changes = result.changes.filter(([key, value]) => values.get(key) !== value)\n for (const [key, value] of changes) values.set(key, value)\n if (!changes.length) return\n\n delivered = true\n clearTimeout(staleTimer)\n callback(null, { block: result.block, changes })\n }\n\n const reportFailure = (error: Error) => {\n if (delivered || ++failures < FAILURES_BEFORE_FIRST_RESULT)\n return log.warn(\n `state_queryStorageAt failed on ${networkId}, retrying at the next block`,\n error\n )\n finish(error)\n }\n\n const queryBestBlock = async () => {\n if (!active || inFlight || !bestBlockHash || bestBlockHash === queriedBlockHash) return\n const blockHash = bestBlockHash\n queriedBlockHash = blockHash\n const controller = new AbortController()\n inFlight = controller\n\n try {\n const [result] = await requestWithTimeout<StorageChanges[]>(\n client,\n \"state_queryStorageAt\",\n [keys, blockHash],\n controller\n )\n if (!active) return\n if (!result) throw new Error(`Empty state_queryStorageAt response on ${networkId}`)\n reportChanges(result)\n } catch (error) {\n if (active) reportFailure(error as Error)\n } finally {\n if (inFlight === controller) inFlight = undefined\n queryBestBlock()\n }\n }\n\n try {\n subscription = client.bestBlocks$.subscribe({\n next: ([best]) => {\n bestBlockHash = best?.hash\n queryBestBlock()\n },\n error: (error) => finish(error as Error),\n complete: () =>\n finish(new Error(`polkadot-api client for ${networkId} stopped following blocks`)),\n })\n } catch (error) {\n stop()\n throw error\n }\n if (!active) subscription.unsubscribe()\n\n return stop\n }\n\n async reset() {}\n\n private getClient(networkId: DotNetworkId): PapiClient {\n const client = this.#clientFor(networkId)\n if (!client) throw new Error(`No polkadot-api client for network ${networkId}`)\n return client\n }\n}\n\n/** rejects on its own timer too, so a client that ignores the abort signal cannot hang the caller */\nconst requestWithTimeout = <T>(\n client: PapiClient,\n method: string,\n params: unknown[],\n controller: AbortController\n) =>\n new Promise<T>((resolve, reject) => {\n const timer = setTimeout(() => {\n controller.abort()\n reject(new Error(\"Timeout\"))\n }, RESPONSE_TIMEOUT)\n try {\n client\n ._request<T>(method, params, controller.signal)\n .then(resolve, reject)\n .finally(() => clearTimeout(timer))\n } catch (error) {\n clearTimeout(timer)\n reject(error)\n }\n })\n","import { createClient, type SubstrateClient } from \"@polkadot-api/substrate-client\"\nimport { getWsProvider } from \"@polkadot-api/ws-provider\"\nimport type { DotNetwork, DotNetworkId } from \"@talismn/chaindata-provider\"\nimport { throwAfter } from \"@talismn/util\"\n\nimport type { IChainConnectorDot, SubscriptionCallback } from \"./IChainConnectorDot\"\n\nconst TIMEOUT = 10_000\n\nexport class ChainConnectorDotStub implements IChainConnectorDot {\n #client: SubstrateClient\n\n constructor(network: DotNetwork) {\n this.#client = createClient(getWsProvider(network.rpcs.concat()))\n }\n\n async send<T = unknown>(\n _chainId: DotNetworkId,\n method: string,\n params: unknown[],\n _isCacheable?: boolean\n ): Promise<T> {\n return await Promise.race([\n this.#client.request<T>(method, params),\n throwAfter(TIMEOUT, `Request ${method} timed out after ${TIMEOUT}ms`),\n ])\n }\n\n async subscribe(\n _chainId: DotNetworkId,\n subscribeMethod: string,\n _responseMethod: string,\n params: unknown[],\n callback: SubscriptionCallback,\n timeout?: number | false\n ): Promise<(unsubscribeMethod: string) => void> {\n let stopFollow: (() => void) | null = null\n let unsubscribed = false\n\n const serverSubId = await Promise.race([\n new Promise<string | number>((resolve, reject) => {\n this.#client._request<string | number, unknown>(subscribeMethod, params, {\n onSuccess: (subId, follow) => {\n stopFollow = follow(subId as string, {\n next: (result) => callback(null, result),\n error: (error) => callback(error, null),\n })\n resolve(subId)\n },\n onError: reject,\n })\n }),\n throwAfter(timeout || TIMEOUT, `Subscription timed out after ${timeout || TIMEOUT}ms`),\n ])\n\n return (unsubscribeMethod: string) => {\n if (unsubscribed) return\n unsubscribed = true\n stopFollow?.()\n this.#client.request(unsubscribeMethod, [serverSubId]).catch(() => {}) // connection may already be gone\n }\n }\n\n reset(): Promise<void> {\n throw new Error(\"ChainConnectorDotStub does not implement reset\")\n }\n\n destroy() {\n this.#client.destroy()\n }\n}\n","import type { EthNetwork, EthNetworkId } from \"@talismn/chaindata-provider\"\nimport { camelCase, fromPairs, toPairs } from \"lodash-es\"\nimport type { Chain, ChainContract } from \"viem\"\nimport * as viemChains from \"viem/chains\"\n\n// exclude zoraTestnet which uses Hyperliquid's chain id\nconst { zoraTestnet, ...validViemChains } = viemChains\n\n// viem chains benefit from multicall config & other viem goodies\nconst VIEM_CHAINS = Object.keys(validViemChains).reduce(\n (acc, curr) => {\n const chain = validViemChains[curr as keyof typeof validViemChains]\n acc[chain.id] = chain\n return acc\n },\n {} as Record<number, Chain>\n)\n\nconst chainsCache = new Map<string, Chain>()\n\nexport const clearChainsCache = (networkId?: EthNetworkId) => {\n if (networkId) chainsCache.delete(networkId)\n else chainsCache.clear()\n}\n\nexport const getChainFromEvmNetwork = (network: EthNetwork): Chain => {\n const { symbol, decimals } = network.nativeCurrency\n\n if (!chainsCache.has(network.id)) {\n const chainRpcs = network.rpcs ?? []\n\n const viemChain = VIEM_CHAINS[Number(network.id)] ?? {}\n\n const chain: Chain = {\n ...viemChain,\n id: Number(network.id),\n name: network.name ?? `Ethereum Chain ${network.id}`,\n rpcUrls: {\n public: { http: chainRpcs },\n default: { http: chainRpcs },\n },\n nativeCurrency: {\n symbol,\n decimals,\n name: symbol,\n },\n contracts: {\n ...viemChain.contracts,\n ...(network.contracts\n ? fromPairs(\n toPairs(network.contracts).map(([name, address]): [string, ChainContract] => [\n camelCase(name),\n { address },\n ])\n )\n : {}),\n },\n }\n\n chainsCache.set(network.id, chain)\n }\n\n return chainsCache.get(network.id) as Chain\n}\n","import type { EthNetwork } from \"@talismn/chaindata-provider\"\nimport { fallback, http, shouldThrow } from \"viem\"\n\nexport type TransportOptions = {\n batch?:\n | boolean\n | {\n batchSize?: number | undefined\n wait?: number | undefined\n }\n}\n\n// Frontier nodes report reverts with a message viem does not recognize, which makes fallback retry every rpc\nconst FRONTIER_EXECUTION_ERROR = /VM Exception while processing transaction/\n\nconst isFinalError = (error: Error) =>\n shouldThrow(error) || FRONTIER_EXECUTION_ERROR.test(error.message)\n\nexport const getTransportForEvmNetwork = (\n evmNetwork: EthNetwork,\n options: TransportOptions = {}\n) => {\n if (!evmNetwork.rpcs?.length) throw new Error(\"No RPCs found for EVM network\")\n\n const { batch } = options\n\n return fallback(\n evmNetwork.rpcs.map((url) => http(url, { batch, retryCount: 0 })),\n { retryCount: 0, shouldThrow: isFinalError }\n )\n}\n","import type { EthNetwork } from \"@talismn/chaindata-provider\"\nimport { createPublicClient, type PublicClient } from \"viem\"\n\nimport { clearChainsCache, getChainFromEvmNetwork } from \"./getChainFromEvmNetwork\"\nimport { getTransportForEvmNetwork, type TransportOptions } from \"./getTransportForEvmNetwork\"\n\nconst MUTLICALL_BATCH_WAIT = 25\nconst MUTLICALL_BATCH_SIZE = 100\n\nconst HTTP_BATCH_WAIT = 25\nconst HTTP_BATCH_SIZE_WITH_MULTICALL = 10\nconst HTTP_BATCH_SIZE_WITHOUT_MULTICALL = 30\n\n// cache to reuse previously created public clients\nconst publicClientCache = new Map<string, PublicClient>()\n\nexport const clearPublicClientCache = (evmNetworkId?: string) => {\n clearChainsCache(evmNetworkId)\n\n if (evmNetworkId) publicClientCache.delete(evmNetworkId)\n else publicClientCache.clear()\n}\n\nexport const getEvmNetworkPublicClient = (network: EthNetwork): PublicClient => {\n const chain = getChainFromEvmNetwork(network)\n\n if (!publicClientCache.has(network.id)) {\n if (!network.rpcs.length) throw new Error(\"No RPCs found for Ethereum network\")\n\n const batch = chain.contracts?.multicall3\n ? { multicall: { wait: MUTLICALL_BATCH_WAIT, batchSize: MUTLICALL_BATCH_SIZE } }\n : undefined\n\n const transportOptions: TransportOptions = {\n batch: {\n batchSize: chain.contracts?.multicall3\n ? HTTP_BATCH_SIZE_WITH_MULTICALL\n : HTTP_BATCH_SIZE_WITHOUT_MULTICALL,\n wait: HTTP_BATCH_WAIT,\n },\n }\n\n const transport = getTransportForEvmNetwork(network, transportOptions)\n\n publicClientCache.set(\n network.id,\n createPublicClient({\n chain,\n transport,\n batch,\n })\n )\n }\n\n return publicClientCache.get(network.id) as PublicClient\n}\n","import type { EthNetwork } from \"@talismn/chaindata-provider\"\nimport { type Account, createWalletClient, type WalletClient } from \"viem\"\n\nimport { getChainFromEvmNetwork } from \"./getChainFromEvmNetwork\"\nimport { getTransportForEvmNetwork } from \"./getTransportForEvmNetwork\"\n\ntype WalletClientOptions = {\n account?: `0x${string}` | Account\n}\n\nexport const getEvmNetworkWalletClient = (\n network: EthNetwork,\n options: WalletClientOptions = {}\n): WalletClient => {\n const chain = getChainFromEvmNetwork(network)\n\n const transport = getTransportForEvmNetwork(network)\n\n return createWalletClient({ chain, transport, account: options.account })\n}\n","import type {\n EthNetworkId,\n IChaindataNetworkProvider,\n IChaindataTokenProvider,\n} from \"@talismn/chaindata-provider\"\nimport type { Account, PublicClient, WalletClient } from \"viem\"\n\nimport { clearPublicClientCache, getEvmNetworkPublicClient } from \"./getEvmNetworkPublicClient\"\nimport { getEvmNetworkWalletClient } from \"./getEvmNetworkWalletClient\"\nimport type { IChainConnectorEth } from \"./IChainConnectorEth\"\n\nexport class ChainConnectorEth implements IChainConnectorEth {\n #chaindataProvider: IChaindataNetworkProvider & IChaindataTokenProvider\n\n constructor(chaindataProvider: IChaindataNetworkProvider & IChaindataTokenProvider) {\n this.#chaindataProvider = chaindataProvider\n }\n\n async getPublicClientForEvmNetwork(evmNetworkId: EthNetworkId): Promise<PublicClient | null> {\n const network = await this.#chaindataProvider.getNetworkById(evmNetworkId, \"ethereum\")\n if (!network) return null\n\n return getEvmNetworkPublicClient(network)\n }\n\n async getWalletClientForEvmNetwork(\n evmNetworkId: EthNetworkId,\n account?: `0x${string}` | Account\n ): Promise<WalletClient | null> {\n const network = await this.#chaindataProvider.getNetworkById(evmNetworkId, \"ethereum\")\n if (!network) return null\n\n return getEvmNetworkWalletClient(network, { account })\n }\n\n public clearRpcProvidersCache(evmNetworkId?: EthNetworkId) {\n clearPublicClientCache(evmNetworkId)\n }\n}\n","import type { EthNetwork, EthNetworkId } from \"@talismn/chaindata-provider\"\nimport type { Account, PublicClient, WalletClient } from \"viem\"\n\nimport { getEvmNetworkPublicClient } from \"./getEvmNetworkPublicClient\"\nimport { getEvmNetworkWalletClient } from \"./getEvmNetworkWalletClient\"\nimport type { IChainConnectorEth } from \"./IChainConnectorEth\"\n\nexport class ChainConnectorEthStub implements IChainConnectorEth {\n #network: EthNetwork\n\n constructor(network: EthNetwork) {\n this.#network = network\n }\n\n async getPublicClientForEvmNetwork(): Promise<PublicClient | null> {\n return getEvmNetworkPublicClient(this.#network)\n }\n\n async getWalletClientForEvmNetwork(\n _networkId: EthNetworkId,\n account?: `0x${string}` | Account\n ): Promise<WalletClient | null> {\n return getEvmNetworkWalletClient(this.#network, { account })\n }\n\n clearRpcProvidersCache(): void {\n // No-op for stub\n }\n}\n","import type { Rpc, RpcTransport, SolanaRpcApi } from \"@solana/kit\"\nimport { createDefaultRpcTransport, createSolanaRpcFromTransport, isSolanaError } from \"@solana/kit\"\nimport type { SolNetworkId } from \"@talismn/chaindata-provider\"\n\nexport type SolRpc = Rpc<SolanaRpcApi>\n\n// Public Solana RPC nodes rate-limit aggressively with HTTP 429. kit's default transport is\n// single-shot, unlike the old web3.js `Connection` which retried 429 up to 5x with backoff, so a\n// single 429 would fail an otherwise-valid request (e.g. a user's transaction submission, or token\n// discovery silently returning no tokens). This wrapper restores that behaviour.\nconst MAX_429_RETRIES = 5\nconst BASE_BACKOFF_MS = 500\n\ntype HttpErrorContext = { statusCode?: number; headers?: Headers }\n\nconst getRateLimitContext = (error: unknown): HttpErrorContext | null => {\n if (!isSolanaError(error)) return null\n\n const context = error.context as HttpErrorContext\n return context.statusCode === 429 ? context : null\n}\n\n/** Returns the delay to wait before retrying, or `null` if the error is not a retryable 429. */\nconst get429RetryDelay = (error: unknown, attempt: number): number | null => {\n const context = getRateLimitContext(error)\n if (!context) return null\n\n // honour the server's Retry-After header (delta-seconds) when present\n const retryAfter = Number(context.headers?.get(\"retry-after\"))\n if (Number.isFinite(retryAfter) && retryAfter > 0) return retryAfter * 1000\n\n // otherwise exponential backoff: 500ms, 1s, 2s, 4s, 8s\n return BASE_BACKOFF_MS * 2 ** attempt\n}\n\nconst sleep = (ms: number, signal?: AbortSignal): Promise<void> =>\n new Promise((resolve, reject) => {\n if (signal?.aborted) return reject(signal.reason)\n\n const onAbort = () => {\n clearTimeout(timeout)\n reject(signal?.reason)\n }\n const timeout = setTimeout(() => {\n signal?.removeEventListener(\"abort\", onAbort)\n resolve()\n }, ms)\n signal?.addEventListener(\"abort\", onAbort, { once: true })\n })\n\n/**\n * Wraps a transport so HTTP 429 responses are retried with backoff. Solana RPC requests are\n * idempotent (`sendTransaction` is keyed by signature), so replaying a rate-limited request is safe.\n */\nconst withRetryOn429 = (transport: RpcTransport): RpcTransport => {\n const wrapped = async (config: Parameters<RpcTransport>[0]) => {\n for (let attempt = 0; ; attempt++) {\n try {\n return await transport(config)\n } catch (error) {\n const delay = attempt < MAX_429_RETRIES ? get429RetryDelay(error, attempt) : null\n if (delay === null) throw error\n await sleep(delay, config.signal)\n }\n }\n }\n return wrapped as RpcTransport\n}\n\n/**\n * How long a request may wait on an RPC before moving on to the next one. The last RPC tried gets\n * no timeout, so a slow but working node still answers when every other one has failed.\n */\nconst FAILOVER_TIMEOUT_MS = 20_000\n\nconst sendWithTimeout = async <TResponse>(\n transport: RpcTransport,\n config: RpcTransportConfig,\n timeoutMs: number\n): Promise<TResponse> => {\n const controller = new AbortController()\n const onAbort = () => controller.abort(config.signal?.reason)\n config.signal?.addEventListener(\"abort\", onAbort, { once: true })\n const timeout = setTimeout(\n () => controller.abort(new Error(`RPC request timed out after ${timeoutMs}ms`)),\n timeoutMs\n )\n\n try {\n return await transport<TResponse>({ ...config, signal: controller.signal })\n } finally {\n clearTimeout(timeout)\n config.signal?.removeEventListener(\"abort\", onAbort)\n }\n}\n\ntype RpcTransportConfig = Parameters<RpcTransport>[0]\n\nconst isSendTransactionPayload = (\n payload: unknown\n): payload is { method: \"sendTransaction\"; params: unknown[] } =>\n typeof payload === \"object\" &&\n payload !== null &&\n \"method\" in payload &&\n payload.method === \"sendTransaction\" &&\n \"params\" in payload &&\n Array.isArray(payload.params)\n\nconst withoutPreflight = (config: RpcTransportConfig): RpcTransportConfig => {\n if (!isSendTransactionPayload(config.payload)) return config\n\n const [transaction, sendConfig] = config.payload.params\n return {\n ...config,\n payload: {\n ...config.payload,\n params: [transaction, { ...(sendConfig as object | undefined), skipPreflight: true }],\n },\n }\n}\n\nexport type SolTransportOptions = {\n /** Called with the url of the RPC that answered, after every successful request */\n onRpcSuccess?: (url: string) => void\n}\n\n/**\n * Sends each request to one RPC at a time, starting from the one that answered last, and moves on to\n * the next when the request fails. A transport only throws for connection, timeout and HTTP errors:\n * JSON-RPC errors come back in the response body and are returned as is.\n *\n * A failed RPC other than a rate limited one may still have forwarded a transaction. Resending it is\n * safe, as the network processes a signature once, but its preflight simulation on the next RPC\n * could then fail although it landed. So after such a failure, every resend of that transaction,\n * including the retries after a rate limit, skips preflight.\n */\nconst withFailover = (urls: string[], options: SolTransportOptions): RpcTransport => {\n const transports = urls.map((url) => createDefaultRpcTransport({ url }))\n let preferred = 0\n const mayHaveBeenProcessed = new WeakSet<RpcTransportConfig>()\n\n const failover = async <TResponse>(config: RpcTransportConfig): Promise<TResponse> => {\n if (!transports.length) throw new Error(\"No RPCs found for Solana network\")\n\n const start = preferred\n let lastError: unknown\n let rateLimitError: unknown\n for (let attempt = 0; attempt < transports.length; attempt++) {\n config.signal?.throwIfAborted()\n const index = (start + attempt) % transports.length\n const transport = transports[index] as RpcTransport\n const isLastAttempt = attempt === transports.length - 1\n const request = mayHaveBeenProcessed.has(config) ? withoutPreflight(config) : config\n\n try {\n const response = isLastAttempt\n ? await transport<TResponse>(request)\n : await sendWithTimeout<TResponse>(transport, request, FAILOVER_TIMEOUT_MS)\n preferred = index\n options.onRpcSuccess?.(urls[index] as string)\n return response\n } catch (error) {\n if (config.signal?.aborted) throw error\n lastError = error\n if (!getRateLimitContext(error)) mayHaveBeenProcessed.add(config)\n else rateLimitError ??= error\n }\n }\n throw rateLimitError ?? lastError\n }\n return failover as RpcTransport\n}\n\n/**\n * Returns a transport over all of the network's RPCs, in the given order. A request fails over to\n * the next RPC on error, and the RPC that answered is tried first for the next request. When every\n * RPC fails and one of them answered HTTP 429, the whole list is retried with backoff.\n */\nexport const getSolTransport = (\n _networkId: SolNetworkId,\n rpcs: string[],\n options: SolTransportOptions = {}\n): RpcTransport => {\n return withRetryOn429(withFailover(rpcs, options))\n}\n\nexport const getSolRpc = (\n networkId: SolNetworkId,\n rpcs: string[],\n options?: SolTransportOptions\n): SolRpc => createSolanaRpcFromTransport(getSolTransport(networkId, rpcs, options))\n","import type { RpcTransport } from \"@solana/kit\"\nimport { createSolanaRpcFromTransport } from \"@solana/kit\"\nimport type {\n IChaindataNetworkProvider,\n IChaindataTokenProvider,\n SolNetworkId,\n} from \"@talismn/chaindata-provider\"\n\nimport type { SolRpc } from \"./getSolRpc\"\nimport { getSolTransport } from \"./getSolRpc\"\nimport type { IChainConnectorSol } from \"./IChainConnectorSol\"\n\nexport class ChainConnectorSol implements IChainConnectorSol {\n #chaindataProvider: IChaindataNetworkProvider & IChaindataTokenProvider\n #transports = new Map<SolNetworkId, RpcTransport>()\n #rpcs = new Map<SolNetworkId, SolRpc>()\n\n constructor(chaindataProvider: IChaindataNetworkProvider & IChaindataTokenProvider) {\n this.#chaindataProvider = chaindataProvider\n }\n\n async #getNetworkRpcs(networkId: SolNetworkId): Promise<string[]> {\n const network = await this.#chaindataProvider.getNetworkById(networkId, \"solana\")\n if (!network) throw new Error(`Network not found: ${networkId}`)\n\n return network.rpcs\n }\n\n async getTransport(networkId: SolNetworkId): Promise<RpcTransport> {\n if (!this.#transports.has(networkId))\n this.#transports.set(\n networkId,\n getSolTransport(networkId, await this.#getNetworkRpcs(networkId))\n )\n\n return this.#transports.get(networkId)!\n }\n\n async getRpc(networkId: SolNetworkId): Promise<SolRpc> {\n if (!this.#rpcs.has(networkId))\n this.#rpcs.set(networkId, createSolanaRpcFromTransport(await this.getTransport(networkId)))\n\n return this.#rpcs.get(networkId)!\n }\n\n /** Drops cached transports/rpcs so the next call re-reads the network's rpcs from chaindata */\n clearRpcProvidersCache(networkId?: SolNetworkId) {\n if (networkId) {\n this.#transports.delete(networkId)\n this.#rpcs.delete(networkId)\n } else {\n this.#transports.clear()\n this.#rpcs.clear()\n }\n }\n}\n","import type { RpcTransport } from \"@solana/kit\"\nimport { createSolanaRpcFromTransport } from \"@solana/kit\"\nimport type { SolNetwork } from \"@talismn/chaindata-provider\"\n\nimport type { SolRpc } from \"./getSolRpc\"\nimport { getSolTransport } from \"./getSolRpc\"\nimport type { IChainConnectorSol } from \"./IChainConnectorSol\"\n\nexport class ChainConnectorSolStub implements IChainConnectorSol {\n #transport: RpcTransport\n #rpc: SolRpc\n\n constructor(network: Pick<SolNetwork, \"id\" | \"rpcs\">) {\n this.#transport = getSolTransport(network.id, network.rpcs)\n this.#rpc = createSolanaRpcFromTransport(this.#transport)\n }\n\n async getRpc(): Promise<SolRpc> {\n return this.#rpc\n }\n\n async getTransport(): Promise<RpcTransport> {\n return this.#transport\n }\n}\n"],"mappings":";;;;;;;;;;ACIA,IAAA,cAAe,UAAUA,2BAAgB;;;ACUzC,MAAM,iBAAyC;CAC7C,UAAU;CACV,UAAU;AACZ;AAEA,MAAMC,qBAAmB;AACzB,MAAM,sBAAsB;;;;;;AAM5B,MAAM,mBAAmB;;AAGzB,MAAM,oBAAoB,UACxB,iBAAiB,SAAS,MAAM,SAAS;AAC3C,MAAM,uBAAuB;AAE7B,IAAa,uBAAb,cAA0C,MAAM;CAC9C;CACA;CAEA,YAAY,SAAiB,SAAwB;EACnD,MAAM,8BAA8B,WAAW,OAAO;EAEtD,KAAK,OAAO;EACZ,KAAK,UAAU;CACjB;AACF;;;;;AAMA,IAAa,gBAAb,cAAmC,MAAM;CACvC;CACA;CAEA,YAAY,SAAiB,SAAwB;EACnD,MAAM,wCAAwC,WAAW,OAAO;EAEhE,KAAK,OAAO;EACZ,KAAK,UAAU;CACjB;AACF;;;;;;;;;;;;;;;AAqDA,IAAa,oBAAb,MAA6D;CAC3D;CACA;CAEA,eAAiD,CAAC;CAClD,sBAAiE,C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,OAAO;GACL,KAAK,YAAY,MAAM;GACvB,KAAK,MAAM,MAAM;EACnB;CACF;AACF;;;AC/CA,IAAa,wBAAb,MAAiE;CAC/D;CACA;CAEA,YAAY,SAA0C;EACpD,KAAK,aAAa,gBAAgB,QAAQ,IAAI,QAAQ,IAAI;EAC1D,KAAK,OAAO,6BAA6B,KAAK,UAAU;CAC1D;CAEA,MAAM,SAA0B;EAC9B,OAAO,KAAK;CACd;CAEA,MAAM,eAAsC;EAC1C,OAAO,KAAK;CACd;AACF"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["packageJson.name","RESPONSE_TIMEOUT","log"],"sources":["../package.json","../src/log.ts","../src/dot/ChainConnectorDot.ts","../src/dot/ChainConnectorDotPapi.ts","../src/dot/ChainConnectorDotStub.ts","../src/eth/getChainFromEvmNetwork.ts","../src/eth/getTransportForEvmNetwork.ts","../src/eth/getEvmNetworkPublicClient.ts","../src/eth/getEvmNetworkWalletClient.ts","../src/eth/ChainConnectorEth.ts","../src/eth/ChainConnectorEthStub.ts","../src/sol/getSolRpc.ts","../src/sol/ChainConnectorSol.ts","../src/sol/ChainConnectorSolStub.ts"],"sourcesContent":["","import anylogger from \"anylogger\"\n\nimport packageJson from \"../package.json\"\n\nexport default anylogger(packageJson.name)\n","import { createClient, type SubstrateClient } from \"@polkadot-api/substrate-client\"\nimport {\n getWsProvider,\n type StatusChange,\n WsEvent,\n type WsJsonRpcProvider,\n} from \"@polkadot-api/ws-provider\"\nimport type { DotNetworkId, IChaindataNetworkProvider } from \"@talismn/chaindata-provider\"\n\nimport log from \"../log\"\nimport type { IChainConnectorDot, SubscriptionCallback } from \"./IChainConnectorDot\"\n\n// errors that require an rpc fallback\n// https://docs.blastapi.io/blast-documentation/things-you-need-to-know/error-reference\nconst BAD_RPC_ERRORS: Record<string, string> = {\n \"-32097\": \"Rate limit exceeded\",\n \"-32098\": \"Capacity exceeded\",\n}\n\nconst RESPONSE_TIMEOUT = 30_000 // max wait for an rpc response (including connection time)\nconst KEEP_ALIVE_INTERVAL = 20_000 // periodic system_health to keep idle sockets alive (ws-provider kills quiet sockets after its 40s heartbeat)\n/**\n * How long a connection stays open once its last user releases it. A one-off request is\n * often followed by more traffic to the same chain (balances read the runtime version,\n * then subscribe to storage), which then reuses the socket instead of opening a new one.\n */\nconst IDLE_CLOSE_DELAY = 30_000\n\n/** in-flight requests reject with DestroyedError when a connection is torn down - expected, not worth logging */\nconst isDestroyedError = (error: unknown): boolean =>\n error instanceof Error && error.name === \"DestroyedError\"\nconst STALE_NOTIFY_TIMEOUT = 30_000 // how long a chain can be disconnected before subscribers are notified\n\nexport class ChainConnectionError extends Error {\n type: \"CHAIN_CONNECTION_ERROR\"\n chainId: string\n\n constructor(chainId: string, options?: ErrorOptions) {\n super(`Unable to connect to chain ${chainId}`, options)\n\n this.type = \"CHAIN_CONNECTION_ERROR\"\n this.chainId = chainId\n }\n}\n\n/**\n * Passed to subscription callbacks when the chain has been unreachable for a while. Not\n * terminal: the subscription stays registered and is re-issued when a socket connects.\n */\nexport class StaleRpcError extends Error {\n type: \"STALE_RPC_ERROR\"\n chainId: string\n\n constructor(chainId: string, options?: ErrorOptions) {\n super(`RPCs are stale/unavailable for chain ${chainId}`, options)\n\n this.type = \"STALE_RPC_ERROR\"\n this.chainId = chainId\n }\n}\n\ntype SocketUserId = number\n\ntype Subscription = {\n subscribeMethod: string\n params: unknown[]\n callback: SubscriptionCallback\n /** cancels the pending subscribe request, if any */\n cancelRequest: (() => void) | null\n /** stops routing notifications to the callback */\n stopFollow: (() => void) | null\n serverSubId: string | number | null\n unsubscribed: boolean\n}\n\ntype Connection = {\n chainId: DotNetworkId\n provider: WsJsonRpcProvider\n client: SubstrateClient\n users: Set<SocketUserId>\n subscriptions: Set<Subscription>\n wasConnected: boolean\n keepAliveInterval: ReturnType<typeof setInterval> | null\n staleTimeout: ReturnType<typeof setTimeout> | null\n /** closes the connection once it has had no users for IDLE_CLOSE_DELAY */\n idleTimeout: ReturnType<typeof setTimeout> | null\n}\n\nexport type ChainConnectorDotOptions = {\n /**\n * How long a new socket may take to open before the provider gives up on the endpoint\n * and tries the next one. Defaults to polkadot-api's 5 seconds. A slow device or\n * network can take longer than that to connect while it is busy, as a phone app is\n * at startup, and every endpoint then times out in turn.\n */\n connectionTimeout?: number\n}\n\n/**\n * ChainConnector provides an interface similar to a websocket JSON-RPC provider, but with three points of difference:\n *\n * 1. ChainConnector methods all accept a `chainId` instead of an array of RPCs. RPCs are then fetched internally from chaindata.\n * 2. ChainConnector creates only one socket connection per chain (via polkadot-api's ws-provider, which handles\n * endpoint rotation, reconnection and stale-socket detection) and ensures that all downstream requests to a chain\n * share that connection.\n * 3. Subscriptions return a callable `unsubscribe` method instead of an id, and are automatically re-established\n * when the provider reconnects (possibly to another endpoint).\n *\n * Additionally, when run on the clientside of a dapp where `window.talismanSub` is available, instead of spinning up new websocket\n * connections this class will forward all requests through to the wallet backend - where another instance of this class will\n * handle the websocket connections.\n */\nexport class ChainConnectorDot implements IChainConnectorDot {\n #chaindataChainProvider: IChaindataNetworkProvider\n #connectionTimeout: number | undefined\n\n #connections: Record<DotNetworkId, Connection> = {}\n #pendingConnections: Record<DotNetworkId, Promise<Connection>> = {}\n\n constructor(\n chaindataChainProvider: IChaindataNetworkProvider,\n options?: ChainConnectorDotOptions\n ) {\n this.#chaindataChainProvider = chaindataChainProvider\n this.#connectionTimeout = options?.connectionTimeout\n }\n\n // biome-ignore lint/suspicious/noExplicitAny: legacy\n async send<T = any>(\n chainId: DotNetworkId,\n method: string,\n params: unknown[],\n _isCacheable?: boolean | undefined,\n extraOptions?: {\n /**\n * Set to `true` if this query is speculative, i.e. if on some chains it's expected that it will raise a wasm unreachable error of the form:\n *\n * 4003: Client error: Execution failed: Execution aborted due to trap: wasm trap: wasm `unreachable` instruction executed\n *\n * By setting expectErrors to true, this method won't pollute the logs with errors we intend to have happen.\n * An example use case of this is when you plan to catch the wasm unreachable error on chains that don't support the query, and then fall back\n * to another query or perhaps an empty result.\n */\n expectErrors?: boolean\n }\n ): Promise<T> {\n const talismanSub = this.getTalismanSub()\n if (talismanSub !== undefined) {\n try {\n const genesisHash = await this.getGenesisHash(chainId)\n return await talismanSub.send(genesisHash, method, params)\n } catch (error) {\n log.warn(\n `Failed to make wallet-proxied send request for chain ${chainId}. Falling back to plain websocket`,\n error\n )\n }\n }\n\n let socketUserId: SocketUserId\n let connection: Connection\n try {\n ;[socketUserId, connection] = await this.acquireConnection(chainId)\n } catch (error) {\n throw new StaleRpcError(chainId, { cause: error })\n }\n\n try {\n return await this.request<T>(connection, method, params)\n } catch (err) {\n const error = err as (Error & { code?: number; data?: unknown }) | null\n\n if (error?.message === \"TIMEOUT\") {\n log.error(`ChainConnector timeout`, { chainId, error })\n connection.provider.switch()\n throw new Error(\"Timeout\")\n }\n\n const badRpcError = BAD_RPC_ERRORS[error?.code?.toString() ?? \"\"]\n if (badRpcError) {\n log.error(`ChainConnector ${badRpcError}`, { error, chainId })\n connection.provider.switch()\n throw new Error(badRpcError)\n }\n\n if (!extraOptions?.expectErrors)\n log.error(\n `Failed to send ${method} on chain ${chainId}\\nparams: ${JSON.stringify(params)}`,\n {\n error,\n }\n )\n\n throw error\n } finally {\n this.releaseConnection(chainId, socketUserId)\n }\n }\n\n async subscribe(\n chainId: DotNetworkId,\n subscribeMethod: string,\n responseMethod: string,\n params: unknown[],\n callback: SubscriptionCallback,\n timeout: number | false = 30_000 // 30 seconds in milliseconds\n ): Promise<(unsubscribeMethod: string) => void> {\n const talismanSub = this.getTalismanSub()\n if (talismanSub !== undefined) {\n try {\n const genesisHash = await this.getGenesisHash(chainId)\n\n const subscriptionId = await talismanSub.subscribe(\n genesisHash,\n subscribeMethod,\n responseMethod,\n params,\n callback,\n timeout\n )\n\n return (unsubscribeMethod: string) =>\n talismanSub.unsubscribe(subscriptionId, unsubscribeMethod)\n } catch (error) {\n log.warn(\n `Failed to create wallet-proxied subscription for chain ${chainId}. Falling back to plain websocket`,\n error\n )\n }\n }\n\n let socketUserId: SocketUserId\n let connection: Connection\n try {\n ;[socketUserId, connection] = await this.acquireConnection(chainId)\n } catch (error) {\n throw new StaleRpcError(chainId, { cause: error })\n }\n\n const subscription: Subscription = {\n subscribeMethod,\n params,\n callback,\n cancelRequest: null,\n stopFollow: null,\n serverSubId: null,\n unsubscribed: false,\n }\n connection.subscriptions.add(subscription)\n\n // if the chain can't be reached at all, let the caller know after a while (the provider keeps retrying)\n if (timeout && !connection.wasConnected) {\n const staleWarning = setTimeout(() => {\n if (!subscription.unsubscribed && !connection.wasConnected)\n callback(new StaleRpcError(chainId), null)\n }, timeout)\n const clear = () => clearTimeout(staleWarning)\n // piggyback on the follow setup to clear the warning once anything happens\n const originalCallback = subscription.callback\n subscription.callback = (error, result) => {\n clear()\n subscription.callback = originalCallback\n originalCallback(error, result)\n }\n }\n\n this.startSubscription(connection, subscription)\n\n return (unsubscribeMethod: string) => {\n if (subscription.unsubscribed) return\n subscription.unsubscribed = true\n\n subscription.cancelRequest?.()\n subscription.stopFollow?.()\n\n // the connection may have been replaced by a reset() since we subscribed. It stays\n // open for a while after its last user leaves, so unsubscribe on the server even then\n const current = this.#connections[chainId]\n if (subscription.serverSubId !== null && current)\n try {\n current.client.request(unsubscribeMethod, [subscription.serverSubId]).catch((error) => {\n if (!isDestroyedError(error)) log.warn(`Failed to unsubscribe from ${chainId}`, error)\n })\n } catch (error) {\n if (!isDestroyedError(error)) log.warn(`Failed to unsubscribe from ${chainId}`, error)\n }\n\n current?.subscriptions.delete(subscription)\n this.releaseConnection(chainId, socketUserId)\n }\n }\n\n /**\n * Kills and recreates the connection for a chain, if any.\n * Useful after changing a network's rpcs to make sure the new list is applied for further requests.\n * Active subscriptions are automatically re-established on the new connection.\n */\n async reset(chainId: DotNetworkId) {\n log.info(\"ChainConnector reset\", chainId)\n const connection = this.#connections[chainId]\n if (!connection) return\n\n this.destroyConnection(connection)\n delete this.#connections[chainId]\n\n // recreate a connection for the active subscriptions, if any\n if (connection.subscriptions.size) {\n try {\n const fresh = await this.createConnection(chainId)\n fresh.users = connection.users\n fresh.subscriptions = connection.subscriptions\n this.#connections[chainId] = fresh\n for (const subscription of fresh.subscriptions) this.startSubscription(fresh, subscription)\n } catch (error) {\n log.warn(`Failed to recreate connection for ${chainId} after reset`, error)\n // not a StaleRpcError: no connection is left to re-issue these subscriptions,\n // so subscribers must treat this one as terminal\n for (const subscription of connection.subscriptions)\n subscription.callback(new ChainConnectionError(chainId, { cause: error }), null)\n }\n }\n }\n\n /** Sends a request over a connection, throwing `Error(\"TIMEOUT\")` if no response arrives in time */\n private request<T>(\n connection: Connection,\n method: string,\n params: unknown[],\n timeoutMs = RESPONSE_TIMEOUT\n ): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n const timer = setTimeout(() => {\n cancel()\n reject(new Error(\"TIMEOUT\"))\n }, timeoutMs)\n\n const cancel = connection.client._request<T, unknown>(method, params, {\n onSuccess: (result) => {\n clearTimeout(timer)\n resolve(result)\n },\n onError: (error) => {\n clearTimeout(timer)\n reject(error)\n },\n })\n })\n }\n\n /** Issues the subscribe request and routes notifications to the subscription callback */\n private startSubscription(connection: Connection, subscription: Subscription) {\n subscription.serverSubId = null\n subscription.stopFollow = null\n\n subscription.cancelRequest = connection.client._request<string | number, unknown>(\n subscription.subscribeMethod,\n subscription.params,\n {\n onSuccess: (serverSubId, follow) => {\n subscription.cancelRequest = null\n if (subscription.unsubscribed) return\n\n subscription.serverSubId = serverSubId\n // raw-client matches notifications by the raw (not stringified) subscription id, but types it as string\n subscription.stopFollow = follow(serverSubId as string, {\n next: (result) => subscription.callback(null, result),\n error: (error) => subscription.callback(error, null),\n })\n },\n onError: (error) => {\n subscription.cancelRequest = null\n if (!subscription.unsubscribed) subscription.callback(error, null)\n },\n }\n )\n }\n\n /**\n * Get (or create) the shared connection for a chain.\n *\n * The caller must call releaseConnection with the returned SocketUserId once they are finished with it.\n */\n private async acquireConnection(chainId: DotNetworkId): Promise<[SocketUserId, Connection]> {\n // a single creation promise per chain guarantees that concurrent callers share the same connection\n let connection = this.#connections[chainId]\n if (!connection) {\n if (!this.#pendingConnections[chainId]) {\n this.#pendingConnections[chainId] = this.createConnection(chainId)\n .then((created) => {\n this.#connections[chainId] = created\n return created\n })\n .finally(() => {\n delete this.#pendingConnections[chainId]\n })\n }\n connection = await this.#pendingConnections[chainId]\n }\n\n if (connection.idleTimeout) {\n clearTimeout(connection.idleTimeout)\n connection.idleTimeout = null\n }\n const socketUserId = this.getExclusiveRandomId([...connection.users])\n connection.users.add(socketUserId)\n\n return [socketUserId, connection]\n }\n\n private async createConnection(chainId: DotNetworkId): Promise<Connection> {\n const chain = await this.#chaindataChainProvider.getNetworkById(chainId, \"polkadot\")\n if (!chain) throw new Error(`Chain ${chainId} not found in store`)\n\n const rpcs = chain.rpcs.concat()\n if (!rpcs.length) throw new Error(`No healthy RPCs available for chain ${chainId}`)\n\n // will be assigned below - the provider config needs to reference the connection\n let connection: Connection = null as unknown as Connection\n\n const provider = getWsProvider(rpcs, {\n onStatusChanged: (status: StatusChange) => this.handleStatusChange(connection, status),\n ...(this.#connectionTimeout !== undefined && { timeout: this.#connectionTimeout }),\n })\n\n const client = createClient(provider)\n\n connection = {\n chainId,\n provider,\n client,\n users: new Set(),\n subscriptions: new Set(),\n wasConnected: false,\n keepAliveInterval: null,\n staleTimeout: null,\n idleTimeout: null,\n }\n\n return connection\n }\n\n private handleStatusChange(connection: Connection, status: StatusChange) {\n // connection is still being constructed on the initial CONNECTING event\n if (!connection) return\n // ignore events from a connection that has been reset/destroyed\n if (this.#connections[connection.chainId] !== connection) return\n\n if (status.type === WsEvent.CONNECTED) {\n if (connection.staleTimeout) {\n clearTimeout(connection.staleTimeout)\n connection.staleTimeout = null\n }\n\n const isReconnect = connection.wasConnected\n connection.wasConnected = true\n\n // periodically send a request to keep the socket alive when there is no other traffic\n if (connection.keepAliveInterval) clearInterval(connection.keepAliveInterval)\n connection.keepAliveInterval = setInterval(() => {\n this.request(connection, \"system_health\", [], KEEP_ALIVE_INTERVAL).catch((error) => {\n if (!isDestroyedError(error))\n log.warn(`Failed keep-alive for socket ${connection.chainId}`, error)\n })\n }, KEEP_ALIVE_INTERVAL)\n\n // server-side subscriptions died with the previous socket : re-establish them\n // (skip author_* subscriptions : resubmitting an extrinsic is not safe)\n if (isReconnect)\n for (const subscription of connection.subscriptions) {\n if (subscription.unsubscribed) continue\n if (subscription.subscribeMethod.startsWith(\"author_\")) continue\n subscription.stopFollow?.()\n subscription.cancelRequest?.()\n this.startSubscription(connection, subscription)\n }\n } else {\n if (connection.keepAliveInterval) {\n clearInterval(connection.keepAliveInterval)\n connection.keepAliveInterval = null\n }\n\n // notify subscribers if the chain stays unreachable for too long\n if (!connection.staleTimeout && connection.subscriptions.size) {\n connection.staleTimeout = setTimeout(() => {\n connection.staleTimeout = null\n for (const subscription of connection.subscriptions)\n if (!subscription.unsubscribed)\n subscription.callback(new StaleRpcError(connection.chainId), null)\n }, STALE_NOTIFY_TIMEOUT)\n }\n }\n }\n\n private releaseConnection(chainId: DotNetworkId, socketUserId: SocketUserId): void {\n const connection = this.#connections[chainId]\n if (!connection) return\n\n connection.users.delete(socketUserId)\n if (connection.users.size > 0 || connection.idleTimeout) return\n\n connection.idleTimeout = setTimeout(() => {\n connection.idleTimeout = null\n if (connection.users.size > 0 || this.#connections[chainId] !== connection) return\n this.destroyConnection(connection)\n delete this.#connections[chainId]\n }, IDLE_CLOSE_DELAY)\n }\n\n private destroyConnection(connection: Connection): void {\n if (connection.keepAliveInterval) clearInterval(connection.keepAliveInterval)\n if (connection.staleTimeout) clearTimeout(connection.staleTimeout)\n if (connection.idleTimeout) clearTimeout(connection.idleTimeout)\n connection.keepAliveInterval = null\n connection.staleTimeout = null\n connection.idleTimeout = null\n\n // detach subscriptions before destroying the client so their callbacks don't receive a DestroyedError\n for (const subscription of connection.subscriptions) {\n subscription.stopFollow?.()\n subscription.cancelRequest?.()\n subscription.stopFollow = null\n subscription.cancelRequest = null\n subscription.serverSubId = null\n }\n\n try {\n connection.client.destroy()\n } catch (error) {\n log.warn(`Error occurred destroying connection ${connection.chainId}`, error)\n }\n }\n\n private async getGenesisHash(chainId: DotNetworkId): Promise<string> {\n const chain = await this.#chaindataChainProvider.getNetworkById(chainId, \"polkadot\")\n if (!chain) throw new Error(`Chain ${chainId} not found in store`)\n\n const { genesisHash } = chain\n if (typeof genesisHash !== \"string\")\n throw new Error(`Chain ${chainId} has no genesisHash in store`)\n\n return genesisHash\n }\n\n /** continues to generate a random number until it finds one which is not present in the exclude list */\n private getExclusiveRandomId(exclude: number[] = []): number {\n let id = this.getRandomId()\n while (exclude.includes(id)) {\n id = this.getRandomId()\n }\n return id\n }\n /** generates a random number */\n private getRandomId(): number {\n return Math.trunc(Math.random() * 10 ** 8)\n }\n\n private getTalismanSub() {\n // biome-ignore lint/suspicious/noExplicitAny: legacy\n const talismanSub = typeof window !== \"undefined\" && (window as any).talismanSub\n\n // biome-ignore lint/complexity/noBannedTypes: legacy\n const rpcByGenesisHashSend: Function | undefined = talismanSub?.rpcByGenesisHashSend\n // biome-ignore lint/complexity/noBannedTypes: legacy\n const rpcByGenesisHashSubscribe: Function | undefined = talismanSub?.rpcByGenesisHashSubscribe\n // biome-ignore lint/complexity/noBannedTypes: legacy\n const rpcByGenesisHashUnsubscribe: Function | undefined =\n talismanSub?.rpcByGenesisHashUnsubscribe\n\n if (typeof rpcByGenesisHashSend !== \"function\") return\n if (typeof rpcByGenesisHashSubscribe !== \"function\") return\n if (typeof rpcByGenesisHashUnsubscribe !== \"function\") return\n\n return {\n // biome-ignore lint/suspicious/noExplicitAny: legacy\n send: <T = any>(genesisHash: string, method: string, params: unknown[]): Promise<T> =>\n rpcByGenesisHashSend(genesisHash, method, params),\n\n subscribe: (\n genesisHash: string,\n subscribeMethod: string,\n responseMethod: string,\n params: unknown[],\n callback: SubscriptionCallback,\n timeout: number | false\n ): Promise<string> =>\n rpcByGenesisHashSubscribe(\n genesisHash,\n subscribeMethod,\n responseMethod,\n params,\n callback,\n timeout\n ),\n\n unsubscribe: (subscriptionId: string, unsubscribeMethod: string): Promise<void> =>\n rpcByGenesisHashUnsubscribe(subscriptionId, unsubscribeMethod),\n }\n }\n}\n","import type { DotNetworkId } from \"@talismn/chaindata-provider\"\n\nimport log from \"../log\"\nimport { StaleRpcError } from \"./ChainConnectorDot\"\nimport type { IChainConnectorDot, SubscriptionCallback } from \"./IChainConnectorDot\"\n\nconst RESPONSE_TIMEOUT = 30_000\nconst FAILURES_BEFORE_FIRST_RESULT = 3\n\ntype HexString = `0x${string}`\ntype StorageChanges = { block: HexString; changes: [HexString, HexString | null][] }\n\n/** The parts of a polkadot-api `PolkadotClient` that the connector uses */\nexport type PapiClient = {\n /** `PolkadotClient` types it without `abortSignal`, but it is substrate-client's `request`, which honours it */\n _request: <Reply>(method: string, params: unknown[], abortSignal?: AbortSignal) => Promise<Reply>\n bestBlocks$: {\n subscribe: (observer: {\n next: (blocks: { hash: string }[]) => void\n error: (error: unknown) => void\n complete: () => void\n }) => { unsubscribe: () => void }\n }\n}\n\n/**\n * Runs `@talismn/balances` over a dapp's polkadot-api clients, so the dapp and its balances share one socket per chain.\n *\n * `state_subscribeStorage` is the only subscription balances uses. It is served by querying the keys at each new\n * best block and reporting the values that changed, like the node does. One query runs at a time, for the latest\n * best block. A failed query is retried at the next block, because balances treats a subscription error as final\n * and would stop updating that network. Only when the first three queries fail does the subscription report the error.\n */\nexport class ChainConnectorDotPapi implements IChainConnectorDot {\n #clientFor: (networkId: DotNetworkId) => PapiClient | undefined\n\n constructor(clientFor: (networkId: DotNetworkId) => PapiClient | undefined) {\n this.#clientFor = clientFor\n }\n\n async send<T = unknown>(networkId: DotNetworkId, method: string, params: unknown[]): Promise<T> {\n return requestWithTimeout<T>(this.getClient(networkId), method, params, new AbortController())\n }\n\n async subscribe(\n networkId: DotNetworkId,\n subscribeMethod: string,\n _responseMethod: string,\n params: unknown[],\n callback: SubscriptionCallback,\n timeout: number | false = 30_000\n ): Promise<(unsubscribeMethod: string) => void> {\n const client = this.getClient(networkId)\n if (subscribeMethod !== \"state_subscribeStorage\")\n throw new Error(`ChainConnectorDotPapi does not support ${subscribeMethod}`)\n\n const [keys] = params as [HexString[]]\n const values = new Map<HexString, HexString | null>()\n let bestBlockHash: string | undefined\n let queriedBlockHash: string | undefined\n let inFlight: AbortController | undefined\n let delivered = false\n let failures = 0\n let active = true\n let subscription: { unsubscribe: () => void } | undefined\n const staleTimer = timeout\n ? setTimeout(() => callback(new StaleRpcError(networkId), null), timeout)\n : undefined\n\n const stop = () => {\n active = false\n clearTimeout(staleTimer)\n inFlight?.abort()\n subscription?.unsubscribe()\n }\n\n const finish = (error: Error) => {\n if (!active) return\n stop()\n callback(error, null)\n }\n\n const reportChanges = (result: StorageChanges) => {\n const changes = result.changes.filter(([key, value]) => values.get(key) !== value)\n for (const [key, value] of changes) values.set(key, value)\n if (!changes.length) return\n\n delivered = true\n clearTimeout(staleTimer)\n callback(null, { block: result.block, changes })\n }\n\n const reportFailure = (error: Error) => {\n if (delivered || ++failures < FAILURES_BEFORE_FIRST_RESULT)\n return log.warn(\n `state_queryStorageAt failed on ${networkId}, retrying at the next block`,\n error\n )\n finish(error)\n }\n\n const queryBestBlock = async () => {\n if (!active || inFlight || !bestBlockHash || bestBlockHash === queriedBlockHash) return\n const blockHash = bestBlockHash\n queriedBlockHash = blockHash\n const controller = new AbortController()\n inFlight = controller\n\n try {\n const [result] = await requestWithTimeout<StorageChanges[]>(\n client,\n \"state_queryStorageAt\",\n [keys, blockHash],\n controller\n )\n if (!active) return\n if (!result) throw new Error(`Empty state_queryStorageAt response on ${networkId}`)\n reportChanges(result)\n } catch (error) {\n if (active) reportFailure(error as Error)\n } finally {\n if (inFlight === controller) inFlight = undefined\n queryBestBlock()\n }\n }\n\n try {\n subscription = client.bestBlocks$.subscribe({\n next: ([best]) => {\n bestBlockHash = best?.hash\n queryBestBlock()\n },\n error: (error) => finish(error as Error),\n complete: () =>\n finish(new Error(`polkadot-api client for ${networkId} stopped following blocks`)),\n })\n } catch (error) {\n stop()\n throw error\n }\n if (!active) subscription.unsubscribe()\n\n return stop\n }\n\n async reset() {}\n\n private getClient(networkId: DotNetworkId): PapiClient {\n const client = this.#clientFor(networkId)\n if (!client) throw new Error(`No polkadot-api client for network ${networkId}`)\n return client\n }\n}\n\n/** rejects on its own timer too, so a client that ignores the abort signal cannot hang the caller */\nconst requestWithTimeout = <T>(\n client: PapiClient,\n method: string,\n params: unknown[],\n controller: AbortController\n) =>\n new Promise<T>((resolve, reject) => {\n const timer = setTimeout(() => {\n controller.abort()\n reject(new Error(\"Timeout\"))\n }, RESPONSE_TIMEOUT)\n try {\n client\n ._request<T>(method, params, controller.signal)\n .then(resolve, reject)\n .finally(() => clearTimeout(timer))\n } catch (error) {\n clearTimeout(timer)\n reject(error)\n }\n })\n","import { createClient, type SubstrateClient } from \"@polkadot-api/substrate-client\"\nimport { getWsProvider } from \"@polkadot-api/ws-provider\"\nimport type { DotNetwork, DotNetworkId } from \"@talismn/chaindata-provider\"\nimport { throwAfter } from \"@talismn/util\"\n\nimport type { IChainConnectorDot, SubscriptionCallback } from \"./IChainConnectorDot\"\n\nconst TIMEOUT = 10_000\n\nexport class ChainConnectorDotStub implements IChainConnectorDot {\n #client: SubstrateClient\n\n constructor(network: DotNetwork) {\n this.#client = createClient(getWsProvider(network.rpcs.concat()))\n }\n\n async send<T = unknown>(\n _chainId: DotNetworkId,\n method: string,\n params: unknown[],\n _isCacheable?: boolean\n ): Promise<T> {\n return await Promise.race([\n this.#client.request<T>(method, params),\n throwAfter(TIMEOUT, `Request ${method} timed out after ${TIMEOUT}ms`),\n ])\n }\n\n async subscribe(\n _chainId: DotNetworkId,\n subscribeMethod: string,\n _responseMethod: string,\n params: unknown[],\n callback: SubscriptionCallback,\n timeout?: number | false\n ): Promise<(unsubscribeMethod: string) => void> {\n let stopFollow: (() => void) | null = null\n let unsubscribed = false\n\n const serverSubId = await Promise.race([\n new Promise<string | number>((resolve, reject) => {\n this.#client._request<string | number, unknown>(subscribeMethod, params, {\n onSuccess: (subId, follow) => {\n stopFollow = follow(subId as string, {\n next: (result) => callback(null, result),\n error: (error) => callback(error, null),\n })\n resolve(subId)\n },\n onError: reject,\n })\n }),\n throwAfter(timeout || TIMEOUT, `Subscription timed out after ${timeout || TIMEOUT}ms`),\n ])\n\n return (unsubscribeMethod: string) => {\n if (unsubscribed) return\n unsubscribed = true\n stopFollow?.()\n this.#client.request(unsubscribeMethod, [serverSubId]).catch(() => {}) // connection may already be gone\n }\n }\n\n reset(): Promise<void> {\n throw new Error(\"ChainConnectorDotStub does not implement reset\")\n }\n\n destroy() {\n this.#client.destroy()\n }\n}\n","import type { EthNetwork, EthNetworkId } from \"@talismn/chaindata-provider\"\nimport { camelCase, fromPairs, toPairs } from \"lodash-es\"\nimport type { Chain, ChainContract } from \"viem\"\nimport * as viemChains from \"viem/chains\"\n\n// exclude zoraTestnet which uses Hyperliquid's chain id\nconst { zoraTestnet, ...validViemChains } = viemChains\n\n// viem chains benefit from multicall config & other viem goodies\nconst VIEM_CHAINS = Object.keys(validViemChains).reduce(\n (acc, curr) => {\n const chain = validViemChains[curr as keyof typeof validViemChains]\n acc[chain.id] = chain\n return acc\n },\n {} as Record<number, Chain>\n)\n\nconst chainsCache = new Map<string, Chain>()\n\nexport const clearChainsCache = (networkId?: EthNetworkId) => {\n if (networkId) chainsCache.delete(networkId)\n else chainsCache.clear()\n}\n\nexport const getChainFromEvmNetwork = (network: EthNetwork): Chain => {\n const { symbol, decimals } = network.nativeCurrency\n\n if (!chainsCache.has(network.id)) {\n const chainRpcs = network.rpcs ?? []\n\n const viemChain = VIEM_CHAINS[Number(network.id)] ?? {}\n\n const chain: Chain = {\n ...viemChain,\n id: Number(network.id),\n name: network.name ?? `Ethereum Chain ${network.id}`,\n rpcUrls: {\n public: { http: chainRpcs },\n default: { http: chainRpcs },\n },\n nativeCurrency: {\n symbol,\n decimals,\n name: symbol,\n },\n contracts: {\n ...viemChain.contracts,\n ...(network.contracts\n ? fromPairs(\n toPairs(network.contracts).map(([name, address]): [string, ChainContract] => [\n camelCase(name),\n { address },\n ])\n )\n : {}),\n },\n }\n\n chainsCache.set(network.id, chain)\n }\n\n return chainsCache.get(network.id) as Chain\n}\n","import type { EthNetwork } from \"@talismn/chaindata-provider\"\nimport { fallback, http, shouldThrow } from \"viem\"\n\nexport type TransportOptions = {\n batch?:\n | boolean\n | {\n batchSize?: number | undefined\n wait?: number | undefined\n }\n}\n\n// Frontier nodes report reverts with a message viem does not recognize, which makes fallback retry every rpc\nconst FRONTIER_EXECUTION_ERROR = /VM Exception while processing transaction/\n\nconst isFinalError = (error: Error) =>\n shouldThrow(error) || FRONTIER_EXECUTION_ERROR.test(error.message)\n\nexport const getTransportForEvmNetwork = (\n evmNetwork: EthNetwork,\n options: TransportOptions = {}\n) => {\n if (!evmNetwork.rpcs?.length) throw new Error(\"No RPCs found for EVM network\")\n\n const { batch } = options\n\n return fallback(\n evmNetwork.rpcs.map((url) => http(url, { batch, retryCount: 0 })),\n { retryCount: 0, shouldThrow: isFinalError }\n )\n}\n","import type { EthNetwork } from \"@talismn/chaindata-provider\"\nimport { createPublicClient, type PublicClient } from \"viem\"\n\nimport { clearChainsCache, getChainFromEvmNetwork } from \"./getChainFromEvmNetwork\"\nimport { getTransportForEvmNetwork, type TransportOptions } from \"./getTransportForEvmNetwork\"\n\nconst MUTLICALL_BATCH_WAIT = 25\nconst MUTLICALL_BATCH_SIZE = 100\n\nconst HTTP_BATCH_WAIT = 25\nconst HTTP_BATCH_SIZE_WITH_MULTICALL = 10\nconst HTTP_BATCH_SIZE_WITHOUT_MULTICALL = 30\n\n// cache to reuse previously created public clients\nconst publicClientCache = new Map<string, PublicClient>()\n\nexport const clearPublicClientCache = (evmNetworkId?: string) => {\n clearChainsCache(evmNetworkId)\n\n if (evmNetworkId) publicClientCache.delete(evmNetworkId)\n else publicClientCache.clear()\n}\n\nexport const getEvmNetworkPublicClient = (network: EthNetwork): PublicClient => {\n const chain = getChainFromEvmNetwork(network)\n\n if (!publicClientCache.has(network.id)) {\n if (!network.rpcs.length) throw new Error(\"No RPCs found for Ethereum network\")\n\n const batch = chain.contracts?.multicall3\n ? { multicall: { wait: MUTLICALL_BATCH_WAIT, batchSize: MUTLICALL_BATCH_SIZE } }\n : undefined\n\n const transportOptions: TransportOptions = {\n batch: {\n batchSize: chain.contracts?.multicall3\n ? HTTP_BATCH_SIZE_WITH_MULTICALL\n : HTTP_BATCH_SIZE_WITHOUT_MULTICALL,\n wait: HTTP_BATCH_WAIT,\n },\n }\n\n const transport = getTransportForEvmNetwork(network, transportOptions)\n\n publicClientCache.set(\n network.id,\n createPublicClient({\n chain,\n transport,\n batch,\n })\n )\n }\n\n return publicClientCache.get(network.id) as PublicClient\n}\n","import type { EthNetwork } from \"@talismn/chaindata-provider\"\nimport { type Account, createWalletClient, type WalletClient } from \"viem\"\n\nimport { getChainFromEvmNetwork } from \"./getChainFromEvmNetwork\"\nimport { getTransportForEvmNetwork } from \"./getTransportForEvmNetwork\"\n\ntype WalletClientOptions = {\n account?: `0x${string}` | Account\n}\n\nexport const getEvmNetworkWalletClient = (\n network: EthNetwork,\n options: WalletClientOptions = {}\n): WalletClient => {\n const chain = getChainFromEvmNetwork(network)\n\n const transport = getTransportForEvmNetwork(network)\n\n return createWalletClient({ chain, transport, account: options.account })\n}\n","import type {\n EthNetworkId,\n IChaindataNetworkProvider,\n IChaindataTokenProvider,\n} from \"@talismn/chaindata-provider\"\nimport type { Account, PublicClient, WalletClient } from \"viem\"\n\nimport { clearPublicClientCache, getEvmNetworkPublicClient } from \"./getEvmNetworkPublicClient\"\nimport { getEvmNetworkWalletClient } from \"./getEvmNetworkWalletClient\"\nimport type { IChainConnectorEth } from \"./IChainConnectorEth\"\n\nexport class ChainConnectorEth implements IChainConnectorEth {\n #chaindataProvider: IChaindataNetworkProvider & IChaindataTokenProvider\n\n constructor(chaindataProvider: IChaindataNetworkProvider & IChaindataTokenProvider) {\n this.#chaindataProvider = chaindataProvider\n }\n\n async getPublicClientForEvmNetwork(evmNetworkId: EthNetworkId): Promise<PublicClient | null> {\n const network = await this.#chaindataProvider.getNetworkById(evmNetworkId, \"ethereum\")\n if (!network) return null\n\n return getEvmNetworkPublicClient(network)\n }\n\n async getWalletClientForEvmNetwork(\n evmNetworkId: EthNetworkId,\n account?: `0x${string}` | Account\n ): Promise<WalletClient | null> {\n const network = await this.#chaindataProvider.getNetworkById(evmNetworkId, \"ethereum\")\n if (!network) return null\n\n return getEvmNetworkWalletClient(network, { account })\n }\n\n public clearRpcProvidersCache(evmNetworkId?: EthNetworkId) {\n clearPublicClientCache(evmNetworkId)\n }\n}\n","import type { EthNetwork, EthNetworkId } from \"@talismn/chaindata-provider\"\nimport type { Account, PublicClient, WalletClient } from \"viem\"\n\nimport { getEvmNetworkPublicClient } from \"./getEvmNetworkPublicClient\"\nimport { getEvmNetworkWalletClient } from \"./getEvmNetworkWalletClient\"\nimport type { IChainConnectorEth } from \"./IChainConnectorEth\"\n\nexport class ChainConnectorEthStub implements IChainConnectorEth {\n #network: EthNetwork\n\n constructor(network: EthNetwork) {\n this.#network = network\n }\n\n async getPublicClientForEvmNetwork(): Promise<PublicClient | null> {\n return getEvmNetworkPublicClient(this.#network)\n }\n\n async getWalletClientForEvmNetwork(\n _networkId: EthNetworkId,\n account?: `0x${string}` | Account\n ): Promise<WalletClient | null> {\n return getEvmNetworkWalletClient(this.#network, { account })\n }\n\n clearRpcProvidersCache(): void {\n // No-op for stub\n }\n}\n","import type { Rpc, RpcTransport, SolanaRpcApi } from \"@solana/kit\"\nimport { createDefaultRpcTransport, createSolanaRpcFromTransport, isSolanaError } from \"@solana/kit\"\nimport type { SolNetworkId } from \"@talismn/chaindata-provider\"\n\nexport type SolRpc = Rpc<SolanaRpcApi>\n\n// Public Solana RPC nodes rate-limit aggressively with HTTP 429. kit's default transport is\n// single-shot, unlike the old web3.js `Connection` which retried 429 up to 5x with backoff, so a\n// single 429 would fail an otherwise-valid request (e.g. a user's transaction submission, or token\n// discovery silently returning no tokens). This wrapper restores that behaviour.\nconst MAX_429_RETRIES = 5\nconst BASE_BACKOFF_MS = 500\n\ntype HttpErrorContext = { statusCode?: number; headers?: Headers }\n\nconst getRateLimitContext = (error: unknown): HttpErrorContext | null => {\n if (!isSolanaError(error)) return null\n\n const context = error.context as HttpErrorContext\n return context.statusCode === 429 ? context : null\n}\n\n/** Returns the delay to wait before retrying, or `null` if the error is not a retryable 429. */\nconst get429RetryDelay = (error: unknown, attempt: number): number | null => {\n const context = getRateLimitContext(error)\n if (!context) return null\n\n // honour the server's Retry-After header (delta-seconds) when present\n const retryAfter = Number(context.headers?.get(\"retry-after\"))\n if (Number.isFinite(retryAfter) && retryAfter > 0) return retryAfter * 1000\n\n // otherwise exponential backoff: 500ms, 1s, 2s, 4s, 8s\n return BASE_BACKOFF_MS * 2 ** attempt\n}\n\nconst sleep = (ms: number, signal?: AbortSignal): Promise<void> =>\n new Promise((resolve, reject) => {\n if (signal?.aborted) return reject(signal.reason)\n\n const onAbort = () => {\n clearTimeout(timeout)\n reject(signal?.reason)\n }\n const timeout = setTimeout(() => {\n signal?.removeEventListener(\"abort\", onAbort)\n resolve()\n }, ms)\n signal?.addEventListener(\"abort\", onAbort, { once: true })\n })\n\n/**\n * Wraps a transport so HTTP 429 responses are retried with backoff. Solana RPC requests are\n * idempotent (`sendTransaction` is keyed by signature), so replaying a rate-limited request is safe.\n */\nconst withRetryOn429 = (transport: RpcTransport): RpcTransport => {\n const wrapped = async (config: Parameters<RpcTransport>[0]) => {\n for (let attempt = 0; ; attempt++) {\n try {\n return await transport(config)\n } catch (error) {\n const delay = attempt < MAX_429_RETRIES ? get429RetryDelay(error, attempt) : null\n if (delay === null) throw error\n await sleep(delay, config.signal)\n }\n }\n }\n return wrapped as RpcTransport\n}\n\n/**\n * How long a request may wait on an RPC before moving on to the next one. The last RPC tried gets\n * no timeout, so a slow but working node still answers when every other one has failed.\n */\nconst FAILOVER_TIMEOUT_MS = 20_000\n\nconst sendWithTimeout = async <TResponse>(\n transport: RpcTransport,\n config: RpcTransportConfig,\n timeoutMs: number\n): Promise<TResponse> => {\n const controller = new AbortController()\n const onAbort = () => controller.abort(config.signal?.reason)\n config.signal?.addEventListener(\"abort\", onAbort, { once: true })\n const timeout = setTimeout(\n () => controller.abort(new Error(`RPC request timed out after ${timeoutMs}ms`)),\n timeoutMs\n )\n\n try {\n return await transport<TResponse>({ ...config, signal: controller.signal })\n } finally {\n clearTimeout(timeout)\n config.signal?.removeEventListener(\"abort\", onAbort)\n }\n}\n\ntype RpcTransportConfig = Parameters<RpcTransport>[0]\n\nconst isSendTransactionPayload = (\n payload: unknown\n): payload is { method: \"sendTransaction\"; params: unknown[] } =>\n typeof payload === \"object\" &&\n payload !== null &&\n \"method\" in payload &&\n payload.method === \"sendTransaction\" &&\n \"params\" in payload &&\n Array.isArray(payload.params)\n\nconst withoutPreflight = (config: RpcTransportConfig): RpcTransportConfig => {\n if (!isSendTransactionPayload(config.payload)) return config\n\n const [transaction, sendConfig] = config.payload.params\n return {\n ...config,\n payload: {\n ...config.payload,\n params: [transaction, { ...(sendConfig as object | undefined), skipPreflight: true }],\n },\n }\n}\n\nexport type SolTransportOptions = {\n /** Called with the url of the RPC that answered, after every successful request */\n onRpcSuccess?: (url: string) => void\n}\n\n/**\n * Sends each request to one RPC at a time, starting from the one that answered last, and moves on to\n * the next when the request fails. A transport only throws for connection, timeout and HTTP errors:\n * JSON-RPC errors come back in the response body and are returned as is.\n *\n * A failed RPC other than a rate limited one may still have forwarded a transaction. Resending it is\n * safe, as the network processes a signature once, but its preflight simulation on the next RPC\n * could then fail although it landed. So after such a failure, every resend of that transaction,\n * including the retries after a rate limit, skips preflight.\n */\nconst withFailover = (urls: string[], options: SolTransportOptions): RpcTransport => {\n const transports = urls.map((url) => createDefaultRpcTransport({ url }))\n let preferred = 0\n const mayHaveBeenProcessed = new WeakSet<RpcTransportConfig>()\n\n const failover = async <TResponse>(config: RpcTransportConfig): Promise<TResponse> => {\n if (!transports.length) throw new Error(\"No RPCs found for Solana network\")\n\n const start = preferred\n let lastError: unknown\n let rateLimitError: unknown\n for (let attempt = 0; attempt < transports.length; attempt++) {\n config.signal?.throwIfAborted()\n const index = (start + attempt) % transports.length\n const transport = transports[index] as RpcTransport\n const isLastAttempt = attempt === transports.length - 1\n const request = mayHaveBeenProcessed.has(config) ? withoutPreflight(config) : config\n\n try {\n const response = isLastAttempt\n ? await transport<TResponse>(request)\n : await sendWithTimeout<TResponse>(transport, request, FAILOVER_TIMEOUT_MS)\n preferred = index\n options.onRpcSuccess?.(urls[index] as string)\n return response\n } catch (error) {\n if (config.signal?.aborted) throw error\n lastError = error\n if (!getRateLimitContext(error)) mayHaveBeenProcessed.add(config)\n else rateLimitError ??= error\n }\n }\n throw rateLimitError ?? lastError\n }\n return failover as RpcTransport\n}\n\n/**\n * Returns a transport over all of the network's RPCs, in the given order. A request fails over to\n * the next RPC on error, and the RPC that answered is tried first for the next request. When every\n * RPC fails and one of them answered HTTP 429, the whole list is retried with backoff.\n */\nexport const getSolTransport = (\n _networkId: SolNetworkId,\n rpcs: string[],\n options: SolTransportOptions = {}\n): RpcTransport => {\n return withRetryOn429(withFailover(rpcs, options))\n}\n\nexport const getSolRpc = (\n networkId: SolNetworkId,\n rpcs: string[],\n options?: SolTransportOptions\n): SolRpc => createSolanaRpcFromTransport(getSolTransport(networkId, rpcs, options))\n","import type { RpcTransport } from \"@solana/kit\"\nimport { createSolanaRpcFromTransport } from \"@solana/kit\"\nimport type {\n IChaindataNetworkProvider,\n IChaindataTokenProvider,\n SolNetworkId,\n} from \"@talismn/chaindata-provider\"\n\nimport type { SolRpc } from \"./getSolRpc\"\nimport { getSolTransport } from \"./getSolRpc\"\nimport type { IChainConnectorSol } from \"./IChainConnectorSol\"\n\nexport class ChainConnectorSol implements IChainConnectorSol {\n #chaindataProvider: IChaindataNetworkProvider & IChaindataTokenProvider\n #transports = new Map<SolNetworkId, RpcTransport>()\n #rpcs = new Map<SolNetworkId, SolRpc>()\n\n constructor(chaindataProvider: IChaindataNetworkProvider & IChaindataTokenProvider) {\n this.#chaindataProvider = chaindataProvider\n }\n\n async #getNetworkRpcs(networkId: SolNetworkId): Promise<string[]> {\n const network = await this.#chaindataProvider.getNetworkById(networkId, \"solana\")\n if (!network) throw new Error(`Network not found: ${networkId}`)\n\n return network.rpcs\n }\n\n async getTransport(networkId: SolNetworkId): Promise<RpcTransport> {\n if (!this.#transports.has(networkId))\n this.#transports.set(\n networkId,\n getSolTransport(networkId, await this.#getNetworkRpcs(networkId))\n )\n\n return this.#transports.get(networkId)!\n }\n\n async getRpc(networkId: SolNetworkId): Promise<SolRpc> {\n if (!this.#rpcs.has(networkId))\n this.#rpcs.set(networkId, createSolanaRpcFromTransport(await this.getTransport(networkId)))\n\n return this.#rpcs.get(networkId)!\n }\n\n /** Drops cached transports/rpcs so the next call re-reads the network's rpcs from chaindata */\n clearRpcProvidersCache(networkId?: SolNetworkId) {\n if (networkId) {\n this.#transports.delete(networkId)\n this.#rpcs.delete(networkId)\n } else {\n this.#transports.clear()\n this.#rpcs.clear()\n }\n }\n}\n","import type { RpcTransport } from \"@solana/kit\"\nimport { createSolanaRpcFromTransport } from \"@solana/kit\"\nimport type { SolNetwork } from \"@talismn/chaindata-provider\"\n\nimport type { SolRpc } from \"./getSolRpc\"\nimport { getSolTransport } from \"./getSolRpc\"\nimport type { IChainConnectorSol } from \"./IChainConnectorSol\"\n\nexport class ChainConnectorSolStub implements IChainConnectorSol {\n #transport: RpcTransport\n #rpc: SolRpc\n\n constructor(network: Pick<SolNetwork, \"id\" | \"rpcs\">) {\n this.#transport = getSolTransport(network.id, network.rpcs)\n this.#rpc = createSolanaRpcFromTransport(this.#transport)\n }\n\n async getRpc(): Promise<SolRpc> {\n return this.#rpc\n }\n\n async getTransport(): Promise<RpcTransport> {\n return this.#transport\n }\n}\n"],"mappings":";;;;;;;;;ACIA,IAAA,cAAe,UAAUA,2BAAgB;;ACUzC,MAAM,iBAAyC;CAC7C,UAAU;CACV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AAS,MAAM,IAAI,MAAM,sBAAsB,WAAW;EAE/D,OAAO,QAAQ;CACjB;CAEA,MAAM,aAAa,WAAgD;EACjE,IAAI,CAAC,KAAK,YAAY,IAAI,SAAS,GACjC,KAAK,YAAY,IACf,WACA,gBAAgB,WAAW,MAAM,KAAK,gBAAgB,SAAS,CAAC,CAClE;EAEF,OAAO,KAAK,YAAY,IAAI,SAAS;CACvC;CAEA,MAAM,OAAO,WAA0C;EACrD,IAAI,CAAC,KAAK,MAAM,IAAI,SAAS,GAC3B,KAAK,MAAM,IAAI,WAAW,6BAA6B,MAAM,KAAK,aAAa,SAAS,CAAC,CAAC;EAE5F,OAAO,KAAK,MAAM,IAAI,SAAS;CACjC;;CAGA,uBAAuB,WAA0B;EAC/C,IAAI,WAAW;GACb,KAAK,YAAY,OAAO,SAAS;GACjC,KAAK,MAAM,OAAO,SAAS;EAC7B,OAAO;GACL,KAAK,YAAY,MAAM;GACvB,KAAK,MAAM,MAAM;EACnB;CACF;AACF;;AC/CA,IAAa,wBAAb,MAAiE;CAC/D;CACA;CAEA,YAAY,SAA0C;EACpD,KAAK,aAAa,gBAAgB,QAAQ,IAAI,QAAQ,IAAI;EAC1D,KAAK,OAAO,6BAA6B,KAAK,UAAU;CAC1D;CAEA,MAAM,SAA0B;EAC9B,OAAO,KAAK;CACd;CAEA,MAAM,eAAsC;EAC1C,OAAO,KAAK;CACd;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@talismn/chain-connectors",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "RPC connectors for Polkadot SDK, EVM and Solana networks",
|
|
5
5
|
"author": "Talisman",
|
|
6
6
|
"homepage": "https://talisman.xyz",
|
|
@@ -24,16 +24,16 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@polkadot-api/substrate-client": "0.7.0",
|
|
26
26
|
"@polkadot-api/ws-provider": "0.9.2",
|
|
27
|
-
"@solana/kit": "8.
|
|
28
|
-
"@talismn/chaindata-provider": "2.
|
|
29
|
-
"@talismn/util": "2.
|
|
27
|
+
"@solana/kit": "8.6.0",
|
|
28
|
+
"@talismn/chaindata-provider": "2.4.0",
|
|
29
|
+
"@talismn/util": "2.2.0",
|
|
30
30
|
"anylogger": "^1.0.11",
|
|
31
31
|
"lodash-es": "4.18.1",
|
|
32
|
-
"viem": "2.
|
|
32
|
+
"viem": "2.57.14"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@talismn/tsconfig": "0.0.4",
|
|
36
|
-
"polkadot-api": "3.
|
|
36
|
+
"polkadot-api": "3.3.0",
|
|
37
37
|
"typescript": "^7.0.2"
|
|
38
38
|
},
|
|
39
39
|
"types": "./dist/index.d.ts",
|