@avaprotocol/sdk-js 0.7.1 → 0.7.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/README.md CHANGED
@@ -81,28 +81,12 @@ To ensure the SDK is functioning correctly, we have a comprehensive test suite.
81
81
 
82
82
  This will execute all unit and integration tests. Make sure all tests pass before submitting a pull request or deploying changes.
83
83
 
84
- ## Version Management
85
-
86
- This project uses [Changesets](https://github.com/changesets/changesets) to manage versions and changelogs. To contribute changes:
87
-
88
- 1. Make your changes to the codebase.
89
- 2. Run `npm run changeset` to create a new changeset.
90
- 3. Follow the prompts to describe your changes.
91
- 4. Commit the generated changeset file along with your changes.
92
-
93
- To release a new version:
94
-
95
- 1. Run `npm run version` to update package versions and changelogs.
96
- 2. Review and commit the changes.
97
- 3. Run `npm run release` to publish the new version to npm.
98
-
99
- For more detailed information on using Changesets, refer to the [Changesets documentation](https://github.com/changesets/changesets/blob/main/docs/intro-to-using-changesets.md).
100
-
101
84
  ## Release Process
102
85
 
103
86
  This repository uses a two-step workflow process for creating new releases:
104
87
 
105
88
  1. **Record changeset workflow**
89
+
106
90
  - Go to the "Actions" tab in GitHub, and run the "Record Changeset" workflow
107
91
  - Select the version bump type:
108
92
  - `patch` for backwards-compatible bug fixes (0.0.x)
@@ -112,15 +96,19 @@ This repository uses a two-step workflow process for creating new releases:
112
96
 
113
97
  2. **Create release workflow**
114
98
  - Go to the "Actions" tab in GitHub and run the "Create Release" workflow. This will run `npx changeset version` to bump up version in `package.json` based on the recorded changeset files. It will also create a new GitHub Release if the new version is higher than the current version in `package.json`.
99
+ 3. **Publish to NPM**
100
+ - After the last step, the version number in `package.json` is updated and a git tag with the new version number is created. Now you can publish the production version to NPM using `npm publish`.
101
+
102
+ ### NPM Publishing Dev Versions
103
+
104
+ The NPM publishing of dev versions can be handled manually, since the test cases reference the dist folder and don’t require a new version on NPM. NPM publish on dev tag is only required for testing the new version in a web app.
115
105
 
116
- ### NPM Publishing
106
+ 1. Publish a dev version and test it in your local environment. The `npm publish` will use the version number in `package.json`, so run `npm version prerelease --preid=dev` first if you need a new version number.
117
107
 
118
- The NPM publishing should be handled manually, since the test cases reference the dist folder and don’t require a new version on NPM. NPM publish on dev tag is only required for testing the new version in a web app.
119
- 1. Publish a dev version and test it in your local environment:
120
108
  ```bash
121
- # Update version with dev tag in package.json
109
+ # Optionally, update version with dev tag in package.json
122
110
  npm version prerelease --preid=dev
123
-
111
+
124
112
  # Publish to npm with dev tag
125
113
  npm publish --tag dev
126
114
  ```
@@ -131,8 +119,6 @@ The NPM publishing should be handled manually, since the test cases reference th
131
119
  npm publish
132
120
  ```
133
121
 
134
- > **Note**: Make sure to run these workflows in order. The Version Bump workflow must complete successfully before running the Create Release workflow.
135
-
136
122
  ### Utility Scripts
137
123
 
138
124
  To generate the key request message for signing, you can run the following command:
package/dist/index.d.mts CHANGED
@@ -474,8 +474,8 @@ declare namespace BranchAction {
474
474
  }
475
475
 
476
476
  declare class TaskAction extends jspb.Message {
477
- getTaskType(): TaskType;
478
- setTaskType(value: TaskType): TaskAction;
477
+ getTaskType(): TaskType$1;
478
+ setTaskType(value: TaskType$1): TaskAction;
479
479
  getId(): string;
480
480
  setId(value: string): TaskAction;
481
481
  getName(): string;
@@ -527,7 +527,7 @@ declare class TaskAction extends jspb.Message {
527
527
 
528
528
  declare namespace TaskAction {
529
529
  export type AsObject = {
530
- taskType: TaskType,
530
+ taskType: TaskType$1,
531
531
  id: string,
532
532
  name: string,
533
533
  nextList: Array<string>,
@@ -566,53 +566,53 @@ declare namespace Execution {
566
566
  }
567
567
  }
568
568
 
569
- declare class Task$1 extends jspb.Message {
569
+ declare class Task extends jspb.Message {
570
570
 
571
571
  hasId(): boolean;
572
572
  clearId(): void;
573
573
  getId(): UUID | undefined;
574
- setId(value?: UUID): Task$1;
574
+ setId(value?: UUID): Task;
575
575
  getOwner(): string;
576
- setOwner(value: string): Task$1;
576
+ setOwner(value: string): Task;
577
577
  getSmartAccountAddress(): string;
578
- setSmartAccountAddress(value: string): Task$1;
578
+ setSmartAccountAddress(value: string): Task;
579
579
 
580
580
  hasTrigger(): boolean;
581
581
  clearTrigger(): void;
582
582
  getTrigger(): TaskTrigger | undefined;
583
- setTrigger(value?: TaskTrigger): Task$1;
583
+ setTrigger(value?: TaskTrigger): Task;
584
584
  clearNodesList(): void;
585
585
  getNodesList(): Array<TaskAction>;
586
- setNodesList(value: Array<TaskAction>): Task$1;
586
+ setNodesList(value: Array<TaskAction>): Task;
587
587
  addNodes(value?: TaskAction, index?: number): TaskAction;
588
588
  getStartAt(): number;
589
- setStartAt(value: number): Task$1;
589
+ setStartAt(value: number): Task;
590
590
  getExpiredAt(): number;
591
- setExpiredAt(value: number): Task$1;
591
+ setExpiredAt(value: number): Task;
592
592
  getMemo(): string;
593
- setMemo(value: string): Task$1;
593
+ setMemo(value: string): Task;
594
594
  getCompletedAt(): number;
595
- setCompletedAt(value: number): Task$1;
595
+ setCompletedAt(value: number): Task;
596
596
  getStatus(): TaskStatus;
597
- setStatus(value: TaskStatus): Task$1;
597
+ setStatus(value: TaskStatus): Task;
598
598
  getRepeatable(): boolean;
599
- setRepeatable(value: boolean): Task$1;
599
+ setRepeatable(value: boolean): Task;
600
600
  clearExecutionsList(): void;
601
601
  getExecutionsList(): Array<Execution>;
602
- setExecutionsList(value: Array<Execution>): Task$1;
602
+ setExecutionsList(value: Array<Execution>): Task;
603
603
  addExecutions(value?: Execution, index?: number): Execution;
604
604
 
605
605
  serializeBinary(): Uint8Array;
606
- toObject(includeInstance?: boolean): Task$1.AsObject;
607
- static toObject(includeInstance: boolean, msg: Task$1): Task$1.AsObject;
606
+ toObject(includeInstance?: boolean): Task.AsObject;
607
+ static toObject(includeInstance: boolean, msg: Task): Task.AsObject;
608
608
  static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
609
609
  static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
610
- static serializeBinaryToWriter(message: Task$1, writer: jspb.BinaryWriter): void;
611
- static deserializeBinary(bytes: Uint8Array): Task$1;
612
- static deserializeBinaryFromReader(message: Task$1, reader: jspb.BinaryReader): Task$1;
610
+ static serializeBinaryToWriter(message: Task, writer: jspb.BinaryWriter): void;
611
+ static deserializeBinary(bytes: Uint8Array): Task;
612
+ static deserializeBinaryFromReader(message: Task, reader: jspb.BinaryReader): Task;
613
613
  }
614
614
 
615
- declare namespace Task$1 {
615
+ declare namespace Task {
616
616
  export type AsObject = {
617
617
  id?: UUID.AsObject,
618
618
  owner: string,
@@ -939,7 +939,7 @@ declare enum TriggerType {
939
939
  EXPRESSIONTRIGGER = 2,
940
940
  }
941
941
 
942
- declare enum TaskType {
942
+ declare enum TaskType$1 {
943
943
  ETHTRANSFERTASK = 0,
944
944
  CONTRACTEXECUTIONTASK = 1,
945
945
  GRAPHQLDATAQUERYTASK = 2,
@@ -1088,18 +1088,18 @@ interface IAggregatorClient {
1088
1088
  ): grpc.ClientUnaryCall;
1089
1089
  getTask(
1090
1090
  request: UUID,
1091
- callback: (error: grpc.ServiceError | null, response: Task$1) => void
1091
+ callback: (error: grpc.ServiceError | null, response: Task) => void
1092
1092
  ): grpc.ClientUnaryCall;
1093
1093
  getTask(
1094
1094
  request: UUID,
1095
1095
  metadata: grpc.Metadata,
1096
- callback: (error: grpc.ServiceError | null, response: Task$1) => void
1096
+ callback: (error: grpc.ServiceError | null, response: Task) => void
1097
1097
  ): grpc.ClientUnaryCall;
1098
1098
  getTask(
1099
1099
  request: UUID,
1100
1100
  metadata: grpc.Metadata,
1101
1101
  options: Partial<grpc.CallOptions>,
1102
- callback: (error: grpc.ServiceError | null, response: Task$1) => void
1102
+ callback: (error: grpc.ServiceError | null, response: Task) => void
1103
1103
  ): grpc.ClientUnaryCall;
1104
1104
  cancelTask(
1105
1105
  request: UUID,
@@ -1336,18 +1336,18 @@ declare class AggregatorClient extends grpc.Client implements IAggregatorClient
1336
1336
  ): grpc.ClientUnaryCall;
1337
1337
  public getTask(
1338
1338
  request: UUID,
1339
- callback: (error: grpc.ServiceError | null, response: Task$1) => void
1339
+ callback: (error: grpc.ServiceError | null, response: Task) => void
1340
1340
  ): grpc.ClientUnaryCall;
1341
1341
  public getTask(
1342
1342
  request: UUID,
1343
1343
  metadata: grpc.Metadata,
1344
- callback: (error: grpc.ServiceError | null, response: Task$1) => void
1344
+ callback: (error: grpc.ServiceError | null, response: Task) => void
1345
1345
  ): grpc.ClientUnaryCall;
1346
1346
  public getTask(
1347
1347
  request: UUID,
1348
1348
  metadata: grpc.Metadata,
1349
1349
  options: Partial<grpc.CallOptions>,
1350
- callback: (error: grpc.ServiceError | null, response: Task$1) => void
1350
+ callback: (error: grpc.ServiceError | null, response: Task) => void
1351
1351
  ): grpc.ClientUnaryCall;
1352
1352
  public cancelTask(
1353
1353
  request: UUID,
@@ -1458,60 +1458,101 @@ declare class AggregatorClient extends grpc.Client implements IAggregatorClient
1458
1458
 
1459
1459
  type Environment = "production" | "development" | "staging";
1460
1460
  declare const AUTH_KEY_HEADER = "authKey";
1461
+ interface RequestOptions {
1462
+ authKey: string;
1463
+ }
1461
1464
  interface GetKeyResponse {
1462
- key: string;
1465
+ authKey: string;
1463
1466
  }
1464
1467
  interface ClientOption {
1465
1468
  endpoint: string;
1466
- jwtApiKey?: string;
1467
1469
  }
1468
- interface Task {
1470
+ interface TaskType {
1469
1471
  id: string;
1470
- status: string;
1471
- result?: any;
1472
- error?: string;
1472
+ owner: string;
1473
+ smartAccountAddress: string;
1474
+ trigger: {
1475
+ triggerType: number;
1476
+ schedule?: any;
1477
+ contractQuery?: any;
1478
+ expression: {
1479
+ expression: string;
1480
+ };
1481
+ };
1482
+ nodesList: Array<{
1483
+ taskType: number;
1484
+ id: string;
1485
+ name: string;
1486
+ nextList: any[];
1487
+ ethTransfer?: any;
1488
+ contractExecution: any;
1489
+ graphqlDataQuery?: any;
1490
+ httpDataQuery?: any;
1491
+ customCode?: any;
1492
+ branch?: any;
1493
+ }>;
1494
+ startAt: number;
1495
+ expiredAt: number;
1496
+ memo: string;
1497
+ completedAt: number;
1498
+ status: number;
1499
+ repeatable: boolean;
1500
+ executionsList: any[];
1473
1501
  }
1474
1502
  interface CreateTaskResponse {
1475
1503
  id: string;
1476
1504
  }
1477
1505
  interface ListTasksResponse {
1478
- tasks: Task[];
1506
+ tasks: {
1507
+ id: string;
1508
+ status: string;
1509
+ }[];
1510
+ }
1511
+ interface CancelTaskResponse {
1512
+ value: boolean;
1513
+ }
1514
+ interface DeleteTaskResponse {
1515
+ value: boolean;
1479
1516
  }
1480
1517
  interface GetAddressesResponse {
1481
1518
  owner: string;
1482
1519
  smart_account_address: string;
1483
1520
  }
1484
- interface TransactionResp {
1485
- hash: string;
1486
- }
1487
- interface BalanceResp {
1488
- balance: string;
1489
- }
1490
1521
 
1491
1522
  declare class BaseClient {
1492
1523
  readonly endpoint: string;
1493
1524
  readonly rpcClient: AggregatorClient;
1494
1525
  protected metadata: Metadata;
1495
1526
  constructor(opts: ClientOption);
1496
- setAuthKey(key: string): void;
1497
- getAuthKey(): string | undefined;
1498
- isAuthenticated(): boolean;
1527
+ isAuthKeyValid(key: string): boolean;
1499
1528
  authWithAPIKey(apiKey: string, expiredAtEpoch: number): Promise<GetKeyResponse>;
1500
1529
  authWithSignature(address: string, signature: string, expiredAtEpoch: number): Promise<GetKeyResponse>;
1501
- protected _callRPC<TResponse, TRequest>(method: string, request: TRequest | any): Promise<TResponse>;
1530
+ protected _callRPC<TResponse, TRequest>(method: string, request: TRequest | any, options?: RequestOptions): Promise<TResponse>;
1502
1531
  }
1503
1532
  declare class Client extends BaseClient {
1504
1533
  constructor(config: ClientOption);
1505
- getAddresses(address: string): Promise<GetAddressesResponse>;
1534
+ getAddresses(address: string, { authKey }: {
1535
+ authKey: string;
1536
+ }): Promise<GetAddressesResponse>;
1506
1537
  createTask({ address, oracleContract, tokenContract, }: {
1507
1538
  address: string;
1508
1539
  tokenContract: string;
1509
1540
  oracleContract: string;
1541
+ }, { authKey }: {
1542
+ authKey: string;
1510
1543
  }): Promise<CreateTaskResponse>;
1511
- listTasks(address: string): Promise<ListTasksResponse>;
1512
- getTask(id: string): Promise<object>;
1513
- cancelTask(id: string): Promise<boolean>;
1514
- deleteTask(id: string): Promise<boolean>;
1515
- }
1516
-
1517
- export { AUTH_KEY_HEADER, type BalanceResp, type ClientOption, type CreateTaskResponse, type Environment, type GetAddressesResponse, type GetKeyResponse, type ListTasksResponse, type Task, type TransactionResp, Client as default, getKeyRequestMessage };
1544
+ listTasks(address: string, { authKey }: {
1545
+ authKey: string;
1546
+ }): Promise<ListTasksResponse>;
1547
+ getTask(id: string, { authKey }: {
1548
+ authKey: string;
1549
+ }): Promise<TaskType>;
1550
+ cancelTask(id: string, { authKey }: {
1551
+ authKey: string;
1552
+ }): Promise<CancelTaskResponse>;
1553
+ deleteTask(id: string, { authKey }: {
1554
+ authKey: string;
1555
+ }): Promise<DeleteTaskResponse>;
1556
+ }
1557
+
1558
+ export { AUTH_KEY_HEADER, type CancelTaskResponse, type ClientOption, type CreateTaskResponse, type DeleteTaskResponse, type Environment, type GetAddressesResponse, type GetKeyResponse, type ListTasksResponse, type RequestOptions, type TaskType, Client as default, getKeyRequestMessage };
package/dist/index.d.ts CHANGED
@@ -474,8 +474,8 @@ declare namespace BranchAction {
474
474
  }
475
475
 
476
476
  declare class TaskAction extends jspb.Message {
477
- getTaskType(): TaskType;
478
- setTaskType(value: TaskType): TaskAction;
477
+ getTaskType(): TaskType$1;
478
+ setTaskType(value: TaskType$1): TaskAction;
479
479
  getId(): string;
480
480
  setId(value: string): TaskAction;
481
481
  getName(): string;
@@ -527,7 +527,7 @@ declare class TaskAction extends jspb.Message {
527
527
 
528
528
  declare namespace TaskAction {
529
529
  export type AsObject = {
530
- taskType: TaskType,
530
+ taskType: TaskType$1,
531
531
  id: string,
532
532
  name: string,
533
533
  nextList: Array<string>,
@@ -566,53 +566,53 @@ declare namespace Execution {
566
566
  }
567
567
  }
568
568
 
569
- declare class Task$1 extends jspb.Message {
569
+ declare class Task extends jspb.Message {
570
570
 
571
571
  hasId(): boolean;
572
572
  clearId(): void;
573
573
  getId(): UUID | undefined;
574
- setId(value?: UUID): Task$1;
574
+ setId(value?: UUID): Task;
575
575
  getOwner(): string;
576
- setOwner(value: string): Task$1;
576
+ setOwner(value: string): Task;
577
577
  getSmartAccountAddress(): string;
578
- setSmartAccountAddress(value: string): Task$1;
578
+ setSmartAccountAddress(value: string): Task;
579
579
 
580
580
  hasTrigger(): boolean;
581
581
  clearTrigger(): void;
582
582
  getTrigger(): TaskTrigger | undefined;
583
- setTrigger(value?: TaskTrigger): Task$1;
583
+ setTrigger(value?: TaskTrigger): Task;
584
584
  clearNodesList(): void;
585
585
  getNodesList(): Array<TaskAction>;
586
- setNodesList(value: Array<TaskAction>): Task$1;
586
+ setNodesList(value: Array<TaskAction>): Task;
587
587
  addNodes(value?: TaskAction, index?: number): TaskAction;
588
588
  getStartAt(): number;
589
- setStartAt(value: number): Task$1;
589
+ setStartAt(value: number): Task;
590
590
  getExpiredAt(): number;
591
- setExpiredAt(value: number): Task$1;
591
+ setExpiredAt(value: number): Task;
592
592
  getMemo(): string;
593
- setMemo(value: string): Task$1;
593
+ setMemo(value: string): Task;
594
594
  getCompletedAt(): number;
595
- setCompletedAt(value: number): Task$1;
595
+ setCompletedAt(value: number): Task;
596
596
  getStatus(): TaskStatus;
597
- setStatus(value: TaskStatus): Task$1;
597
+ setStatus(value: TaskStatus): Task;
598
598
  getRepeatable(): boolean;
599
- setRepeatable(value: boolean): Task$1;
599
+ setRepeatable(value: boolean): Task;
600
600
  clearExecutionsList(): void;
601
601
  getExecutionsList(): Array<Execution>;
602
- setExecutionsList(value: Array<Execution>): Task$1;
602
+ setExecutionsList(value: Array<Execution>): Task;
603
603
  addExecutions(value?: Execution, index?: number): Execution;
604
604
 
605
605
  serializeBinary(): Uint8Array;
606
- toObject(includeInstance?: boolean): Task$1.AsObject;
607
- static toObject(includeInstance: boolean, msg: Task$1): Task$1.AsObject;
606
+ toObject(includeInstance?: boolean): Task.AsObject;
607
+ static toObject(includeInstance: boolean, msg: Task): Task.AsObject;
608
608
  static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
609
609
  static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
610
- static serializeBinaryToWriter(message: Task$1, writer: jspb.BinaryWriter): void;
611
- static deserializeBinary(bytes: Uint8Array): Task$1;
612
- static deserializeBinaryFromReader(message: Task$1, reader: jspb.BinaryReader): Task$1;
610
+ static serializeBinaryToWriter(message: Task, writer: jspb.BinaryWriter): void;
611
+ static deserializeBinary(bytes: Uint8Array): Task;
612
+ static deserializeBinaryFromReader(message: Task, reader: jspb.BinaryReader): Task;
613
613
  }
614
614
 
615
- declare namespace Task$1 {
615
+ declare namespace Task {
616
616
  export type AsObject = {
617
617
  id?: UUID.AsObject,
618
618
  owner: string,
@@ -939,7 +939,7 @@ declare enum TriggerType {
939
939
  EXPRESSIONTRIGGER = 2,
940
940
  }
941
941
 
942
- declare enum TaskType {
942
+ declare enum TaskType$1 {
943
943
  ETHTRANSFERTASK = 0,
944
944
  CONTRACTEXECUTIONTASK = 1,
945
945
  GRAPHQLDATAQUERYTASK = 2,
@@ -1088,18 +1088,18 @@ interface IAggregatorClient {
1088
1088
  ): grpc.ClientUnaryCall;
1089
1089
  getTask(
1090
1090
  request: UUID,
1091
- callback: (error: grpc.ServiceError | null, response: Task$1) => void
1091
+ callback: (error: grpc.ServiceError | null, response: Task) => void
1092
1092
  ): grpc.ClientUnaryCall;
1093
1093
  getTask(
1094
1094
  request: UUID,
1095
1095
  metadata: grpc.Metadata,
1096
- callback: (error: grpc.ServiceError | null, response: Task$1) => void
1096
+ callback: (error: grpc.ServiceError | null, response: Task) => void
1097
1097
  ): grpc.ClientUnaryCall;
1098
1098
  getTask(
1099
1099
  request: UUID,
1100
1100
  metadata: grpc.Metadata,
1101
1101
  options: Partial<grpc.CallOptions>,
1102
- callback: (error: grpc.ServiceError | null, response: Task$1) => void
1102
+ callback: (error: grpc.ServiceError | null, response: Task) => void
1103
1103
  ): grpc.ClientUnaryCall;
1104
1104
  cancelTask(
1105
1105
  request: UUID,
@@ -1336,18 +1336,18 @@ declare class AggregatorClient extends grpc.Client implements IAggregatorClient
1336
1336
  ): grpc.ClientUnaryCall;
1337
1337
  public getTask(
1338
1338
  request: UUID,
1339
- callback: (error: grpc.ServiceError | null, response: Task$1) => void
1339
+ callback: (error: grpc.ServiceError | null, response: Task) => void
1340
1340
  ): grpc.ClientUnaryCall;
1341
1341
  public getTask(
1342
1342
  request: UUID,
1343
1343
  metadata: grpc.Metadata,
1344
- callback: (error: grpc.ServiceError | null, response: Task$1) => void
1344
+ callback: (error: grpc.ServiceError | null, response: Task) => void
1345
1345
  ): grpc.ClientUnaryCall;
1346
1346
  public getTask(
1347
1347
  request: UUID,
1348
1348
  metadata: grpc.Metadata,
1349
1349
  options: Partial<grpc.CallOptions>,
1350
- callback: (error: grpc.ServiceError | null, response: Task$1) => void
1350
+ callback: (error: grpc.ServiceError | null, response: Task) => void
1351
1351
  ): grpc.ClientUnaryCall;
1352
1352
  public cancelTask(
1353
1353
  request: UUID,
@@ -1458,60 +1458,101 @@ declare class AggregatorClient extends grpc.Client implements IAggregatorClient
1458
1458
 
1459
1459
  type Environment = "production" | "development" | "staging";
1460
1460
  declare const AUTH_KEY_HEADER = "authKey";
1461
+ interface RequestOptions {
1462
+ authKey: string;
1463
+ }
1461
1464
  interface GetKeyResponse {
1462
- key: string;
1465
+ authKey: string;
1463
1466
  }
1464
1467
  interface ClientOption {
1465
1468
  endpoint: string;
1466
- jwtApiKey?: string;
1467
1469
  }
1468
- interface Task {
1470
+ interface TaskType {
1469
1471
  id: string;
1470
- status: string;
1471
- result?: any;
1472
- error?: string;
1472
+ owner: string;
1473
+ smartAccountAddress: string;
1474
+ trigger: {
1475
+ triggerType: number;
1476
+ schedule?: any;
1477
+ contractQuery?: any;
1478
+ expression: {
1479
+ expression: string;
1480
+ };
1481
+ };
1482
+ nodesList: Array<{
1483
+ taskType: number;
1484
+ id: string;
1485
+ name: string;
1486
+ nextList: any[];
1487
+ ethTransfer?: any;
1488
+ contractExecution: any;
1489
+ graphqlDataQuery?: any;
1490
+ httpDataQuery?: any;
1491
+ customCode?: any;
1492
+ branch?: any;
1493
+ }>;
1494
+ startAt: number;
1495
+ expiredAt: number;
1496
+ memo: string;
1497
+ completedAt: number;
1498
+ status: number;
1499
+ repeatable: boolean;
1500
+ executionsList: any[];
1473
1501
  }
1474
1502
  interface CreateTaskResponse {
1475
1503
  id: string;
1476
1504
  }
1477
1505
  interface ListTasksResponse {
1478
- tasks: Task[];
1506
+ tasks: {
1507
+ id: string;
1508
+ status: string;
1509
+ }[];
1510
+ }
1511
+ interface CancelTaskResponse {
1512
+ value: boolean;
1513
+ }
1514
+ interface DeleteTaskResponse {
1515
+ value: boolean;
1479
1516
  }
1480
1517
  interface GetAddressesResponse {
1481
1518
  owner: string;
1482
1519
  smart_account_address: string;
1483
1520
  }
1484
- interface TransactionResp {
1485
- hash: string;
1486
- }
1487
- interface BalanceResp {
1488
- balance: string;
1489
- }
1490
1521
 
1491
1522
  declare class BaseClient {
1492
1523
  readonly endpoint: string;
1493
1524
  readonly rpcClient: AggregatorClient;
1494
1525
  protected metadata: Metadata;
1495
1526
  constructor(opts: ClientOption);
1496
- setAuthKey(key: string): void;
1497
- getAuthKey(): string | undefined;
1498
- isAuthenticated(): boolean;
1527
+ isAuthKeyValid(key: string): boolean;
1499
1528
  authWithAPIKey(apiKey: string, expiredAtEpoch: number): Promise<GetKeyResponse>;
1500
1529
  authWithSignature(address: string, signature: string, expiredAtEpoch: number): Promise<GetKeyResponse>;
1501
- protected _callRPC<TResponse, TRequest>(method: string, request: TRequest | any): Promise<TResponse>;
1530
+ protected _callRPC<TResponse, TRequest>(method: string, request: TRequest | any, options?: RequestOptions): Promise<TResponse>;
1502
1531
  }
1503
1532
  declare class Client extends BaseClient {
1504
1533
  constructor(config: ClientOption);
1505
- getAddresses(address: string): Promise<GetAddressesResponse>;
1534
+ getAddresses(address: string, { authKey }: {
1535
+ authKey: string;
1536
+ }): Promise<GetAddressesResponse>;
1506
1537
  createTask({ address, oracleContract, tokenContract, }: {
1507
1538
  address: string;
1508
1539
  tokenContract: string;
1509
1540
  oracleContract: string;
1541
+ }, { authKey }: {
1542
+ authKey: string;
1510
1543
  }): Promise<CreateTaskResponse>;
1511
- listTasks(address: string): Promise<ListTasksResponse>;
1512
- getTask(id: string): Promise<object>;
1513
- cancelTask(id: string): Promise<boolean>;
1514
- deleteTask(id: string): Promise<boolean>;
1515
- }
1516
-
1517
- export { AUTH_KEY_HEADER, type BalanceResp, type ClientOption, type CreateTaskResponse, type Environment, type GetAddressesResponse, type GetKeyResponse, type ListTasksResponse, type Task, type TransactionResp, Client as default, getKeyRequestMessage };
1544
+ listTasks(address: string, { authKey }: {
1545
+ authKey: string;
1546
+ }): Promise<ListTasksResponse>;
1547
+ getTask(id: string, { authKey }: {
1548
+ authKey: string;
1549
+ }): Promise<TaskType>;
1550
+ cancelTask(id: string, { authKey }: {
1551
+ authKey: string;
1552
+ }): Promise<CancelTaskResponse>;
1553
+ deleteTask(id: string, { authKey }: {
1554
+ authKey: string;
1555
+ }): Promise<DeleteTaskResponse>;
1556
+ }
1557
+
1558
+ export { AUTH_KEY_HEADER, type CancelTaskResponse, type ClientOption, type CreateTaskResponse, type DeleteTaskResponse, type Environment, type GetAddressesResponse, type GetKeyResponse, type ListTasksResponse, type RequestOptions, type TaskType, Client as default, getKeyRequestMessage };
package/dist/index.js CHANGED
@@ -4505,20 +4505,37 @@ var AggregatorClient = grpc.makeGenericClientConstructor(AggregatorService);
4505
4505
  // src/index.ts
4506
4506
  init_avs_pb();
4507
4507
 
4508
+ // src/types.ts
4509
+ var AUTH_KEY_HEADER = "authKey";
4510
+
4508
4511
  // src/task.ts
4509
4512
  var Task2 = class {
4510
- // result?: any;
4511
- // error?: string;
4513
+ // Add other missing properties here
4512
4514
  constructor(task) {
4513
- this.id = task.getId();
4515
+ this.id = task.getId()?.toString() || "";
4514
4516
  this.status = task.getStatus().toString();
4517
+ this.owner = task.getOwner();
4518
+ this.smartAccountAddress = task.getSmartAccountAddress();
4519
+ this.trigger = {
4520
+ triggerType: task.getTrigger()?.getTriggerType() || 0,
4521
+ schedule: task.getTrigger()?.getSchedule()?.toObject(),
4522
+ contractQuery: task.getTrigger()?.getContractQuery()?.toObject(),
4523
+ expression: task.getTrigger()?.getExpression()?.toObject() || {
4524
+ expression: ""
4525
+ }
4526
+ };
4527
+ this.nodesList = task.getNodesList();
4528
+ this.startAt = task.getStartAt();
4529
+ this.expiredAt = task.getExpiredAt();
4530
+ this.memo = task.getMemo();
4531
+ this.completedAt = task.getCompletedAt();
4532
+ this.status = task.getStatus();
4533
+ this.repeatable = task.getRepeatable();
4534
+ this.executionsList = task.getExecutionsList();
4515
4535
  }
4516
4536
  };
4517
4537
  var task_default = Task2;
4518
4538
 
4519
- // src/types.ts
4520
- var AUTH_KEY_HEADER = "authKey";
4521
-
4522
4539
  // src/index.ts
4523
4540
  var BaseClient = class {
4524
4541
  constructor(opts) {
@@ -4529,25 +4546,14 @@ var BaseClient = class {
4529
4546
  );
4530
4547
  this.metadata = new import_grpc_js.Metadata();
4531
4548
  }
4532
- setAuthKey(key) {
4533
- this.metadata.add(AUTH_KEY_HEADER, key);
4534
- }
4535
- getAuthKey() {
4536
- const authKey = this.metadata.get(AUTH_KEY_HEADER);
4537
- return authKey?.[0]?.toString();
4538
- }
4539
- isAuthenticated() {
4540
- const authKey = this.getAuthKey();
4541
- if (!authKey) {
4542
- return false;
4543
- }
4549
+ isAuthKeyValid(key) {
4544
4550
  try {
4545
- const [, payload] = authKey.split(".");
4551
+ const [, payload] = key.split(".");
4546
4552
  const decodedPayload = JSON.parse(atob(payload));
4547
4553
  const currentTimestamp = Math.floor(Date.now() / 1e3);
4548
4554
  return decodedPayload.exp > currentTimestamp;
4549
4555
  } catch (error) {
4550
- console.error("Error validating JWT token:", error);
4556
+ console.error("Error validating auth key:", error);
4551
4557
  return false;
4552
4558
  }
4553
4559
  }
@@ -4557,8 +4563,7 @@ var BaseClient = class {
4557
4563
  request.setExpiredAt(expiredAtEpoch);
4558
4564
  request.setSignature(apiKey);
4559
4565
  const result = await this._callRPC("getKey", request);
4560
- this.setAuthKey(result.getKey());
4561
- return { key: result.getKey() };
4566
+ return { authKey: result.getKey() };
4562
4567
  }
4563
4568
  // This flow can be used where the signature is generate from outside, such as in front-end and pass in
4564
4569
  async authWithSignature(address, signature, expiredAtEpoch) {
@@ -4570,14 +4575,17 @@ var BaseClient = class {
4570
4575
  "getKey",
4571
4576
  request
4572
4577
  );
4573
- this.setAuthKey(result.getKey());
4574
- return { key: result.getKey() };
4578
+ return { authKey: result.getKey() };
4575
4579
  }
4576
- _callRPC(method, request) {
4580
+ _callRPC(method, request, options) {
4581
+ const metadata = import_lodash.default.cloneDeep(this.metadata);
4582
+ if (options?.authKey) {
4583
+ metadata.set(AUTH_KEY_HEADER, options.authKey);
4584
+ }
4577
4585
  return new Promise((resolve, reject) => {
4578
4586
  this.rpcClient[method].bind(this.rpcClient)(
4579
4587
  request,
4580
- this.metadata,
4588
+ metadata,
4581
4589
  (error, response) => {
4582
4590
  if (error) reject(error);
4583
4591
  else resolve(response);
@@ -4590,10 +4598,10 @@ var Client = class extends BaseClient {
4590
4598
  constructor(config) {
4591
4599
  super(config);
4592
4600
  }
4593
- async getAddresses(address) {
4601
+ async getAddresses(address, { authKey }) {
4594
4602
  const request = new AddressRequest();
4595
4603
  request.setOwner(address);
4596
- const result = await this._callRPC("getSmartAccountAddress", request);
4604
+ const result = await this._callRPC("getSmartAccountAddress", request, { authKey });
4597
4605
  return {
4598
4606
  owner: address,
4599
4607
  smart_account_address: result.getSmartAccountAddress()
@@ -4603,7 +4611,7 @@ var Client = class extends BaseClient {
4603
4611
  address,
4604
4612
  oracleContract,
4605
4613
  tokenContract
4606
- }) {
4614
+ }, { authKey }) {
4607
4615
  const trigger = new TaskTrigger();
4608
4616
  trigger.setTriggerType(TriggerType.EXPRESSIONTRIGGER);
4609
4617
  trigger.setExpression(
@@ -4628,17 +4636,22 @@ var Client = class extends BaseClient {
4628
4636
  execution.setCallData(callData);
4629
4637
  action.setContractExecution(execution);
4630
4638
  const request = new CreateTaskReq().setTrigger(trigger).setActionsList([action]).setExpiredAt(Math.floor(Date.now() / 1e3) + 1e6);
4631
- const result = await this._callRPC("createTask", request);
4639
+ const result = await this._callRPC("createTask", request, { authKey });
4632
4640
  return {
4633
4641
  id: result.getId()
4634
4642
  };
4635
4643
  }
4636
- async listTasks(address) {
4644
+ async listTasks(address, { authKey }) {
4637
4645
  const request = new ListTasksReq();
4638
- const result = await this._callRPC("listTasks", request);
4646
+ const result = await this._callRPC("listTasks", request, { authKey });
4639
4647
  const tasks = import_lodash.default.map(
4640
4648
  result.getTasksList(),
4641
- (obj) => new task_default(obj)
4649
+ (obj) => {
4650
+ return {
4651
+ id: obj.getId(),
4652
+ status: import_lodash.default.capitalize(obj.getStatus().toString())
4653
+ };
4654
+ }
4642
4655
  );
4643
4656
  return {
4644
4657
  tasks
@@ -4646,32 +4659,40 @@ var Client = class extends BaseClient {
4646
4659
  }
4647
4660
  // TODO: specify the return type to match client’s requirements
4648
4661
  // Right now we simply return the original object from the server
4649
- async getTask(id) {
4662
+ async getTask(id, { authKey }) {
4650
4663
  const request = new UUID();
4651
4664
  request.setBytes(id);
4665
+ ``;
4652
4666
  const result = await this._callRPC(
4653
4667
  "getTask",
4654
- request
4668
+ request,
4669
+ { authKey }
4655
4670
  );
4656
- return result.toObject();
4671
+ return new task_default(result);
4657
4672
  }
4658
- async cancelTask(id) {
4673
+ async cancelTask(id, { authKey }) {
4659
4674
  const request = new UUID();
4660
4675
  request.setBytes(id);
4661
4676
  const result = await this._callRPC(
4662
4677
  "cancelTask",
4663
- request
4678
+ request,
4679
+ { authKey }
4664
4680
  );
4665
- return result.getValue();
4681
+ return {
4682
+ value: result.getValue()
4683
+ };
4666
4684
  }
4667
- async deleteTask(id) {
4685
+ async deleteTask(id, { authKey }) {
4668
4686
  const request = new UUID();
4669
4687
  request.setBytes(id);
4670
4688
  const result = await this._callRPC(
4671
4689
  "deleteTask",
4672
- request
4690
+ request,
4691
+ { authKey }
4673
4692
  );
4674
- return result.getValue();
4693
+ return {
4694
+ value: result.getValue()
4695
+ };
4675
4696
  }
4676
4697
  };
4677
4698
  // Annotate the CommonJS export names for ESM import in node:
package/dist/index.mjs CHANGED
@@ -4493,20 +4493,37 @@ var AggregatorClient = grpc.makeGenericClientConstructor(AggregatorService);
4493
4493
  // src/index.ts
4494
4494
  init_avs_pb();
4495
4495
 
4496
+ // src/types.ts
4497
+ var AUTH_KEY_HEADER = "authKey";
4498
+
4496
4499
  // src/task.ts
4497
4500
  var Task2 = class {
4498
- // result?: any;
4499
- // error?: string;
4501
+ // Add other missing properties here
4500
4502
  constructor(task) {
4501
- this.id = task.getId();
4503
+ this.id = task.getId()?.toString() || "";
4502
4504
  this.status = task.getStatus().toString();
4505
+ this.owner = task.getOwner();
4506
+ this.smartAccountAddress = task.getSmartAccountAddress();
4507
+ this.trigger = {
4508
+ triggerType: task.getTrigger()?.getTriggerType() || 0,
4509
+ schedule: task.getTrigger()?.getSchedule()?.toObject(),
4510
+ contractQuery: task.getTrigger()?.getContractQuery()?.toObject(),
4511
+ expression: task.getTrigger()?.getExpression()?.toObject() || {
4512
+ expression: ""
4513
+ }
4514
+ };
4515
+ this.nodesList = task.getNodesList();
4516
+ this.startAt = task.getStartAt();
4517
+ this.expiredAt = task.getExpiredAt();
4518
+ this.memo = task.getMemo();
4519
+ this.completedAt = task.getCompletedAt();
4520
+ this.status = task.getStatus();
4521
+ this.repeatable = task.getRepeatable();
4522
+ this.executionsList = task.getExecutionsList();
4503
4523
  }
4504
4524
  };
4505
4525
  var task_default = Task2;
4506
4526
 
4507
- // src/types.ts
4508
- var AUTH_KEY_HEADER = "authKey";
4509
-
4510
4527
  // src/index.ts
4511
4528
  var BaseClient = class {
4512
4529
  constructor(opts) {
@@ -4517,25 +4534,14 @@ var BaseClient = class {
4517
4534
  );
4518
4535
  this.metadata = new Metadata();
4519
4536
  }
4520
- setAuthKey(key) {
4521
- this.metadata.add(AUTH_KEY_HEADER, key);
4522
- }
4523
- getAuthKey() {
4524
- const authKey = this.metadata.get(AUTH_KEY_HEADER);
4525
- return authKey?.[0]?.toString();
4526
- }
4527
- isAuthenticated() {
4528
- const authKey = this.getAuthKey();
4529
- if (!authKey) {
4530
- return false;
4531
- }
4537
+ isAuthKeyValid(key) {
4532
4538
  try {
4533
- const [, payload] = authKey.split(".");
4539
+ const [, payload] = key.split(".");
4534
4540
  const decodedPayload = JSON.parse(atob(payload));
4535
4541
  const currentTimestamp = Math.floor(Date.now() / 1e3);
4536
4542
  return decodedPayload.exp > currentTimestamp;
4537
4543
  } catch (error) {
4538
- console.error("Error validating JWT token:", error);
4544
+ console.error("Error validating auth key:", error);
4539
4545
  return false;
4540
4546
  }
4541
4547
  }
@@ -4545,8 +4551,7 @@ var BaseClient = class {
4545
4551
  request.setExpiredAt(expiredAtEpoch);
4546
4552
  request.setSignature(apiKey);
4547
4553
  const result = await this._callRPC("getKey", request);
4548
- this.setAuthKey(result.getKey());
4549
- return { key: result.getKey() };
4554
+ return { authKey: result.getKey() };
4550
4555
  }
4551
4556
  // This flow can be used where the signature is generate from outside, such as in front-end and pass in
4552
4557
  async authWithSignature(address, signature, expiredAtEpoch) {
@@ -4558,14 +4563,17 @@ var BaseClient = class {
4558
4563
  "getKey",
4559
4564
  request
4560
4565
  );
4561
- this.setAuthKey(result.getKey());
4562
- return { key: result.getKey() };
4566
+ return { authKey: result.getKey() };
4563
4567
  }
4564
- _callRPC(method, request) {
4568
+ _callRPC(method, request, options) {
4569
+ const metadata = _.cloneDeep(this.metadata);
4570
+ if (options?.authKey) {
4571
+ metadata.set(AUTH_KEY_HEADER, options.authKey);
4572
+ }
4565
4573
  return new Promise((resolve, reject) => {
4566
4574
  this.rpcClient[method].bind(this.rpcClient)(
4567
4575
  request,
4568
- this.metadata,
4576
+ metadata,
4569
4577
  (error, response) => {
4570
4578
  if (error) reject(error);
4571
4579
  else resolve(response);
@@ -4578,10 +4586,10 @@ var Client = class extends BaseClient {
4578
4586
  constructor(config) {
4579
4587
  super(config);
4580
4588
  }
4581
- async getAddresses(address) {
4589
+ async getAddresses(address, { authKey }) {
4582
4590
  const request = new AddressRequest();
4583
4591
  request.setOwner(address);
4584
- const result = await this._callRPC("getSmartAccountAddress", request);
4592
+ const result = await this._callRPC("getSmartAccountAddress", request, { authKey });
4585
4593
  return {
4586
4594
  owner: address,
4587
4595
  smart_account_address: result.getSmartAccountAddress()
@@ -4591,7 +4599,7 @@ var Client = class extends BaseClient {
4591
4599
  address,
4592
4600
  oracleContract,
4593
4601
  tokenContract
4594
- }) {
4602
+ }, { authKey }) {
4595
4603
  const trigger = new TaskTrigger();
4596
4604
  trigger.setTriggerType(TriggerType.EXPRESSIONTRIGGER);
4597
4605
  trigger.setExpression(
@@ -4616,17 +4624,22 @@ var Client = class extends BaseClient {
4616
4624
  execution.setCallData(callData);
4617
4625
  action.setContractExecution(execution);
4618
4626
  const request = new CreateTaskReq().setTrigger(trigger).setActionsList([action]).setExpiredAt(Math.floor(Date.now() / 1e3) + 1e6);
4619
- const result = await this._callRPC("createTask", request);
4627
+ const result = await this._callRPC("createTask", request, { authKey });
4620
4628
  return {
4621
4629
  id: result.getId()
4622
4630
  };
4623
4631
  }
4624
- async listTasks(address) {
4632
+ async listTasks(address, { authKey }) {
4625
4633
  const request = new ListTasksReq();
4626
- const result = await this._callRPC("listTasks", request);
4634
+ const result = await this._callRPC("listTasks", request, { authKey });
4627
4635
  const tasks = _.map(
4628
4636
  result.getTasksList(),
4629
- (obj) => new task_default(obj)
4637
+ (obj) => {
4638
+ return {
4639
+ id: obj.getId(),
4640
+ status: _.capitalize(obj.getStatus().toString())
4641
+ };
4642
+ }
4630
4643
  );
4631
4644
  return {
4632
4645
  tasks
@@ -4634,32 +4647,40 @@ var Client = class extends BaseClient {
4634
4647
  }
4635
4648
  // TODO: specify the return type to match client’s requirements
4636
4649
  // Right now we simply return the original object from the server
4637
- async getTask(id) {
4650
+ async getTask(id, { authKey }) {
4638
4651
  const request = new UUID();
4639
4652
  request.setBytes(id);
4653
+ ``;
4640
4654
  const result = await this._callRPC(
4641
4655
  "getTask",
4642
- request
4656
+ request,
4657
+ { authKey }
4643
4658
  );
4644
- return result.toObject();
4659
+ return new task_default(result);
4645
4660
  }
4646
- async cancelTask(id) {
4661
+ async cancelTask(id, { authKey }) {
4647
4662
  const request = new UUID();
4648
4663
  request.setBytes(id);
4649
4664
  const result = await this._callRPC(
4650
4665
  "cancelTask",
4651
- request
4666
+ request,
4667
+ { authKey }
4652
4668
  );
4653
- return result.getValue();
4669
+ return {
4670
+ value: result.getValue()
4671
+ };
4654
4672
  }
4655
- async deleteTask(id) {
4673
+ async deleteTask(id, { authKey }) {
4656
4674
  const request = new UUID();
4657
4675
  request.setBytes(id);
4658
4676
  const result = await this._callRPC(
4659
4677
  "deleteTask",
4660
- request
4678
+ request,
4679
+ { authKey }
4661
4680
  );
4662
- return result.getValue();
4681
+ return {
4682
+ value: result.getValue()
4683
+ };
4663
4684
  }
4664
4685
  };
4665
4686
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@avaprotocol/sdk-js",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "description": "A JavaScript/TypeScript SDK designed to simplify integration with Ava Protocol's AVS",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",