Skip to content

Commit

Permalink
chore: Automate renaming (#38)
Browse files Browse the repository at this point in the history
* chore: rename files

* chore: rename abi & types

* chore: rename vars

* chore: rename package & readme

* chore: task api axios instance

* chore: update task api endpoint

* chore: remove old contract types

* chore: bump version number

---------

Co-authored-by: Sylvain Goumy <goumsss@protonmail.com>
  • Loading branch information
brandonchuah and goums authored Mar 17, 2023
1 parent f1b742b commit 374e006
Show file tree
Hide file tree
Showing 17 changed files with 142 additions and 122 deletions.
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Gelato Ops SDK <!-- omit in toc -->
# Gelato Automate SDK <!-- omit in toc -->

Automate your smart contracts using Gelato Ops SDK
Automate your smart contracts using Automate SDK

- [Installation](#installation)
- [How to use?](#how-to-use)
Expand All @@ -9,36 +9,36 @@ Automate your smart contracts using Gelato Ops SDK
## Installation

```bash
yarn add @gelatonetwork/ops-sdk
yarn add @gelatonetwork/automate-sdk
```
or
```bash
npm install @gelatonetwork/ops-sdk
npm install @gelatonetwork/automate-sdk
```

## How to use?

1. Import the Gelato Ops SDK into your project:
1. Import the Automate SDK into your project:

```typescript
import { GelatoOpsSDK } from "@gelatonetwork/ops-sdk";
import { AutomateSDK } from "@gelatonetwork/automate-sdk";
```

2. Check if Gelato Ops is deployed on your network:
2. Check if Automate is deployed on your network:

```typescript
import { isGelatoOpsSupported } from "@gelatonetwork/ops-sdk";
import { isAutomateSupported } from "@gelatonetwork/automate-sdk";

if (!isGelatoOpsSupported(chainId)) {
console.log(`Gelato Ops network not supported (${chainId})`);
if (!isAutomateSupported(chainId)) {
console.log(`Automate network not supported (${chainId})`);
return;
}
```

3. Instantiate Gelato Ops using your signer:
3. Instantiate Automate using your signer:

```typescript
const gelatoOps = new GelatoOpsSDK(chainId, signer);
const automate = new AutomateSDK(chainId, signer);
```

4. Create an automation task:
Expand Down Expand Up @@ -75,15 +75,15 @@ interface CreateTaskOptions {
}

const params: CreateTaskOptions = { name, execAddress, execSelector, interval, dedicatedMsgSender };
const { taskId, tx }: TaskTransaction = await gelatoOps.createTask(params);
const { taskId, tx }: TaskTransaction = await automate.createTask(params);
await tx.wait(); // Optionally wait for tx confirmation
console.log(`Task created, taskId: ${taskId} (tx hash: ${tx.hash})`);
```

5. Retrieve all your tasks:

```typescript
const activeTasks = await gelatoOps.getActiveTasks();
const activeTasks = await automate.getActiveTasks();
activeTasks.forEach((task: Task) => {
console.log(`- ${task.name} (${task.taskId})`);
});
Expand All @@ -92,13 +92,13 @@ console.log(`Task created, taskId: ${taskId} (tx hash: ${tx.hash})`);
6. Rename a task:

```typescript
await gelatoOps.renameTask(taskId, "Another Gelato name");
await automate.renameTask(taskId, "Another Gelato name");
```

7. Cancel a task:

```typescript
const { taskId, tx }: TaskTransaction = await gelatoOps.cancelTask(taskId);
const { taskId, tx }: TaskTransaction = await automate.cancelTask(taskId);
await tx.wait(); // Optionally wait for tx confirmation
console.log(`Task canceled, taskId: ${taskId} (tx hash: ${tx.hash})`);
```
Expand All @@ -110,23 +110,23 @@ If you need to override gas settings, you can pass an additional `Overrides` obj
```typescript
const params: CreateTaskOptions = { name, execAddress, execSelector, interval, dedicatedMsgSender };
const overrides: Overrides = { gasLimit: 2000000 };
const tx: TaskTransaction = await gelatoOps.createTask(params, overrides);
const tx: TaskTransaction = await automate.createTask(params, overrides);
```

9. Whitelisting msg.sender of function:

If you enabled `dedicatedMsgSender`, your task will be called via a dedicated `msg.sender` which you can whitelist on your smart contract for extra security.

If `dedicatedMsgSender` is set to false, `msg.sender` of the task will be the Ops contract.
If `dedicatedMsgSender` is set to false, `msg.sender` of the task will be the Automate contract.

To fetch your dedicated `msg.sender`:

```typescript
const { address } = await gelatoOps.getDedicatedMsgSender();
const { address } = await automate.getDedicatedMsgSender();
console.log("Dedicated msg.sender: ", address);
```


## Examples

Check out our tutorial repository [ops-sdk-hello-world](https://github.com/gelatodigital/ops-sdk-hello-world) for more in-depth examples.
Check out our tutorial repository [automate-sdk-hello-world](https://github.com/gelatodigital/automate-sdk-hello-world) for more in-depth examples.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "@gelatonetwork/ops-sdk",
"version": "2.0.7",
"description": "SDK to create Gelato Ops tasks",
"url": "https://github.com/gelatodigital/ops-sdk",
"name": "@gelatonetwork/automate-sdk",
"version": "2.1.0",
"description": "SDK to create Automate tasks",
"url": "https://github.com/gelatodigital/automate-sdk",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
Expand Down
33 changes: 16 additions & 17 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { GelatoAddressBook } from "../types";

export const OPS_TASKS_API =
"https://ops-task.fra.gelato.digital/1514007e8336fa99e6fe/api";
export const AUTOMATE_TASKS_API = "https://api.gelato.digital/automate/tasks";

export const ETH = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
export const ZERO_ADD = "0x0000000000000000000000000000000000000000";
Expand All @@ -27,48 +26,48 @@ export const CHAIN_ID = {

export const GELATO_ADDRESSES: GelatoAddressBook = {
[CHAIN_ID.MAINNET]: {
ops: "0xB3f5503f93d5Ef84b06993a1975B9D21B962892F",
automate: "0xB3f5503f93d5Ef84b06993a1975B9D21B962892F",
},
[CHAIN_ID.GOERLI]: {
ops: "0xc1C6805B857Bef1f412519C4A842522431aFed39",
automate: "0xc1C6805B857Bef1f412519C4A842522431aFed39",
},
[CHAIN_ID.OPTIMISTIC_GOERLI]: {
ops: "0x255F82563b5973264e89526345EcEa766DB3baB2",
automate: "0x255F82563b5973264e89526345EcEa766DB3baB2",
},
[CHAIN_ID.ARBITRUM_GOERLI]: {
ops: "0xa5f9b728ecEB9A1F6FCC89dcc2eFd810bA4Dec41",
automate: "0xa5f9b728ecEB9A1F6FCC89dcc2eFd810bA4Dec41",
},
[CHAIN_ID.MATIC]: {
ops: "0x527a819db1eb0e34426297b03bae11F2f8B3A19E",
automate: "0x527a819db1eb0e34426297b03bae11F2f8B3A19E",
},
[CHAIN_ID.MUMBAI]: {
ops: "0xB3f5503f93d5Ef84b06993a1975B9D21B962892F",
automate: "0xB3f5503f93d5Ef84b06993a1975B9D21B962892F",
},
[CHAIN_ID.FANTOM]: {
ops: "0x6EDe1597c05A0ca77031cBA43Ab887ccf24cd7e8",
automate: "0x6EDe1597c05A0ca77031cBA43Ab887ccf24cd7e8",
},
[CHAIN_ID.ARBITRUM]: {
ops: "0xB3f5503f93d5Ef84b06993a1975B9D21B962892F",
automate: "0xB3f5503f93d5Ef84b06993a1975B9D21B962892F",
},
[CHAIN_ID.AVALANCHE]: {
ops: "0x8aB6aDbC1fec4F18617C9B889F5cE7F28401B8dB",
automate: "0x8aB6aDbC1fec4F18617C9B889F5cE7F28401B8dB",
},
[CHAIN_ID.BSC]: {
ops: "0x527a819db1eb0e34426297b03bae11F2f8B3A19E",
automate: "0x527a819db1eb0e34426297b03bae11F2f8B3A19E",
},
[CHAIN_ID.GNOSIS]: {
ops: "0x8aB6aDbC1fec4F18617C9B889F5cE7F28401B8dB",
automate: "0x8aB6aDbC1fec4F18617C9B889F5cE7F28401B8dB",
},
[CHAIN_ID.OPTIMISM]: {
ops: "0x340759c8346A1E6Ed92035FB8B6ec57cE1D82c2c",
automate: "0x340759c8346A1E6Ed92035FB8B6ec57cE1D82c2c",
},
[CHAIN_ID.MOONBEAM]: {
ops: "0x6c3224f9b3feE000A444681d5D45e4532D5BA531",
automate: "0x6c3224f9b3feE000A444681d5D45e4532D5BA531",
},
[CHAIN_ID.MOONRIVER]: {
ops: "0x86B7e611194978F556007ac1F52D09d114D8f160",
automate: "0x86B7e611194978F556007ac1F52D09d114D8f160",
},
[CHAIN_ID.CRONOS]: {
ops: "0x86B7e611194978F556007ac1F52D09d114D8f160",
automate: "0x86B7e611194978F556007ac1F52D09d114D8f160",
},
};
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export declare namespace LibDataTypes {
};
}

export interface OpsInterface extends utils.Interface {
export interface AutomateInterface extends utils.Interface {
functions: {
"cancelTask(bytes32)": FunctionFragment;
"createTask(address,bytes,(uint8[],bytes[]),address)": FunctionFragment;
Expand Down Expand Up @@ -164,12 +164,12 @@ export interface OpsInterface extends utils.Interface {
events: {};
}

export interface Ops extends BaseContract {
export interface Automate extends BaseContract {
connect(signerOrProvider: Signer | Provider | string): this;
attach(addressOrName: string): this;
deployed(): Promise<this>;

interface: OpsInterface;
interface: AutomateInterface;

queryFilter<TEvent extends TypedEvent>(
event: TypedEventFilter<TEvent>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import type {
OnEvent,
} from "./common";

export interface OpsProxyFactoryInterface extends utils.Interface {
export interface AutomateProxyFactoryInterface extends utils.Interface {
functions: {
"deploy()": FunctionFragment;
"deployFor(address)": FunctionFragment;
Expand Down Expand Up @@ -111,12 +111,12 @@ export type DeployProxyEvent = TypedEvent<

export type DeployProxyEventFilter = TypedEventFilter<DeployProxyEvent>;

export interface OpsProxyFactory extends BaseContract {
export interface AutomateProxyFactory extends BaseContract {
connect(signerOrProvider: Signer | Provider | string): this;
attach(addressOrName: string): this;
deployed(): Promise<this>;

interface: OpsProxyFactoryInterface;
interface: AutomateProxyFactoryInterface;

queryFilter<TEvent extends TypedEvent>(
event: TypedEventFilter<TEvent>,
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/contracts/types/factories/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export { Automate__factory } from "./Automate__factory";
export { AutomateProxyFactory__factory } from "./AutomateProxyFactory__factory";
export { Forwarder__factory } from "./Forwarder__factory";
export { Ops__factory } from "./Ops__factory";
export { OpsProxyFactory__factory } from "./OpsProxyFactory__factory";
export { ProxyModule__factory } from "./ProxyModule__factory";
8 changes: 4 additions & 4 deletions src/contracts/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export type { Automate } from "./Automate";
export type { AutomateProxyFactory } from "./AutomateProxyFactory";
export type { Forwarder } from "./Forwarder";
export type { Ops } from "./Ops";
export type { OpsProxyFactory } from "./OpsProxyFactory";
export type { ProxyModule } from "./ProxyModule";
export * as factories from "./factories";
export { Automate__factory } from "./factories/Automate__factory";
export { AutomateProxyFactory__factory } from "./factories/AutomateProxyFactory__factory";
export { Forwarder__factory } from "./factories/Forwarder__factory";
export { Ops__factory } from "./factories/Ops__factory";
export { OpsProxyFactory__factory } from "./factories/OpsProxyFactory__factory";
export { ProxyModule__factory } from "./factories/ProxyModule__factory";
6 changes: 3 additions & 3 deletions src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import dotenv from "dotenv";
import { ethers } from "ethers";
import { GelatoOpsSDK } from "./lib";
import { AutomateSDK } from "./lib";
dotenv.config();

if (!process.env.PK) throw new Error("Missing env PK");
Expand All @@ -17,10 +17,10 @@ const main = async () => {
const provider = new ethers.providers.JsonRpcProvider(providerUrl);

const wallet = new ethers.Wallet(pk as string, provider);
const sdk = new GelatoOpsSDK(chainId, wallet);
const sdk = new AutomateSDK(chainId, wallet);

const taskId = await sdk.createTask({
name: "OpsSdkTest",
name: "AutomateSdkTest",
execAddress: iceCreamAddress,
execSelector: iceCreamInterface.getSighash("lick"),
execData: iceCreamInterface.encodeFunctionData("lick", [1]),
Expand Down
2 changes: 1 addition & 1 deletion src/lib/GelatoOpsModule.ts → src/lib/AutomateModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
TimeParams,
} from "../types/Module.interface";

export class GelatoOpsModule {
export class AutomateModule {
public encodeModuleArgs = (
moduleArgsParams: Partial<ModuleArgsParams>
): ModuleData => {
Expand Down
Loading

0 comments on commit 374e006

Please sign in to comment.