otomato-sdk 2.0.296 → 2.0.297
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.
|
@@ -375,3 +375,20 @@ export const findNewElements = (oldArray, newArray) => {
|
|
|
375
375
|
}
|
|
376
376
|
return matchStartIndex > 0 ? newArray.slice(0, matchStartIndex) : [];
|
|
377
377
|
};
|
|
378
|
+
export const createEthersContract = (chainId, contractAddress, abi, rpcUrl) => {
|
|
379
|
+
let providerUrl;
|
|
380
|
+
if (rpcUrl) {
|
|
381
|
+
providerUrl = rpcUrl;
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
const chainName = chainId == 1 ? 'INFURA' : Object.keys(CHAINS).find(key => CHAINS[key] == chainId);
|
|
385
|
+
if (!chainName) {
|
|
386
|
+
throw new Error(`Unsupported chain ID: ${chainId}`);
|
|
387
|
+
}
|
|
388
|
+
providerUrl = process.env[`${chainName}_HTTPS_PROVIDER`];
|
|
389
|
+
}
|
|
390
|
+
if (!providerUrl)
|
|
391
|
+
throw new Error("No provider url found");
|
|
392
|
+
const provider = new ethers.JsonRpcProvider(providerUrl);
|
|
393
|
+
return new ethers.Contract(contractAddress, abi, provider);
|
|
394
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "2.0.
|
|
1
|
+
export declare const SDK_VERSION = "2.0.297";
|
|
2
2
|
export declare function compareVersions(v1: string, v2: string): number;
|
|
@@ -120,3 +120,4 @@ export declare const getComparisonString: (condition: string, comparisonValue: s
|
|
|
120
120
|
* @returns The new elements.
|
|
121
121
|
*/
|
|
122
122
|
export declare const findNewElements: (oldArray: string[], newArray: string[]) => string[];
|
|
123
|
+
export declare const createEthersContract: (chainId: number, contractAddress: string, abi: any[], rpcUrl?: string) => ethers.Contract;
|