@orb-labs/orby-core 0.0.7 → 0.0.8

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.
@@ -17,7 +17,14 @@ export declare class AccountClusterActions extends LibraryRequest {
17
17
  getActivity(accountClusterId: string, limit?: number, offset?: number, order?: Order, startDate?: number, endDate?: number, filters?: {
18
18
  transactionHash?: string;
19
19
  address?: string;
20
- }[]): Promise<Activity[]>;
20
+ }[]): Promise<{
21
+ activities: Activity[];
22
+ pageInfo: {
23
+ hasNextPage: boolean;
24
+ hasPreviousPage: boolean;
25
+ totalCount: number;
26
+ };
27
+ }>;
21
28
  getPortfolioOverview(accountClusterId: string): Promise<FungibleTokenOverview>;
22
29
  getFungibleTokenPortfolio(accountClusterId: string): Promise<StandardizedBalance[]>;
23
30
  getFungibleTokenBalances(accountClusterId: string, offset?: number, limit?: number, chainId?: bigint, tokensToOmit?: string[]): Promise<StandardizedBalance[]>;
@@ -1,6 +1,6 @@
1
- import { extractAccountCluster, extractFungibleTokenOverview, extractStandardizedBalances, } from "../utils/action_helpers.js";
1
+ import { extractAccountCluster, extractActivities, extractFungibleTokenOverview, extractStandardizedBalances, } from "../utils/action_helpers.js";
2
2
  import { LibraryRequest } from "../entities/library_request.js";
3
- import { getChainIdFromOrbyChainId } from "../utils/utils.js";
3
+ import { getChainIdFromOrbyChainId, getOrbyChainId } from "../utils/utils.js";
4
4
  export class AccountClusterActions extends LibraryRequest {
5
5
  constructor(library, client, provider) {
6
6
  super(library, client, provider);
@@ -8,24 +8,39 @@ export class AccountClusterActions extends LibraryRequest {
8
8
  async createAccountCluster(accounts) {
9
9
  const formattedAccounts = accounts.map((account) => account.toAccountModel());
10
10
  const accountCluster = await this.sendRequest("orby_createAccountCluster", [
11
- { accounts: formattedAccounts },
11
+ {
12
+ accounts: formattedAccounts,
13
+ },
12
14
  ]);
13
15
  return extractAccountCluster(accountCluster);
14
16
  }
15
17
  async addToAccountCluster(accounts, accountClusterId) {
16
18
  const formattedAccounts = accounts.map((account) => account.toAccountModel());
17
19
  const accountCluster = await this.sendRequest("orby_addToAccountCluster", [
18
- { accounts: formattedAccounts, accountClusterId },
20
+ {
21
+ accounts: formattedAccounts,
22
+ accountClusterId,
23
+ },
19
24
  ]);
20
25
  return extractAccountCluster(accountCluster);
21
26
  }
22
27
  async removeFromAccountCluster(accounts, accountClusterId) {
23
28
  const formattedAccounts = accounts.map((account) => account.toAccountModel());
24
- const accountCluster = await this.sendRequest("orby_removeFromAccountCluster", [{ accounts: formattedAccounts, accountClusterId }]);
29
+ const accountCluster = await this.sendRequest("orby_removeFromAccountCluster", [
30
+ {
31
+ accounts: formattedAccounts,
32
+ accountClusterId,
33
+ },
34
+ ]);
25
35
  return extractAccountCluster(accountCluster);
26
36
  }
27
37
  async enableChainAbstractionForAccountCluster(accountClusterId, enable) {
28
- const { success, message, code } = await this.sendRequest("orby_enableChainAbstractionForAccountCluster", [{ accountClusterId, enable }]);
38
+ const { success, message, code } = await this.sendRequest("orby_enableChainAbstractionForAccountCluster", [
39
+ {
40
+ accountClusterId,
41
+ enable,
42
+ },
43
+ ]);
29
44
  if (code && message) {
30
45
  console.error("[enableChainAbstractionForAccountCluster]", code, message);
31
46
  return undefined;
@@ -35,12 +50,17 @@ export class AccountClusterActions extends LibraryRequest {
35
50
  async setCustomChainEndpointsForAccountCluster(accountClusterId, chainEndpoints) {
36
51
  const formattedEndpoints = chainEndpoints.map((endpoint) => {
37
52
  return {
38
- chainId: `EIP155-${endpoint.chainId}`,
53
+ chainId: getOrbyChainId(endpoint.chainId),
39
54
  customRpcUrls: endpoint.customRpcUrls,
40
55
  customIndexerUrls: endpoint.customIndexerUrls,
41
56
  };
42
57
  });
43
- const { success, message, code } = await this.sendRequest("orby_setCustomChainEndpointsForAccountCluster", [{ accountClusterId, chainEndpoints: formattedEndpoints }]);
58
+ const { success, message, code } = await this.sendRequest("orby_setCustomChainEndpointsForAccountCluster", [
59
+ {
60
+ accountClusterId,
61
+ chainEndpoints: formattedEndpoints,
62
+ },
63
+ ]);
44
64
  if (code && message) {
45
65
  console.error("[setCustomChainEndpointsForAccountCluster]", code, message);
46
66
  return undefined;
@@ -48,8 +68,13 @@ export class AccountClusterActions extends LibraryRequest {
48
68
  return success;
49
69
  }
50
70
  async removeCustomChainEndpointsForAccountCluster(accountClusterId, chainIds) {
51
- const formattedChainIds = chainIds.map((chainId) => `EIP155-${chainId}`);
52
- const { success, message, code } = await this.sendRequest("orby_removeCustomChainEndpointsForAccountCluster", [{ accountClusterId, chainIds: formattedChainIds }]);
71
+ const formattedChainIds = chainIds.map((chainId) => getOrbyChainId(chainId));
72
+ const { success, message, code } = await this.sendRequest("orby_removeCustomChainEndpointsForAccountCluster", [
73
+ {
74
+ accountClusterId,
75
+ chainIds: formattedChainIds,
76
+ },
77
+ ]);
53
78
  if (code && message) {
54
79
  console.error("[removeCustomChainEndpointsForAccountCluster]", code, message);
55
80
  return undefined;
@@ -57,7 +82,12 @@ export class AccountClusterActions extends LibraryRequest {
57
82
  return success;
58
83
  }
59
84
  async getCustomChainEndpointsForAccountCluster(accountClusterId, returnChainIdsOnly) {
60
- const { chainEndpoints, message, code } = await this.sendRequest("orby_getCustomChainEndpointsForAccountCluster", [{ accountClusterId, returnChainIdsOnly }]);
85
+ const { chainEndpoints, message, code } = await this.sendRequest("orby_getCustomChainEndpointsForAccountCluster", [
86
+ {
87
+ accountClusterId,
88
+ returnChainIdsOnly,
89
+ },
90
+ ]);
61
91
  if (code && message) {
62
92
  console.error("[getCustomChainEndpointsForAccountCluster]", code, message);
63
93
  return undefined;
@@ -71,7 +101,12 @@ export class AccountClusterActions extends LibraryRequest {
71
101
  });
72
102
  }
73
103
  async isChainSupportedOnAccountCluster(accountClusterId, chainId) {
74
- const { supportStatus, message, code } = await this.sendRequest("orby_isChainSupportedOnAccountCluster", [{ accountClusterId, chainId: `EIP155-${chainId}` }]);
104
+ const { supportStatus, message, code } = await this.sendRequest("orby_isChainSupportedOnAccountCluster", [
105
+ {
106
+ accountClusterId,
107
+ chainId: getOrbyChainId(chainId),
108
+ },
109
+ ]);
75
110
  if (code && message) {
76
111
  console.error("[isChainSupportedOnAccountCluster]", code, message);
77
112
  return undefined;
@@ -79,7 +114,12 @@ export class AccountClusterActions extends LibraryRequest {
79
114
  return supportStatus;
80
115
  }
81
116
  async getNodeRpcUrl(accountClusterId, chainId) {
82
- const { nodeRpcUrl, code, message } = await this.sendRequest("orby_getNodeRpcUrl", [[{ accountClusterId, chainId: `EIP155-${chainId}` }]]);
117
+ const { nodeRpcUrl, code, message } = await this.sendRequest("orby_getNodeRpcUrl", [
118
+ {
119
+ accountClusterId,
120
+ chainId: getOrbyChainId(chainId),
121
+ },
122
+ ]);
83
123
  if (code && message) {
84
124
  console.error("[getNodeRpcUrl]", code, message);
85
125
  return undefined;
@@ -90,7 +130,7 @@ export class AccountClusterActions extends LibraryRequest {
90
130
  const { virtualNodeRpcUrl, message, code } = await this.sendRequest("orby_getVirtualNodeRpcUrl", [
91
131
  {
92
132
  accountClusterId,
93
- chainId: `EIP155-${chainId}`,
133
+ chainId: getOrbyChainId(chainId),
94
134
  entrypointAccountAddress,
95
135
  },
96
136
  ]);
@@ -101,24 +141,22 @@ export class AccountClusterActions extends LibraryRequest {
101
141
  return virtualNodeRpcUrl;
102
142
  }
103
143
  async getActivity(accountClusterId, limit, offset, order, startDate, endDate, filters) {
104
- const { virtualNodeRpcUrl, code, message } = await this.sendRequest("orby_getActivity", [
105
- [
106
- {
107
- accountClusterId,
108
- limit,
109
- offset,
110
- order,
111
- startDate,
112
- endDate,
113
- filters,
114
- },
115
- ],
144
+ const { pageInfo, edges, code, message } = await this.sendRequest("orby_getActivity", [
145
+ {
146
+ accountClusterId,
147
+ limit,
148
+ offset,
149
+ order,
150
+ startDate,
151
+ endDate,
152
+ filters,
153
+ },
116
154
  ]);
117
155
  if (code && message) {
118
156
  console.error("[getActivity]", code, message);
119
157
  return undefined;
120
158
  }
121
- return virtualNodeRpcUrl;
159
+ return { activities: extractActivities(edges), pageInfo };
122
160
  }
123
161
  async getPortfolioOverview(accountClusterId) {
124
162
  const fungibleTokenOverview = await this.sendRequest("orby_getPortfolioOverview", [{ accountClusterId }]);
@@ -138,7 +176,7 @@ export class AccountClusterActions extends LibraryRequest {
138
176
  accountClusterId,
139
177
  offset,
140
178
  limit,
141
- chainId: chainId ? `EIP155-${chainId?.toString()}` : undefined,
179
+ chainId: chainId ? getOrbyChainId(chainId) : undefined,
142
180
  tokensToOmit,
143
181
  },
144
182
  ]);
@@ -0,0 +1,16 @@
1
+ import { BlockchainInformation } from "../types.js";
2
+ import { LibraryRequest } from "../entities/library_request.js";
3
+ import { LIBRARY_TYPE } from "../enums.js";
4
+ export declare class BlockchainActions extends LibraryRequest {
5
+ constructor(library: LIBRARY_TYPE, client?: any, provider?: any);
6
+ getBlockchainInformation(chainId: bigint): Promise<BlockchainInformation>;
7
+ listBlockchainsInformation(offset?: number, limit?: number): Promise<{
8
+ blockchains: BlockchainInformation[];
9
+ pageInfo: {
10
+ hasNextPage: boolean;
11
+ hasPreviousPage: boolean;
12
+ totalCount: number;
13
+ };
14
+ }>;
15
+ getChainsSupportedByDefault(): Promise<BlockchainInformation[]>;
16
+ }
@@ -0,0 +1,35 @@
1
+ import { extractBlockchainInformation, extractBlockchainInformations, } from "../utils/action_helpers.js";
2
+ import { LibraryRequest } from "../entities/library_request.js";
3
+ import { getOrbyChainId } from "../utils/utils.js";
4
+ export class BlockchainActions extends LibraryRequest {
5
+ constructor(library, client, provider) {
6
+ super(library, client, provider);
7
+ }
8
+ async getBlockchainInformation(chainId) {
9
+ const { blockchain, code, message } = await this.sendRequest("orby_getBlockchainInformation", [{ chainId: getOrbyChainId(chainId) }]);
10
+ if (code && message) {
11
+ console.error("[getBlockchainInformation]", code, message);
12
+ return undefined;
13
+ }
14
+ return extractBlockchainInformation(blockchain);
15
+ }
16
+ async listBlockchainsInformation(offset, limit) {
17
+ const { pageInfo, blockchains, code, message } = await this.sendRequest("orby_listBlockchainsInformation", [{ offset, limit }]);
18
+ if (code && message) {
19
+ console.error("[listBlockchainsInformation]", code, message);
20
+ return undefined;
21
+ }
22
+ return {
23
+ blockchains: extractBlockchainInformations(blockchains),
24
+ pageInfo,
25
+ };
26
+ }
27
+ async getChainsSupportedByDefault() {
28
+ const { blockchains, code, message } = await this.sendRequest("orby_getChainsSupportedByDefault", []);
29
+ if (code && message) {
30
+ console.error("[getChainsSupportedByDefault]", code, message);
31
+ return undefined;
32
+ }
33
+ return extractBlockchainInformations(blockchains);
34
+ }
35
+ }
@@ -1,4 +1,4 @@
1
- import { BlockchainInformation, ChainEndpoint, GasSponsorshipPolicy } from "../types.js";
1
+ import { ChainEndpoint, GasSponsorshipPolicy } from "../types.js";
2
2
  import { LIBRARY_TYPE } from "../enums.js";
3
3
  import { LibraryRequest } from "../entities/library_request.js";
4
4
  export declare class InstanceActions extends LibraryRequest {
@@ -6,7 +6,6 @@ export declare class InstanceActions extends LibraryRequest {
6
6
  setCustomChainEndpointsForInstance(chainEndpoints: ChainEndpoint[]): Promise<boolean>;
7
7
  removeCustomChainEndpointForInstance(chainIds: bigint[]): Promise<boolean>;
8
8
  getCustomChainEndpointsForInstance(returnChainIdsOnly: boolean): Promise<boolean>;
9
- getChainsSupportedByDefault(): Promise<BlockchainInformation[]>;
10
9
  enabledChainAbstractionForInstance(enable: boolean): Promise<boolean>;
11
10
  enableGasSponsorshipForInstance(enable: boolean): Promise<boolean>;
12
11
  getGasSponsorForInstance(): Promise<string>;
@@ -1,6 +1,6 @@
1
- import { extractBlockchainInformations, extractGasSponsorshipPolicy, } from "../utils/action_helpers.js";
1
+ import { extractGasSponsorshipPolicy, } from "../utils/action_helpers.js";
2
2
  import { LibraryRequest } from "../entities/library_request.js";
3
- import { getChainIdFromOrbyChainId } from "../utils/utils.js";
3
+ import { getChainIdFromOrbyChainId, getOrbyChainId } from "../utils/utils.js";
4
4
  export class InstanceActions extends LibraryRequest {
5
5
  constructor(library, client, provider) {
6
6
  super(library, client, provider);
@@ -8,7 +8,7 @@ export class InstanceActions extends LibraryRequest {
8
8
  async setCustomChainEndpointsForInstance(chainEndpoints) {
9
9
  const formattedEndpoints = chainEndpoints.map((endpoint) => {
10
10
  return {
11
- chainId: `EIP155-${endpoint.chainId}`,
11
+ chainId: getOrbyChainId(endpoint.chainId),
12
12
  customRpcUrls: endpoint.customRpcUrls,
13
13
  customIndexerUrls: endpoint.customIndexerUrls,
14
14
  };
@@ -21,7 +21,7 @@ export class InstanceActions extends LibraryRequest {
21
21
  return success;
22
22
  }
23
23
  async removeCustomChainEndpointForInstance(chainIds) {
24
- const formattedChainIds = chainIds.map((chainId) => `EIP155-${chainId}`);
24
+ const formattedChainIds = chainIds.map((chainId) => getOrbyChainId(chainId));
25
25
  const { success, code, message } = await this.sendRequest("orby_removeCustomChainEndpointForInstance", [{ chainIds: formattedChainIds }]);
26
26
  if (code && message) {
27
27
  console.error("[removeCustomChainEndpointForInstance]", code, message);
@@ -43,14 +43,6 @@ export class InstanceActions extends LibraryRequest {
43
43
  };
44
44
  });
45
45
  }
46
- async getChainsSupportedByDefault() {
47
- const { supportedChains, code, message } = await this.sendRequest("orby_getChainsSupportedByDefault", [{}]);
48
- if (code && message) {
49
- console.error("[getChainsSupportedByDefault]", code, message);
50
- return undefined;
51
- }
52
- return extractBlockchainInformations(supportedChains);
53
- }
54
46
  async enabledChainAbstractionForInstance(enable) {
55
47
  const { success, code, message } = await this.sendRequest("orby_enabledChainAbstractionForInstance", [{ enable }]);
56
48
  if (code && message) {
@@ -68,7 +60,7 @@ export class InstanceActions extends LibraryRequest {
68
60
  return success;
69
61
  }
70
62
  async getGasSponsorForInstance() {
71
- const { gasSponsor, code, message } = await this.sendRequest("orby_getGasSponsorForInstance", [{}]);
63
+ const { gasSponsor, code, message } = await this.sendRequest("orby_getGasSponsorForInstance", []);
72
64
  if (code && message) {
73
65
  console.error("[getGasSponsorForInstance]", code, message);
74
66
  return undefined;
@@ -76,7 +68,7 @@ export class InstanceActions extends LibraryRequest {
76
68
  return gasSponsor;
77
69
  }
78
70
  async getOrbyGasSponsorPolicyForInstance() {
79
- const { gasSponsorshipPolicy, message, code } = await this.sendRequest("orby_getOrbyGasSponsorPolicyForInstance", [{}]);
71
+ const { gasSponsorshipPolicy, message, code } = await this.sendRequest("orby_getOrbyGasSponsorPolicyForInstance", []);
80
72
  if (code && message) {
81
73
  console.error("[getOrbyGasSponsorPolicyForInstance]", code, message);
82
74
  return undefined;
@@ -92,7 +84,7 @@ export class InstanceActions extends LibraryRequest {
92
84
  return success;
93
85
  }
94
86
  async removeOrbyGasSponsorPolicyForInstance() {
95
- const { success, code, message } = await this.sendRequest("orby_removeOrbyGasSponsorPolicyForInstance", [{}]);
87
+ const { success, code, message } = await this.sendRequest("orby_removeOrbyGasSponsorPolicyForInstance", []);
96
88
  if (code && message) {
97
89
  console.error("[removeOrbyGasSponsorPolicyForInstance]", code, message);
98
90
  return undefined;
@@ -1,6 +1,6 @@
1
- import { OperationSet, OperationStatus, SignedOperation } from "../types.js";
1
+ import { OnchainOperation, OperationSet, OperationStatus, SignedOperation } from "../types.js";
2
2
  import { CurrencyAmount } from "../entities/financial/currency_amount.js";
3
- import { LIBRARY_TYPE, QuoteType } from "../enums.js";
3
+ import { LIBRARY_TYPE, OperationStatusType, QuoteType } from "../enums.js";
4
4
  import { LibraryRequest } from "../entities/library_request.js";
5
5
  export declare class OperationActions extends LibraryRequest {
6
6
  constructor(library: LIBRARY_TYPE, client?: any, provider?: any);
@@ -36,14 +36,14 @@ export declare class OperationActions extends LibraryRequest {
36
36
  standardizedTokenId: string;
37
37
  amount?: bigint;
38
38
  tokenSources?: {
39
- chainId: string;
39
+ chainId: bigint;
40
40
  address?: string;
41
41
  }[];
42
42
  }, output: {
43
43
  standardizedTokenId: string;
44
44
  amount?: bigint;
45
45
  tokenDestination?: {
46
- chainId: string;
46
+ chainId: bigint;
47
47
  address?: string;
48
48
  };
49
49
  }, gasToken?: {
@@ -57,22 +57,22 @@ export declare class OperationActions extends LibraryRequest {
57
57
  standardizedTokenId: string;
58
58
  amount?: bigint;
59
59
  tokenSources?: {
60
- chainId: string;
60
+ chainId: bigint;
61
61
  address?: string;
62
62
  }[];
63
63
  }, output: {
64
64
  standardizedTokenId: string;
65
65
  amount?: bigint;
66
66
  tokenDestination?: {
67
- chainId: string;
67
+ chainId: bigint;
68
68
  address?: string;
69
69
  };
70
70
  }): Promise<OperationSet>;
71
71
  getOperationsToBridge(accountClusterId: string, standardizedTokenId: string, amount: bigint, tokenSources?: {
72
- chainId: string;
72
+ chainId: bigint;
73
73
  address?: string;
74
74
  }[], tokenDestination?: {
75
- chainId: string;
75
+ chainId: bigint;
76
76
  address?: string;
77
77
  }, gasToken?: {
78
78
  standardizedTokenId: string;
@@ -81,4 +81,13 @@ export declare class OperationActions extends LibraryRequest {
81
81
  address?: string;
82
82
  }[];
83
83
  }): Promise<OperationSet>;
84
+ subscribeToOperationStatuses(ids?: string[], onOperationStatusesUpdateCallback?: (statusSummary: OperationStatusType, primaryOperationStatus?: OperationStatus, allOperationStatuses?: OperationStatus[]) => void): {
85
+ intervalId: number | null;
86
+ };
87
+ sendOperationSet(accountClusterId: string, operationSet: OperationSet, signOperation: (operation: OnchainOperation) => Promise<SignedOperation | undefined>): Promise<{
88
+ success: boolean;
89
+ operationSetId?: string;
90
+ primaryOperationStatus?: OperationStatus;
91
+ operationResponses?: OperationStatus[];
92
+ }>;
84
93
  }