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.
@@ -1,4 +1,4 @@
1
- export const SDK_VERSION = '2.0.296';
1
+ export const SDK_VERSION = '2.0.297';
2
2
  export function compareVersions(v1, v2) {
3
3
  // Split the version strings into parts
4
4
  const v1Parts = v1.split('.').map(Number);
@@ -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.296";
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "otomato-sdk",
3
- "version": "2.0.296",
3
+ "version": "2.0.297",
4
4
  "description": "An SDK for building and managing automations on Otomato",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/types/src/index.d.ts",