Skip to content

Commit

Permalink
feat: support ops module (#15)
Browse files Browse the repository at this point in the history
* feat: support ops module

* feat: add getOpsProxyAddress & update readme

* chore: show if OpsProxy is deployed

* chore: rename deployed var for clarity

* chore: rename to off-chain resolver

* chore: add compilerOptions module to esnext (#16)

* chore: add compilerOptions module to esnext

Update GelatoOpsSDK.ts

* chore: rename return address property from getOpsProxyAddress

* feat: ops module class (#18)

* feat: GelatoOpsModule helper class

* fix: missing export

* chore: decodeModuleArgs return Required<ModuleArgs>

* chore: rename ModuleArgsParams

* chore: bump next ops-sdk version

* fix: remove ogoerli forwarder

* fix: time module encoding

* chore: bump next version number

* chore: rename proxy to dedicatedMsgSender

* chore: bump version to 2.0.2-next

* fix: proxy

* chore: update readme

* chore: remove oresolver (#21)

* chore: remove oResolver

* chore: expose module helpers

* chore: remove deprecated networks

* chore: remove offChainResolver options

* chore: bump sdk package version

Co-authored-by: Renato Cardoso <[email protected]>
Co-authored-by: Sylvain Goumy <[email protected]>
  • Loading branch information
3 people authored Nov 2, 2022
1 parent 0aee8e1 commit ef31b14
Show file tree
Hide file tree
Showing 21 changed files with 2,540 additions and 1,143 deletions.
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,17 @@ interface CreateTaskOptions {
interval?: number; // execution interval in seconds
startTime?: number; // start timestamp in seconds or 0 to start immediately (default: 0)

// Proxy caller
dedicatedMsgSender: boolean; // task will be called via a dedicated msg.sender which you can whitelist

// Single execution task
singleExec?: boolean; // task cancels itself after 1 execution if true.

// Payment params
useTreasury?: boolean; // use false if your task is self-paying (default: true)
}

const params: CreateTaskOptions = { name, execAddress, execSelector, interval };
const params: CreateTaskOptions = { name, execAddress, execSelector, interval, dedicatedMsgSender };
const { taskId, tx }: TaskTransaction = await gelatoOps.createTask(params);
await tx.wait(); // Optionally wait for tx confirmation
console.log(`Task created, taskId: ${taskId} (tx hash: ${tx.hash})`);
Expand Down Expand Up @@ -102,11 +108,24 @@ console.log(`Task canceled, taskId: ${taskId} (tx hash: ${tx.hash})`);
If you need to override gas settings, you can pass an additional `Overrides` object to `createTask` & `cancelTask` methods:

```typescript
const params: CreateTaskOptions = { name, execAddress, execSelector, interval };
const params: CreateTaskOptions = { name, execAddress, execSelector, interval, dedicatedMsgSender };
const overrides: Overrides = { gasLimit: 2000000 };
const tx: TaskTransaction = await gelatoOps.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.

To fetch your dedicated `msg.sender`:

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


## Examples

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gelatonetwork/ops-sdk",
"version": "1.1.3",
"version": "2.0.3",
"description": "SDK to create Gelato Ops tasks",
"url": "https://github.com/gelatodigital/ops-sdk",
"main": "dist/index.js",
Expand Down
31 changes: 1 addition & 30 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@ export const OPS_TASKS_API =
"https://ops-task.fra.gelato.digital/1514007e8336fa99e6fe/api";

export const ETH = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
export const ZERO_ADD = "0x0000000000000000000000000000000000000000";

export const CHAIN_ID = {
MAINNET: 1,
ROPSTEN: 3,
RINKEBY: 4,
GOERLI: 5,
OPTIMISM: 10,
CRONOS: 25,
KOVAN: 42,
OPTIMISTIC_GOERLI: 420,
OPTIMISTIC_KOVAN: 69,
BSC: 56,
GNOSIS: 100,
MATIC: 137,
Expand All @@ -30,74 +28,47 @@ export const CHAIN_ID = {
export const GELATO_ADDRESSES: GelatoAddressBook = {
[CHAIN_ID.MAINNET]: {
ops: "0xB3f5503f93d5Ef84b06993a1975B9D21B962892F",
forwarder: "0xA9AB392d9c725a302329434E92812fdeD02160d4",
},
[CHAIN_ID.ROPSTEN]: {
ops: "0x9C4771560d84222fD8B7d9f15C59193388cC81B3",
forwarder: "0xfaf634e4Db23B3A7d19bb9aB9B640531dbd5779E",
},
[CHAIN_ID.RINKEBY]: {
ops: "0x8c089073A9594a4FB03Fa99feee3effF0e2Bc58a",
forwarder: "0x04462c8ad55a3d970fd9b4944A2f4C7c15700883",
},
[CHAIN_ID.GOERLI]: {
ops: "0xc1C6805B857Bef1f412519C4A842522431aFed39",
forwarder: "0xe2b4403A3bC36b84d54eF088A923aE8575c88d94",
},
[CHAIN_ID.KOVAN]: {
ops: "0x6c3224f9b3feE000A444681d5D45e4532D5BA531",
forwarder: "0x4055cb250Ec8d539C5222EAa71fa7e30Fe94f8e9",
},
[CHAIN_ID.OPTIMISTIC_GOERLI]: {
ops: "0x255F82563b5973264e89526345EcEa766DB3baB2",
forwarder: "0x4e6C550173E53Ca83f369D2a681db280F30d9eC4",
},
[CHAIN_ID.OPTIMISTIC_KOVAN]: {
ops: "0xB3f5503f93d5Ef84b06993a1975B9D21B962892F",
forwarder: "0xa5f9b728ecEB9A1F6FCC89dcc2eFd810bA4Dec41",
},
[CHAIN_ID.MATIC]: {
ops: "0x527a819db1eb0e34426297b03bae11F2f8B3A19E",
forwarder: "0xCd8eE05B92746Ef168460D8809bDb26b7321ec30",
},
[CHAIN_ID.MUMBAI]: {
ops: "0xB3f5503f93d5Ef84b06993a1975B9D21B962892F",
forwarder: "0x4055cb250Ec8d539C5222EAa71fa7e30Fe94f8e9",
},
[CHAIN_ID.FANTOM]: {
ops: "0x6EDe1597c05A0ca77031cBA43Ab887ccf24cd7e8",
forwarder: "0x0f441882F5B00bced580c530e8B6d3d6906F2beD",
},
[CHAIN_ID.ARBITRUM]: {
ops: "0xB3f5503f93d5Ef84b06993a1975B9D21B962892F",
forwarder: "0x95f4538C3950CE0EF5821f2049aE2aC5cCade68D",
},
[CHAIN_ID.AVALANCHE]: {
ops: "0x8aB6aDbC1fec4F18617C9B889F5cE7F28401B8dB",
forwarder: "0xa5f9b728ecEB9A1F6FCC89dcc2eFd810bA4Dec41",
},
[CHAIN_ID.BSC]: {
ops: "0x527a819db1eb0e34426297b03bae11F2f8B3A19E",
forwarder: "0xB3f5503f93d5Ef84b06993a1975B9D21B962892F",
},
[CHAIN_ID.GNOSIS]: {
ops: "0x8aB6aDbC1fec4F18617C9B889F5cE7F28401B8dB",
forwarder: "0xB3f5503f93d5Ef84b06993a1975B9D21B962892F",
},
[CHAIN_ID.OPTIMISM]: {
ops: "0x340759c8346A1E6Ed92035FB8B6ec57cE1D82c2c",
forwarder: "0x95f4538C3950CE0EF5821f2049aE2aC5cCade68D",
},
[CHAIN_ID.MOONBEAM]: {
ops: "0x6c3224f9b3feE000A444681d5D45e4532D5BA531",
forwarder: "0x340759c8346A1E6Ed92035FB8B6ec57cE1D82c2c",
},
[CHAIN_ID.MOONRIVER]: {
ops: "0x86B7e611194978F556007ac1F52D09d114D8f160",
forwarder: "0x6c3224f9b3feE000A444681d5D45e4532D5BA531",
},
[CHAIN_ID.CRONOS]: {
ops: "0x86B7e611194978F556007ac1F52D09d114D8f160",
forwarder: "0xE196330228CdE3Bb6b29413f32A95C45ACcF4952",
},
};
Loading

0 comments on commit ef31b14

Please sign in to comment.