@orb-labs/orby-core 0.0.1

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.
Files changed (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/dist/actions/account_cluster.d.ts +24 -0
  4. package/dist/actions/account_cluster.js +147 -0
  5. package/dist/actions/admin.d.ts +17 -0
  6. package/dist/actions/admin.js +42 -0
  7. package/dist/actions/application.d.ts +6 -0
  8. package/dist/actions/application.js +25 -0
  9. package/dist/actions/instance.d.ts +16 -0
  10. package/dist/actions/instance.js +94 -0
  11. package/dist/actions/operation.d.ts +78 -0
  12. package/dist/actions/operation.js +113 -0
  13. package/dist/actions/token.d.ts +15 -0
  14. package/dist/actions/token.js +46 -0
  15. package/dist/constants.d.ts +4 -0
  16. package/dist/constants.js +36 -0
  17. package/dist/entities/account.d.ts +14 -0
  18. package/dist/entities/account.js +52 -0
  19. package/dist/entities/financial/account_balance.d.ts +12 -0
  20. package/dist/entities/financial/account_balance.js +35 -0
  21. package/dist/entities/financial/asset.d.ts +31 -0
  22. package/dist/entities/financial/asset.js +42 -0
  23. package/dist/entities/financial/currency.d.ts +41 -0
  24. package/dist/entities/financial/currency.js +56 -0
  25. package/dist/entities/financial/currency_amount.d.ts +31 -0
  26. package/dist/entities/financial/currency_amount.js +81 -0
  27. package/dist/entities/financial/fungible_token.d.ts +41 -0
  28. package/dist/entities/financial/fungible_token.js +70 -0
  29. package/dist/entities/financial/fungible_token_amount.d.ts +33 -0
  30. package/dist/entities/financial/fungible_token_amount.js +84 -0
  31. package/dist/entities/financial/non_fungible_token.d.ts +39 -0
  32. package/dist/entities/financial/non_fungible_token.js +66 -0
  33. package/dist/entities/financial/semi_fungible_token.d.ts +41 -0
  34. package/dist/entities/financial/semi_fungible_token.js +68 -0
  35. package/dist/entities/library_request.d.ts +8 -0
  36. package/dist/entities/library_request.js +37 -0
  37. package/dist/entities/state.d.ts +22 -0
  38. package/dist/entities/state.js +105 -0
  39. package/dist/enums.d.ts +115 -0
  40. package/dist/enums.js +137 -0
  41. package/dist/index.d.ts +26 -0
  42. package/dist/index.js +47 -0
  43. package/dist/interfaces/account_cluster.d.ts +22 -0
  44. package/dist/interfaces/account_cluster.js +2 -0
  45. package/dist/interfaces/admin.d.ts +14 -0
  46. package/dist/interfaces/admin.js +2 -0
  47. package/dist/interfaces/application.d.ts +3 -0
  48. package/dist/interfaces/application.js +2 -0
  49. package/dist/interfaces/instance.d.ts +13 -0
  50. package/dist/interfaces/instance.js +2 -0
  51. package/dist/interfaces/operation.d.ts +76 -0
  52. package/dist/interfaces/operation.js +2 -0
  53. package/dist/interfaces/orby.d.ts +8 -0
  54. package/dist/interfaces/orby.js +2 -0
  55. package/dist/interfaces/token.d.ts +12 -0
  56. package/dist/interfaces/token.js +2 -0
  57. package/dist/types.d.ts +143 -0
  58. package/dist/types.js +2 -0
  59. package/dist/utils/utils.d.ts +26 -0
  60. package/dist/utils/utils.js +319 -0
  61. package/dist/utils/validateAndParseAddress.d.ts +10 -0
  62. package/dist/utils/validateAndParseAddress.js +29 -0
  63. package/package.json +25 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Orb Labs, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # rpc-core
@@ -0,0 +1,24 @@
1
+ import { Account } from "../entities/account";
2
+ import { AccountCluster, Activity, ChainEndpoint, FungibleTokenOverview, StandardizedBalance } from "../types";
3
+ import { ChainSupportStatus, LIBRARY_TYPE, Order } from "../enums";
4
+ import { LibraryRequest } from "../entities/library_request";
5
+ export declare class AccountClusterActions extends LibraryRequest {
6
+ constructor(library: LIBRARY_TYPE, client?: any, provider?: any);
7
+ createAccountCluster(accounts: Account[]): Promise<AccountCluster>;
8
+ addToAccountCluster(accounts: Account[], accountClusterId: string): Promise<AccountCluster>;
9
+ removeFromAccountCluster(accounts: Account[], accountClusterId: string): Promise<AccountCluster>;
10
+ enableChainAbstractionForAccountCluster(accountClusterId: string, enable: boolean): Promise<boolean>;
11
+ setCustomChainEndpointsForAccountCluster(accountClusterId: string, chainEndpoints: ChainEndpoint[]): Promise<boolean>;
12
+ removeCustomChainEndpointsForAccountCluster(accountClusterId: string, chainIds: bigint[]): Promise<boolean>;
13
+ getCustomChainEndpointsForAccountCluster(accountClusterId: string, returnChainIdsOnly: boolean): Promise<boolean>;
14
+ isChainSupportedOnAccountCluster(accountClusterId: string, chainId: bigint): Promise<ChainSupportStatus>;
15
+ getNodeRpcUrl(accountClusterId: string, chainId: bigint): Promise<string>;
16
+ getVirtualNodeRpcUrl(accountClusterId: string, chainId: bigint, entrypointAccountAddress: string): Promise<string>;
17
+ getActivity(accountClusterId: string, limit?: number, offset?: number, order?: Order, startDate?: number, endDate?: number, filters?: {
18
+ transactionHash?: string;
19
+ address?: string;
20
+ }[]): Promise<Activity[]>;
21
+ getPortfolioOverview(accountClusterId: string): Promise<FungibleTokenOverview>;
22
+ getFungibleTokenPortfolio(accountClusterId: string): Promise<FungibleTokenOverview>;
23
+ getFungibleTokenBalances(accountClusterId: string, offset?: number, limit?: number, tokensToOmit?: string[]): Promise<StandardizedBalance[]>;
24
+ }
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.AccountClusterActions = void 0;
13
+ const utils_1 = require("../utils/utils");
14
+ const library_request_1 = require("../entities/library_request");
15
+ class AccountClusterActions extends library_request_1.LibraryRequest {
16
+ constructor(library, client, provider) {
17
+ super(library, client, provider);
18
+ }
19
+ createAccountCluster(accounts) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ const formattedAccounts = accounts.map((account) => account.toAccountModel());
22
+ const accountCluster = yield this.sendRequest("orby_createAccountCluster", [
23
+ { accounts: formattedAccounts },
24
+ ]);
25
+ return (0, utils_1.extractAccountCluster)(accountCluster);
26
+ });
27
+ }
28
+ addToAccountCluster(accounts, accountClusterId) {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ const formattedAccounts = accounts.map((account) => account.toAccountModel());
31
+ const accountCluster = yield this.sendRequest("orby_addToAccountCluster", [
32
+ { accounts: formattedAccounts, accountClusterId },
33
+ ]);
34
+ return (0, utils_1.extractAccountCluster)(accountCluster);
35
+ });
36
+ }
37
+ removeFromAccountCluster(accounts, accountClusterId) {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ const formattedAccounts = accounts.map((account) => account.toAccountModel());
40
+ const accountCluster = yield this.sendRequest("orby_removeFromAccountCluster", [{ accounts: formattedAccounts, accountClusterId }]);
41
+ return (0, utils_1.extractAccountCluster)(accountCluster);
42
+ });
43
+ }
44
+ enableChainAbstractionForAccountCluster(accountClusterId, enable) {
45
+ return __awaiter(this, void 0, void 0, function* () {
46
+ const { success } = yield this.sendRequest("orby_enableChainAbstractionForAccountCluster", [{ accountClusterId, enable }]);
47
+ return success;
48
+ });
49
+ }
50
+ setCustomChainEndpointsForAccountCluster(accountClusterId, chainEndpoints) {
51
+ return __awaiter(this, void 0, void 0, function* () {
52
+ const formattedEndpoints = chainEndpoints.map((endpoint) => {
53
+ return {
54
+ chainId: `EIP155-${endpoint.chainId}`,
55
+ customRpcUrls: endpoint.customRpcUrls,
56
+ customIndexerUrls: endpoint.customIndexerUrls,
57
+ };
58
+ });
59
+ const { success } = yield this.sendRequest("orby_setCustomChainEndpointsForAccountCluster", [{ accountClusterId, chainEndpoints: formattedEndpoints }]);
60
+ return success;
61
+ });
62
+ }
63
+ removeCustomChainEndpointsForAccountCluster(accountClusterId, chainIds) {
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ const formattedChainIds = chainIds.map((chainId) => `EIP155-${chainId}`);
66
+ const { success } = yield this.sendRequest("orby_removeCustomChainEndpointsForAccountCluster", [{ accountClusterId, chainIds: formattedChainIds }]);
67
+ return success;
68
+ });
69
+ }
70
+ getCustomChainEndpointsForAccountCluster(accountClusterId, returnChainIdsOnly) {
71
+ return __awaiter(this, void 0, void 0, function* () {
72
+ const { chainEndpoints } = yield this.sendRequest("orby_getCustomChainEndpointsForAccountCluster", [{ accountClusterId, returnChainIdsOnly }]);
73
+ return chainEndpoints.map((endpoint) => {
74
+ return {
75
+ chainId: (0, utils_1.getChainIdFromOrbyChainId)(endpoint.chainId),
76
+ customRpcUrls: endpoint.customRpcUrls,
77
+ customIndexerUrls: endpoint.customIndexerUrls,
78
+ };
79
+ });
80
+ });
81
+ }
82
+ isChainSupportedOnAccountCluster(accountClusterId, chainId) {
83
+ return __awaiter(this, void 0, void 0, function* () {
84
+ const { supportStatus } = yield this.sendRequest("orby_isChainSupportedOnAccountCluster", [{ accountClusterId, chainId: `EIP155-${chainId}` }]);
85
+ return supportStatus;
86
+ });
87
+ }
88
+ getNodeRpcUrl(accountClusterId, chainId) {
89
+ return __awaiter(this, void 0, void 0, function* () {
90
+ const { nodeRpcUrl } = yield this.sendRequest("orby_getNodeRpcUrl", [
91
+ [{ accountClusterId, chainId: `EIP155-${chainId}` }],
92
+ ]);
93
+ return nodeRpcUrl;
94
+ });
95
+ }
96
+ getVirtualNodeRpcUrl(accountClusterId, chainId, entrypointAccountAddress) {
97
+ return __awaiter(this, void 0, void 0, function* () {
98
+ const { virtualNodeRpcUrl } = yield this.sendRequest("orby_getVirtualNodeRpcUrl", [
99
+ [
100
+ {
101
+ accountClusterId,
102
+ chainId: `EIP155-${chainId}`,
103
+ entrypointAccountAddress,
104
+ },
105
+ ],
106
+ ]);
107
+ return virtualNodeRpcUrl;
108
+ });
109
+ }
110
+ getActivity(accountClusterId, limit, offset, order, startDate, endDate, filters) {
111
+ return __awaiter(this, void 0, void 0, function* () {
112
+ const { virtualNodeRpcUrl } = yield this.sendRequest("orby_getActivity", [
113
+ [
114
+ {
115
+ accountClusterId,
116
+ limit,
117
+ offset,
118
+ order,
119
+ startDate,
120
+ endDate,
121
+ filters,
122
+ },
123
+ ],
124
+ ]);
125
+ return virtualNodeRpcUrl;
126
+ });
127
+ }
128
+ getPortfolioOverview(accountClusterId) {
129
+ return __awaiter(this, void 0, void 0, function* () {
130
+ const { fungibleTokenOverview } = yield this.sendRequest("orby_getPortfolioOverview", [{ accountClusterId }]);
131
+ return (0, utils_1.extractFungibleTokenOverview)(fungibleTokenOverview);
132
+ });
133
+ }
134
+ getFungibleTokenPortfolio(accountClusterId) {
135
+ return __awaiter(this, void 0, void 0, function* () {
136
+ const { fungibleTokenOverview } = yield this.sendRequest("orby_getFungibleTokenPortfolio", [{ accountClusterId }]);
137
+ return (0, utils_1.extractFungibleTokenOverview)(fungibleTokenOverview);
138
+ });
139
+ }
140
+ getFungibleTokenBalances(accountClusterId, offset, limit, tokensToOmit) {
141
+ return __awaiter(this, void 0, void 0, function* () {
142
+ const { fungibleTokenBalances } = yield this.sendRequest("orby_getFungibleTokenBalances", [{ accountClusterId, offset, limit, tokensToOmit }]);
143
+ return (0, utils_1.extractStandardizedBalances)(fungibleTokenBalances);
144
+ });
145
+ }
146
+ }
147
+ exports.AccountClusterActions = AccountClusterActions;
@@ -0,0 +1,17 @@
1
+ import { GasSpendForInstance, GasSponsorshipData } from "../types";
2
+ import { LibraryRequest } from "../entities/library_request";
3
+ import { LIBRARY_TYPE } from "../enums";
4
+ export declare class AdminActions extends LibraryRequest {
5
+ constructor(library: LIBRARY_TYPE, client?: any, provider?: any);
6
+ createInstance(name: string): Promise<{
7
+ success: boolean;
8
+ orbyInstancePrivateUrl: string;
9
+ orbyInstancePublicUrl: string;
10
+ }>;
11
+ getInstanceUrls(name: string): Promise<{
12
+ orbyInstancePrivateUrl: string;
13
+ orbyInstancePublicUrl: string;
14
+ }>;
15
+ getGasSpentForCustomer(month: string, year: string): Promise<GasSponsorshipData>;
16
+ getGasSpentForInstances(month: string, year: string, instanceNames: string[]): Promise<GasSpendForInstance[]>;
17
+ }
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.AdminActions = void 0;
13
+ const utils_1 = require("../utils/utils");
14
+ const library_request_1 = require("../entities/library_request");
15
+ class AdminActions extends library_request_1.LibraryRequest {
16
+ constructor(library, client, provider) {
17
+ super(library, client, provider);
18
+ }
19
+ createInstance(name) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ return yield this.sendRequest("orby_createInstance", [{ name }]);
22
+ });
23
+ }
24
+ getInstanceUrls(name) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ return yield this.sendRequest("orby_getInstanceUrls", [{ name }]);
27
+ });
28
+ }
29
+ getGasSpentForCustomer(month, year) {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ const { totalGasSpentForCustomer } = yield this.sendRequest("orby_getGasSpentForCustomer", [{ month, year }]);
32
+ return (0, utils_1.extractGasSponsorshipData)(totalGasSpentForCustomer);
33
+ });
34
+ }
35
+ getGasSpentForInstances(month, year, instanceNames) {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ const { totalGasSpendForInstances } = yield this.sendRequest("orby_getGasSpentForInstances", [{ month, year, instanceNames }]);
38
+ return (0, utils_1.extractGasSpendForInstances)(totalGasSpendForInstances);
39
+ });
40
+ }
41
+ }
42
+ exports.AdminActions = AdminActions;
@@ -0,0 +1,6 @@
1
+ import { LibraryRequest } from "../entities/library_request";
2
+ import { LIBRARY_TYPE } from "../enums";
3
+ export declare class ApplicationActions extends LibraryRequest {
4
+ constructor(library: LIBRARY_TYPE, client?: any, provider?: any);
5
+ isChainAbstractionCompatible(appDomainUrl: string): Promise<boolean>;
6
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ApplicationActions = void 0;
13
+ const library_request_1 = require("../entities/library_request");
14
+ class ApplicationActions extends library_request_1.LibraryRequest {
15
+ constructor(library, client, provider) {
16
+ super(library, client, provider);
17
+ }
18
+ isChainAbstractionCompatible(appDomainUrl) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ const { isChainAbstractionCompatible } = yield this.sendRequest("orby_isChainAbstractionCompatible", [{ appDomainUrl }]);
21
+ return isChainAbstractionCompatible;
22
+ });
23
+ }
24
+ }
25
+ exports.ApplicationActions = ApplicationActions;
@@ -0,0 +1,16 @@
1
+ import { BlockchainInformation, ChainEndpoint, GasSponsorshipPolicy } from "../types";
2
+ import { LIBRARY_TYPE } from "../enums";
3
+ import { LibraryRequest } from "../entities/library_request";
4
+ export declare class InstanceActions extends LibraryRequest {
5
+ constructor(library: LIBRARY_TYPE, client?: any, provider?: any);
6
+ setCustomChainEndpointsForInstance(chainEndpoints: ChainEndpoint[]): Promise<boolean>;
7
+ removeCustomChainEndpointForInstance(chainIds: bigint[]): Promise<boolean>;
8
+ getCustomChainEndpointsForInstance(returnChainIdsOnly: boolean): Promise<boolean>;
9
+ getChainsSupportedByDefault(): Promise<BlockchainInformation[]>;
10
+ enabledChainAbstractionForInstance(enable: boolean): Promise<boolean>;
11
+ enableGasSponsorshipForInstance(enable: boolean): Promise<boolean>;
12
+ getGasSponsorForInstance(): Promise<string>;
13
+ getOrbyGasSponsorPolicyForInstance(): Promise<GasSponsorshipPolicy>;
14
+ setOrbyGasSponsorPolicyForInstance(gasSponsorshipPolicy: GasSponsorshipPolicy): Promise<boolean>;
15
+ removeOrbyGasSponsorPolicyForInstance(): Promise<boolean>;
16
+ }
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.InstanceActions = void 0;
13
+ const utils_1 = require("../utils/utils");
14
+ const library_request_1 = require("../entities/library_request");
15
+ class InstanceActions extends library_request_1.LibraryRequest {
16
+ constructor(library, client, provider) {
17
+ super(library, client, provider);
18
+ }
19
+ setCustomChainEndpointsForInstance(chainEndpoints) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ const formattedEndpoints = chainEndpoints.map((endpoint) => {
22
+ return {
23
+ chainId: `EIP155-${endpoint.chainId}`,
24
+ customRpcUrls: endpoint.customRpcUrls,
25
+ customIndexerUrls: endpoint.customIndexerUrls,
26
+ };
27
+ });
28
+ const { success } = yield this.sendRequest("orby_setCustomChainEndpointsForInstance", [{ chainEndpoints: formattedEndpoints }]);
29
+ return success;
30
+ });
31
+ }
32
+ removeCustomChainEndpointForInstance(chainIds) {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ const formattedChainIds = chainIds.map((chainId) => `EIP155-${chainId}`);
35
+ const { success } = yield this.sendRequest("orby_removeCustomChainEndpointForInstance", [{ chainIds: formattedChainIds }]);
36
+ return success;
37
+ });
38
+ }
39
+ getCustomChainEndpointsForInstance(returnChainIdsOnly) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ const { chainEndpoints } = yield this.sendRequest("orby_getCustomChainEndpointsForInstance", [{ returnChainIdsOnly }]);
42
+ return chainEndpoints.map((endpoint) => {
43
+ return {
44
+ chainId: (0, utils_1.getChainIdFromOrbyChainId)(endpoint.chainId),
45
+ customRpcUrls: endpoint.customRpcUrls,
46
+ customIndexerUrls: endpoint.customIndexerUrls,
47
+ };
48
+ });
49
+ });
50
+ }
51
+ getChainsSupportedByDefault() {
52
+ return __awaiter(this, void 0, void 0, function* () {
53
+ const { supportedChains } = yield this.sendRequest("orby_getChainsSupportedByDefault", [{}]);
54
+ return (0, utils_1.extractBlockchainInformations)(supportedChains);
55
+ });
56
+ }
57
+ enabledChainAbstractionForInstance(enable) {
58
+ return __awaiter(this, void 0, void 0, function* () {
59
+ const { success } = yield this.sendRequest("orby_enabledChainAbstractionForInstance", [{ enable }]);
60
+ return success;
61
+ });
62
+ }
63
+ enableGasSponsorshipForInstance(enable) {
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ const { success } = yield this.sendRequest("orby_enableGasSponsorshipForInstance", [{ enable }]);
66
+ return success;
67
+ });
68
+ }
69
+ getGasSponsorForInstance() {
70
+ return __awaiter(this, void 0, void 0, function* () {
71
+ const { gasSponsor } = yield this.sendRequest("orby_getGasSponsorForInstance", [{}]);
72
+ return gasSponsor;
73
+ });
74
+ }
75
+ getOrbyGasSponsorPolicyForInstance() {
76
+ return __awaiter(this, void 0, void 0, function* () {
77
+ const { gasSponsorshipPolicy } = yield this.sendRequest("orby_getOrbyGasSponsorPolicyForInstance", [{}]);
78
+ return (0, utils_1.extractGasSponsorshipPolicy)(gasSponsorshipPolicy);
79
+ });
80
+ }
81
+ setOrbyGasSponsorPolicyForInstance(gasSponsorshipPolicy) {
82
+ return __awaiter(this, void 0, void 0, function* () {
83
+ const { success } = yield this.sendRequest("orby_setOrbyGasSponsorPolicyForInstance", [Object.assign({}, gasSponsorshipPolicy)]);
84
+ return success;
85
+ });
86
+ }
87
+ removeOrbyGasSponsorPolicyForInstance() {
88
+ return __awaiter(this, void 0, void 0, function* () {
89
+ const { success } = yield this.sendRequest("orby_removeOrbyGasSponsorPolicyForInstance", [{}]);
90
+ return success;
91
+ });
92
+ }
93
+ }
94
+ exports.InstanceActions = InstanceActions;
@@ -0,0 +1,78 @@
1
+ import { Operation, OperationStatus, SignedOperation } from "../types";
2
+ import { CurrencyAmount } from "../entities/financial/currency_amount";
3
+ import { LIBRARY_TYPE, QuoteType } from "../enums";
4
+ import { LibraryRequest } from "../entities/library_request";
5
+ export declare class OperationActions extends LibraryRequest {
6
+ constructor(library: LIBRARY_TYPE, client?: any, provider?: any);
7
+ getOperationsToExecuteTransaction(accountClusterId: string, to: string, data: string, value?: string): Promise<Operation[]>;
8
+ getOperationsToSignTypedData(accountClusterId: string, data: string): Promise<Operation[]>;
9
+ getOperationsToCancelTransaction(accountClusterId: string, operationSetId: string): Promise<Operation[]>;
10
+ isTransactionPreconditionSatisfied(accountClusterId: string, to: string, data: string, value?: string): Promise<boolean>;
11
+ isTypedDataPreconditionSatisfied(accountClusterId: string, data: string): Promise<boolean>;
12
+ sendSignedOperations(accountClusterId: string, signedOperations: SignedOperation[]): Promise<{
13
+ operationSetId: string;
14
+ operationResponses: OperationStatus[];
15
+ }>;
16
+ getOperationStatuses(operationIds: string[]): Promise<OperationStatus[]>;
17
+ estimateFiatCostToExecuteTransaction(to: string, data: string, value?: string): Promise<CurrencyAmount>;
18
+ estimateFiatCostToSignTypedData(data: string): Promise<CurrencyAmount>;
19
+ getOperationsToTransferToken(accountClusterId: string, standardizedTokenId: string, amount: number, recipient: {
20
+ chainId: bigint;
21
+ recipientAddress: string;
22
+ }, gasToken?: {
23
+ standardizedTokenId: string;
24
+ tokenSources?: {
25
+ chainId: bigint;
26
+ address?: string;
27
+ }[];
28
+ }): Promise<Operation[]>;
29
+ getOperationsToSwap(accountClusterId: string, swapType: QuoteType, input: {
30
+ standardizedTokenId: string;
31
+ amount?: number;
32
+ tokenSources?: {
33
+ chainId: string;
34
+ address?: string;
35
+ }[];
36
+ }, output: {
37
+ standardizedTokenId: string;
38
+ amount?: number;
39
+ tokenDestination?: {
40
+ chainId: string;
41
+ address?: string;
42
+ };
43
+ }, gasToken?: {
44
+ standardizedTokenId: string;
45
+ tokenSources?: {
46
+ chainId: bigint;
47
+ address?: string;
48
+ }[];
49
+ }): Promise<Operation[]>;
50
+ getQuote(accountClusterId: string, swapType: QuoteType, input: {
51
+ standardizedTokenId: string;
52
+ amount?: number;
53
+ tokenSources?: {
54
+ chainId: string;
55
+ address?: string;
56
+ }[];
57
+ }, output: {
58
+ standardizedTokenId: string;
59
+ amount?: number;
60
+ tokenDestination?: {
61
+ chainId: string;
62
+ address?: string;
63
+ };
64
+ }): Promise<Operation[]>;
65
+ getOperationsToBridge(accountClusterId: string, standardizedTokenId: string, amount: bigint, tokenSources?: {
66
+ chainId: string;
67
+ address?: string;
68
+ }[], tokenDestination?: {
69
+ chainId: string;
70
+ address?: string;
71
+ }, gasToken?: {
72
+ standardizedTokenId: string;
73
+ tokenSources?: {
74
+ chainId: bigint;
75
+ address?: string;
76
+ }[];
77
+ }): Promise<Operation[]>;
78
+ }
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.OperationActions = void 0;
13
+ const utils_1 = require("../utils/utils");
14
+ const currency_amount_1 = require("../entities/financial/currency_amount");
15
+ const library_request_1 = require("../entities/library_request");
16
+ class OperationActions extends library_request_1.LibraryRequest {
17
+ constructor(library, client, provider) {
18
+ super(library, client, provider);
19
+ }
20
+ getOperationsToExecuteTransaction(accountClusterId, to, data, value) {
21
+ return __awaiter(this, void 0, void 0, function* () {
22
+ const { operationSet } = yield this.sendRequest("orby_getOperationsToExecuteTransaction", [{ accountClusterId, to, data, value }]);
23
+ return (0, utils_1.extractOperationSet)(operationSet);
24
+ });
25
+ }
26
+ getOperationsToSignTypedData(accountClusterId, data) {
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ const { operationSet } = yield this.sendRequest("orby_getOperationsToSignTypedData", [{ accountClusterId, data }]);
29
+ return (0, utils_1.extractOperationSet)(operationSet);
30
+ });
31
+ }
32
+ getOperationsToCancelTransaction(accountClusterId, operationSetId) {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ const { cancellationOperationSet } = yield this.sendRequest("orby_getOperationsToCancelTransaction", [{ accountClusterId, operationSetId }]);
35
+ return (0, utils_1.extractOperationSet)(cancellationOperationSet);
36
+ });
37
+ }
38
+ isTransactionPreconditionSatisfied(accountClusterId, to, data, value) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ const { satisfied } = yield this.sendRequest("orby_isTransactionPreconditionSatisfied", [{ accountClusterId, to, data, value }]);
41
+ return satisfied;
42
+ });
43
+ }
44
+ isTypedDataPreconditionSatisfied(accountClusterId, data) {
45
+ return __awaiter(this, void 0, void 0, function* () {
46
+ const { satisfied } = yield this.sendRequest("orby_isTypedDataPreconditionSatisfied", [{ accountClusterId, data }]);
47
+ return satisfied;
48
+ });
49
+ }
50
+ sendSignedOperations(accountClusterId, signedOperations) {
51
+ return __awaiter(this, void 0, void 0, function* () {
52
+ const { operationSetId, operationResponses } = yield this.sendRequest("orby_sendSignedOperations", [{ accountClusterId, signedOperations }]);
53
+ return {
54
+ operationSetId,
55
+ operationResponses: (0, utils_1.extractOperationStatuses)(operationResponses),
56
+ };
57
+ });
58
+ }
59
+ getOperationStatuses(operationIds) {
60
+ return __awaiter(this, void 0, void 0, function* () {
61
+ const { operationStatuses } = yield this.sendRequest("orby_getOperationStatuses", [{ operationIds }]);
62
+ return (0, utils_1.extractOperationStatuses)(operationStatuses);
63
+ });
64
+ }
65
+ estimateFiatCostToExecuteTransaction(to, data, value) {
66
+ return __awaiter(this, void 0, void 0, function* () {
67
+ const { estimatedCost } = yield this.sendRequest("orby_estimateFiatCostToExecuteTransaction", [{ to, data, value }]);
68
+ return currency_amount_1.CurrencyAmount.toCurrencyAmount(estimatedCost);
69
+ });
70
+ }
71
+ estimateFiatCostToSignTypedData(data) {
72
+ return __awaiter(this, void 0, void 0, function* () {
73
+ const { estimatedCost } = yield this.sendRequest("orby_estimateFiatCostToSignTypedData", [{ data }]);
74
+ return currency_amount_1.CurrencyAmount.toCurrencyAmount(estimatedCost);
75
+ });
76
+ }
77
+ getOperationsToTransferToken(accountClusterId, standardizedTokenId, amount, recipient, gasToken) {
78
+ return __awaiter(this, void 0, void 0, function* () {
79
+ const { operationSet } = yield this.sendRequest("orby_getOperationsToTransferToken", [{ accountClusterId, standardizedTokenId, amount, recipient, gasToken }]);
80
+ return (0, utils_1.extractOperationSet)(operationSet);
81
+ });
82
+ }
83
+ getOperationsToSwap(accountClusterId, swapType, input, output, gasToken) {
84
+ return __awaiter(this, void 0, void 0, function* () {
85
+ const { operationSet } = yield this.sendRequest("orby_getOperationsToSwap", [{ accountClusterId, swapType, input, output, gasToken }]);
86
+ return (0, utils_1.extractOperationSet)(operationSet);
87
+ });
88
+ }
89
+ getQuote(accountClusterId, swapType, input, output) {
90
+ return __awaiter(this, void 0, void 0, function* () {
91
+ const { operationSet } = yield this.sendRequest("orby_getQuote", [
92
+ { accountClusterId, swapType, input, output },
93
+ ]);
94
+ return (0, utils_1.extractOperationSet)(operationSet);
95
+ });
96
+ }
97
+ getOperationsToBridge(accountClusterId, standardizedTokenId, amount, tokenSources, tokenDestination, gasToken) {
98
+ return __awaiter(this, void 0, void 0, function* () {
99
+ const { operationSet } = yield this.sendRequest("orby_getOperationsToBridge", [
100
+ {
101
+ accountClusterId,
102
+ standardizedTokenId,
103
+ amount,
104
+ tokenSources,
105
+ tokenDestination,
106
+ gasToken,
107
+ },
108
+ ]);
109
+ return (0, utils_1.extractOperationSet)(operationSet);
110
+ });
111
+ }
112
+ }
113
+ exports.OperationActions = OperationActions;
@@ -0,0 +1,15 @@
1
+ import { StandardizedToken } from "../types";
2
+ import { LibraryRequest } from "../entities/library_request";
3
+ import { LIBRARY_TYPE } from "../enums";
4
+ export declare class TokenActions extends LibraryRequest {
5
+ constructor(library: LIBRARY_TYPE, client?: any, provider?: any);
6
+ getStandardizedTokenIds(tokens: {
7
+ tokenAddress: string;
8
+ chainId: bigint;
9
+ }[]): Promise<string[]>;
10
+ getStandardizedTokens(tokens: {
11
+ tokenAddress: string;
12
+ chainId: bigint;
13
+ }[]): Promise<StandardizedToken[]>;
14
+ getFungibleTokenData(standardizedTokenIds: string[]): Promise<StandardizedToken>;
15
+ }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.TokenActions = void 0;
13
+ const utils_1 = require("../utils/utils");
14
+ const library_request_1 = require("../entities/library_request");
15
+ class TokenActions extends library_request_1.LibraryRequest {
16
+ constructor(library, client, provider) {
17
+ super(library, client, provider);
18
+ }
19
+ getStandardizedTokenIds(tokens) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ const formattedTokensInfo = tokens.map(({ tokenAddress, chainId }) => {
22
+ return { chainId: `EIP155-${chainId}`, tokenAddress };
23
+ });
24
+ const { standardizedTokenIds } = yield this.sendRequest("orby_getStandardizedTokenIds", [{ tokens: formattedTokensInfo }]);
25
+ return standardizedTokenIds;
26
+ });
27
+ }
28
+ getStandardizedTokens(tokens) {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ const formattedTokensInfo = tokens.map(({ tokenAddress, chainId }) => {
31
+ return { chainId: `EIP155-${chainId}`, tokenAddress };
32
+ });
33
+ const { standardizedTokens } = yield this.sendRequest("orby_getStandardizedTokens", [{ tokens: formattedTokensInfo }]);
34
+ return (0, utils_1.extractStandardizedTokens)(standardizedTokens);
35
+ });
36
+ }
37
+ getFungibleTokenData(standardizedTokenIds) {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ const { data } = yield this.sendRequest("orby_getFungibleTokenData", [
40
+ { standardizedTokenIds },
41
+ ]);
42
+ return (0, utils_1.extractStandardizedToken)(data);
43
+ });
44
+ }
45
+ }
46
+ exports.TokenActions = TokenActions;