@orb-labs/orby-core 0.0.14 → 0.0.16

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 (137) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/cjs/actions/account_cluster.js +211 -0
  3. package/dist/cjs/actions/admin.js +43 -0
  4. package/dist/cjs/actions/application.js +20 -0
  5. package/dist/cjs/actions/blockchain.js +39 -0
  6. package/dist/cjs/actions/instance.js +98 -0
  7. package/dist/{actions → cjs/actions}/operation.d.ts +2 -2
  8. package/dist/cjs/actions/operation.js +415 -0
  9. package/dist/cjs/actions/token.js +50 -0
  10. package/dist/cjs/constants.js +139 -0
  11. package/dist/cjs/entities/account.js +49 -0
  12. package/dist/cjs/entities/financial/account_balance.js +35 -0
  13. package/dist/cjs/entities/financial/asset.js +42 -0
  14. package/dist/cjs/entities/financial/currency.js +56 -0
  15. package/dist/cjs/entities/financial/currency_amount.js +99 -0
  16. package/dist/cjs/entities/financial/fungible_token.js +68 -0
  17. package/dist/cjs/entities/financial/fungible_token_amount.js +102 -0
  18. package/dist/cjs/entities/financial/non_fungible_token.js +65 -0
  19. package/dist/cjs/entities/financial/semi_fungible_token.js +67 -0
  20. package/dist/cjs/entities/library_request.js +37 -0
  21. package/dist/cjs/entities/state.js +106 -0
  22. package/dist/cjs/enums.js +138 -0
  23. package/dist/cjs/index.js +49 -0
  24. package/dist/cjs/interfaces/account_cluster.js +2 -0
  25. package/dist/cjs/interfaces/admin.js +2 -0
  26. package/dist/cjs/interfaces/application.js +2 -0
  27. package/dist/cjs/interfaces/blockchain.js +2 -0
  28. package/dist/cjs/interfaces/instance.js +2 -0
  29. package/dist/{interfaces → cjs/interfaces}/operation.d.ts +2 -2
  30. package/dist/cjs/interfaces/operation.js +2 -0
  31. package/dist/cjs/interfaces/orby.js +2 -0
  32. package/dist/cjs/interfaces/token.js +2 -0
  33. package/dist/{types.d.ts → cjs/types.d.ts} +20 -0
  34. package/dist/cjs/types.js +2 -0
  35. package/dist/cjs/utils/action_helpers.js +274 -0
  36. package/dist/cjs/utils/utils.js +79 -0
  37. package/dist/cjs/utils/validateAndParseAddress.js +29 -0
  38. package/dist/esm/actions/account_cluster.d.ts +32 -0
  39. package/dist/esm/actions/admin.d.ts +17 -0
  40. package/dist/esm/actions/application.d.ts +6 -0
  41. package/dist/esm/actions/blockchain.d.ts +16 -0
  42. package/dist/esm/actions/instance.d.ts +15 -0
  43. package/dist/esm/actions/operation.d.ts +99 -0
  44. package/dist/{actions → esm/actions}/operation.js +75 -5
  45. package/dist/esm/actions/token.d.ts +15 -0
  46. package/dist/{actions → esm/actions}/token.js +1 -1
  47. package/dist/esm/constants.d.ts +14 -0
  48. package/dist/esm/entities/account.d.ts +14 -0
  49. package/dist/{entities → esm/entities}/account.js +1 -1
  50. package/dist/esm/entities/financial/account_balance.d.ts +12 -0
  51. package/dist/esm/entities/financial/asset.d.ts +31 -0
  52. package/dist/esm/entities/financial/currency.d.ts +41 -0
  53. package/dist/esm/entities/financial/currency_amount.d.ts +34 -0
  54. package/dist/esm/entities/financial/fungible_token.d.ts +41 -0
  55. package/dist/esm/entities/financial/fungible_token_amount.d.ts +36 -0
  56. package/dist/esm/entities/financial/non_fungible_token.d.ts +39 -0
  57. package/dist/esm/entities/financial/semi_fungible_token.d.ts +41 -0
  58. package/dist/esm/entities/library_request.d.ts +8 -0
  59. package/dist/esm/entities/state.d.ts +22 -0
  60. package/dist/esm/enums.d.ts +116 -0
  61. package/dist/esm/index.d.ts +29 -0
  62. package/dist/esm/interfaces/account_cluster.d.ts +30 -0
  63. package/dist/esm/interfaces/admin.d.ts +14 -0
  64. package/dist/esm/interfaces/application.d.ts +3 -0
  65. package/dist/esm/interfaces/blockchain.d.ts +13 -0
  66. package/dist/esm/interfaces/instance.d.ts +12 -0
  67. package/dist/esm/interfaces/operation.d.ts +97 -0
  68. package/dist/esm/interfaces/orby.d.ts +9 -0
  69. package/dist/esm/interfaces/token.d.ts +12 -0
  70. package/dist/esm/types.d.ts +172 -0
  71. package/dist/esm/utils/action_helpers.d.ts +22 -0
  72. package/dist/esm/utils/utils.d.ts +10 -0
  73. package/dist/esm/utils/validateAndParseAddress.d.ts +10 -0
  74. package/dist/tsconfig.cjs.tsbuildinfo +1 -0
  75. package/dist/tsconfig.esm.tsbuildinfo +1 -0
  76. package/package.json +16 -7
  77. package/dist/tsconfig.tsbuildinfo +0 -1
  78. /package/dist/{actions → cjs/actions}/account_cluster.d.ts +0 -0
  79. /package/dist/{actions → cjs/actions}/admin.d.ts +0 -0
  80. /package/dist/{actions → cjs/actions}/application.d.ts +0 -0
  81. /package/dist/{actions → cjs/actions}/blockchain.d.ts +0 -0
  82. /package/dist/{actions → cjs/actions}/instance.d.ts +0 -0
  83. /package/dist/{actions → cjs/actions}/token.d.ts +0 -0
  84. /package/dist/{constants.d.ts → cjs/constants.d.ts} +0 -0
  85. /package/dist/{entities → cjs/entities}/account.d.ts +0 -0
  86. /package/dist/{entities → cjs/entities}/financial/account_balance.d.ts +0 -0
  87. /package/dist/{entities → cjs/entities}/financial/asset.d.ts +0 -0
  88. /package/dist/{entities → cjs/entities}/financial/currency.d.ts +0 -0
  89. /package/dist/{entities → cjs/entities}/financial/currency_amount.d.ts +0 -0
  90. /package/dist/{entities → cjs/entities}/financial/fungible_token.d.ts +0 -0
  91. /package/dist/{entities → cjs/entities}/financial/fungible_token_amount.d.ts +0 -0
  92. /package/dist/{entities → cjs/entities}/financial/non_fungible_token.d.ts +0 -0
  93. /package/dist/{entities → cjs/entities}/financial/semi_fungible_token.d.ts +0 -0
  94. /package/dist/{entities → cjs/entities}/library_request.d.ts +0 -0
  95. /package/dist/{entities → cjs/entities}/state.d.ts +0 -0
  96. /package/dist/{enums.d.ts → cjs/enums.d.ts} +0 -0
  97. /package/dist/{index.d.ts → cjs/index.d.ts} +0 -0
  98. /package/dist/{interfaces → cjs/interfaces}/account_cluster.d.ts +0 -0
  99. /package/dist/{interfaces → cjs/interfaces}/admin.d.ts +0 -0
  100. /package/dist/{interfaces → cjs/interfaces}/application.d.ts +0 -0
  101. /package/dist/{interfaces → cjs/interfaces}/blockchain.d.ts +0 -0
  102. /package/dist/{interfaces → cjs/interfaces}/instance.d.ts +0 -0
  103. /package/dist/{interfaces → cjs/interfaces}/orby.d.ts +0 -0
  104. /package/dist/{interfaces → cjs/interfaces}/token.d.ts +0 -0
  105. /package/dist/{utils → cjs/utils}/action_helpers.d.ts +0 -0
  106. /package/dist/{utils → cjs/utils}/utils.d.ts +0 -0
  107. /package/dist/{utils → cjs/utils}/validateAndParseAddress.d.ts +0 -0
  108. /package/dist/{actions → esm/actions}/account_cluster.js +0 -0
  109. /package/dist/{actions → esm/actions}/admin.js +0 -0
  110. /package/dist/{actions → esm/actions}/application.js +0 -0
  111. /package/dist/{actions → esm/actions}/blockchain.js +0 -0
  112. /package/dist/{actions → esm/actions}/instance.js +0 -0
  113. /package/dist/{constants.js → esm/constants.js} +0 -0
  114. /package/dist/{entities → esm/entities}/financial/account_balance.js +0 -0
  115. /package/dist/{entities → esm/entities}/financial/asset.js +0 -0
  116. /package/dist/{entities → esm/entities}/financial/currency.js +0 -0
  117. /package/dist/{entities → esm/entities}/financial/currency_amount.js +0 -0
  118. /package/dist/{entities → esm/entities}/financial/fungible_token.js +0 -0
  119. /package/dist/{entities → esm/entities}/financial/fungible_token_amount.js +0 -0
  120. /package/dist/{entities → esm/entities}/financial/non_fungible_token.js +0 -0
  121. /package/dist/{entities → esm/entities}/financial/semi_fungible_token.js +0 -0
  122. /package/dist/{entities → esm/entities}/library_request.js +0 -0
  123. /package/dist/{entities → esm/entities}/state.js +0 -0
  124. /package/dist/{enums.js → esm/enums.js} +0 -0
  125. /package/dist/{index.js → esm/index.js} +0 -0
  126. /package/dist/{interfaces → esm/interfaces}/account_cluster.js +0 -0
  127. /package/dist/{interfaces → esm/interfaces}/admin.js +0 -0
  128. /package/dist/{interfaces → esm/interfaces}/application.js +0 -0
  129. /package/dist/{interfaces → esm/interfaces}/blockchain.js +0 -0
  130. /package/dist/{interfaces → esm/interfaces}/instance.js +0 -0
  131. /package/dist/{interfaces → esm/interfaces}/operation.js +0 -0
  132. /package/dist/{interfaces → esm/interfaces}/orby.js +0 -0
  133. /package/dist/{interfaces → esm/interfaces}/token.js +0 -0
  134. /package/dist/{types.js → esm/types.js} +0 -0
  135. /package/dist/{utils → esm/utils}/action_helpers.js +0 -0
  136. /package/dist/{utils → esm/utils}/utils.js +0 -0
  137. /package/dist/{utils → esm/utils}/validateAndParseAddress.js +0 -0
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LIBRARY_TYPE = exports.TimeIntervalUnits = exports.TokenAllowlistType = exports.BlockchainEnvironment = exports.ActivityStatus = exports.Order = exports.QuoteType = exports.OperationStatusType = exports.Category = exports.OperationType = exports.OperationDataFormat = exports.CreateOperationsStatus = exports.ChainSupportStatus = exports.VMType = exports.AccountType = exports.TokenType = exports.Blockchain = void 0;
4
+ var Blockchain;
5
+ (function (Blockchain) {
6
+ Blockchain["ETHEREUM"] = "ethereum";
7
+ Blockchain["POLYGON"] = "polygon";
8
+ Blockchain["BINANCE"] = "binance";
9
+ Blockchain["ARBITRUM"] = "arbitrum";
10
+ Blockchain["BASE"] = "base";
11
+ Blockchain["AVALANCHE"] = "avalanche";
12
+ Blockchain["ARBITRUM_NOVA"] = "arbitrum_nova";
13
+ Blockchain["OPTIMISM"] = "optimism";
14
+ Blockchain["EVMOS"] = "evmos";
15
+ Blockchain["MOONBEAM"] = "moonbeam";
16
+ // testnets
17
+ Blockchain["ETHEREUM_SEPOLIA"] = "ethereum_sepolia";
18
+ Blockchain["ETHEREUM_HOLESKY"] = "ethereum_holesky";
19
+ Blockchain["BASE_SEPOLIA"] = "base_sepolia";
20
+ Blockchain["ARBITRUM_SEPOLIA"] = "arbitrum_sepolia";
21
+ Blockchain["OPTIMISM_SEPOLIA"] = "optimism_sepolia";
22
+ Blockchain["POLYGON_AMOY"] = "polygon_amoy";
23
+ Blockchain["BINANCE_TESTNET"] = "binance_testnet";
24
+ Blockchain["OPBNB_TESTNET"] = "opbnb_testnet";
25
+ Blockchain["MOONBEAM_ALPHA"] = "moonbeam_alpha";
26
+ // local testing
27
+ Blockchain["HARDHAT"] = "hardhat";
28
+ Blockchain["LOCAL_CHAIN_0"] = "local_chain_0";
29
+ Blockchain["LOCAL_CHAIN_1"] = "local_chain_1";
30
+ })(Blockchain || (exports.Blockchain = Blockchain = {}));
31
+ var TokenType;
32
+ (function (TokenType) {
33
+ TokenType["FUNGIBLE_TOKEN"] = "FUNGIBLE_TOKEN";
34
+ TokenType["NON_FUNGIBLE_TOKEN"] = "NON_FUNGIBLE_TOKEN";
35
+ TokenType["SEMI_FUNGIBLE_TOKEN"] = "SEMI_FUNGIBLE_TOKEN";
36
+ TokenType["FIAT"] = "FIAT";
37
+ })(TokenType || (exports.TokenType = TokenType = {}));
38
+ var AccountType;
39
+ (function (AccountType) {
40
+ AccountType["EOA"] = "EOA";
41
+ AccountType["SCA"] = "SCA";
42
+ })(AccountType || (exports.AccountType = AccountType = {}));
43
+ var VMType;
44
+ (function (VMType) {
45
+ VMType["EVM"] = "EVM";
46
+ })(VMType || (exports.VMType = VMType = {}));
47
+ var ChainSupportStatus;
48
+ (function (ChainSupportStatus) {
49
+ ChainSupportStatus["CHAIN_SUPPORTED"] = "CHAIN_SUPPORTED";
50
+ ChainSupportStatus["CHAIN_UNAVAILABLE"] = "CHAIN_UNAVAILABLE";
51
+ ChainSupportStatus["ACCOUNT_UNAVAILABLE"] = "ACCOUNT_UNAVAILABLE";
52
+ })(ChainSupportStatus || (exports.ChainSupportStatus = ChainSupportStatus = {}));
53
+ var CreateOperationsStatus;
54
+ (function (CreateOperationsStatus) {
55
+ CreateOperationsStatus["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS";
56
+ CreateOperationsStatus["INSUFFICIENT_FUNDS_FOR_GAS"] = "INSUFFICIENT_FUNDS_FOR_GAS";
57
+ CreateOperationsStatus["INTERNAL"] = "INTERNAL";
58
+ CreateOperationsStatus["INVALID_ARGUMENT"] = "INVALID_ARGUMENT";
59
+ CreateOperationsStatus["NO_EXECUTION_PATH"] = "NO_EXECUTION_PATH";
60
+ CreateOperationsStatus["SUCCESS"] = "SUCCESS";
61
+ })(CreateOperationsStatus || (exports.CreateOperationsStatus = CreateOperationsStatus = {}));
62
+ var OperationDataFormat;
63
+ (function (OperationDataFormat) {
64
+ OperationDataFormat["TRANSACTION"] = "TRANSACTION";
65
+ OperationDataFormat["TYPED_DATA"] = "TYPED_DATA";
66
+ })(OperationDataFormat || (exports.OperationDataFormat = OperationDataFormat = {}));
67
+ var OperationType;
68
+ (function (OperationType) {
69
+ OperationType["APPROVE_ERC20_TOKEN"] = "APPROVE_ERC20_TOKEN";
70
+ OperationType["CANCEL_OPERATION"] = "CANCEL_OPERATION";
71
+ OperationType["CANCEL_TRANSACTION"] = "CANCEL_TRANSACTION";
72
+ OperationType["FINAL_TRANSACTION"] = "FINAL_TRANSACTION";
73
+ OperationType["GAS_ABSTRACTION"] = "GAS_ABSTRACTION";
74
+ OperationType["NATIVE_TOKEN_TRANSFER"] = "NATIVE_TOKEN_TRANSFER";
75
+ OperationType["SUBMIT_INTENT"] = "SUBMIT_INTENT";
76
+ })(OperationType || (exports.OperationType = OperationType = {}));
77
+ var Category;
78
+ (function (Category) {
79
+ Category["SEND"] = "SEND";
80
+ Category["RECEIVE"] = "RECEIVE";
81
+ Category["SWAP"] = "SWAP";
82
+ Category["REBALANCE"] = "REBALANCE";
83
+ Category["BRIDGE"] = "BRIDGE";
84
+ Category["FUNCTION_CALL"] = "FUNCTION_CALL";
85
+ Category["TYPED_DATA_SIGNATURE"] = "TYPED_DATA_SIGNATURE";
86
+ })(Category || (exports.Category = Category = {}));
87
+ var OperationStatusType;
88
+ (function (OperationStatusType) {
89
+ OperationStatusType["FAILED"] = "FAILED";
90
+ OperationStatusType["NOT_FOUND"] = "NOT_FOUND";
91
+ OperationStatusType["PENDING"] = "PENDING";
92
+ OperationStatusType["SUCCESSFUL"] = "SUCCESSFUL";
93
+ OperationStatusType["WAITING_PRECONDITION"] = "WAITING_PRECONDITION";
94
+ })(OperationStatusType || (exports.OperationStatusType = OperationStatusType = {}));
95
+ var QuoteType;
96
+ (function (QuoteType) {
97
+ QuoteType["EXACT_INPUT"] = "EXACT_INPUT";
98
+ QuoteType["EXACT_OUTPUT"] = "EXACT_OUTPUT";
99
+ })(QuoteType || (exports.QuoteType = QuoteType = {}));
100
+ var Order;
101
+ (function (Order) {
102
+ Order["NEWEST"] = "NEWEST";
103
+ Order["OLDEST"] = "OLDEST";
104
+ })(Order || (exports.Order = Order = {}));
105
+ var ActivityStatus;
106
+ (function (ActivityStatus) {
107
+ ActivityStatus["CANCELLED"] = "CANCELLED";
108
+ ActivityStatus["FAILED"] = "FAILED";
109
+ ActivityStatus["PENDING"] = "PENDING";
110
+ ActivityStatus["SUCCESS"] = "SUCCESS";
111
+ })(ActivityStatus || (exports.ActivityStatus = ActivityStatus = {}));
112
+ var BlockchainEnvironment;
113
+ (function (BlockchainEnvironment) {
114
+ BlockchainEnvironment["MAINNET"] = "MAINNET";
115
+ BlockchainEnvironment["TESTNET"] = "TESTNET";
116
+ })(BlockchainEnvironment || (exports.BlockchainEnvironment = BlockchainEnvironment = {}));
117
+ var TokenAllowlistType;
118
+ (function (TokenAllowlistType) {
119
+ TokenAllowlistType["ALL_TOKENS"] = "ALL_TOKENS";
120
+ TokenAllowlistType["ONLY_FUNGIBLE_TOKENS"] = "ONLY_FUNGIBLE_TOKENS";
121
+ TokenAllowlistType["ONLY_NON_FUNGIBLE_TOKENS"] = "ONLY_NON_FUNGIBLE_TOKENS";
122
+ TokenAllowlistType["ONLY_SEMI_FUNGIBLE_TOKENS"] = "ONLY_SEMI_FUNGIBLE_TOKENS";
123
+ })(TokenAllowlistType || (exports.TokenAllowlistType = TokenAllowlistType = {}));
124
+ var TimeIntervalUnits;
125
+ (function (TimeIntervalUnits) {
126
+ TimeIntervalUnits["DAYS"] = "DAYS";
127
+ TimeIntervalUnits["FOREVER"] = "FOREVER";
128
+ TimeIntervalUnits["HOURS"] = "HOURS";
129
+ TimeIntervalUnits["MINUTES"] = "MINUTES";
130
+ TimeIntervalUnits["MONTHS"] = "MONTHS";
131
+ TimeIntervalUnits["WEEKS"] = "WEEKS";
132
+ TimeIntervalUnits["YEARS"] = "YEARS";
133
+ })(TimeIntervalUnits || (exports.TimeIntervalUnits = TimeIntervalUnits = {}));
134
+ var LIBRARY_TYPE;
135
+ (function (LIBRARY_TYPE) {
136
+ LIBRARY_TYPE["VIEM"] = "VIEM";
137
+ LIBRARY_TYPE["ETHERS"] = "ETHERS";
138
+ })(LIBRARY_TYPE || (exports.LIBRARY_TYPE = LIBRARY_TYPE = {}));
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ // interfaces
18
+ __exportStar(require("./interfaces/account_cluster.js"), exports);
19
+ __exportStar(require("./interfaces/admin.js"), exports);
20
+ __exportStar(require("./interfaces/application.js"), exports);
21
+ __exportStar(require("./interfaces/instance.js"), exports);
22
+ __exportStar(require("./interfaces/operation.js"), exports);
23
+ __exportStar(require("./interfaces/token.js"), exports);
24
+ __exportStar(require("./interfaces/orby.js"), exports);
25
+ __exportStar(require("./interfaces/blockchain.js"), exports);
26
+ // actions
27
+ __exportStar(require("./actions/account_cluster.js"), exports);
28
+ __exportStar(require("./actions/admin.js"), exports);
29
+ __exportStar(require("./actions/application.js"), exports);
30
+ __exportStar(require("./actions/instance.js"), exports);
31
+ __exportStar(require("./actions/operation.js"), exports);
32
+ __exportStar(require("./actions/token.js"), exports);
33
+ __exportStar(require("./actions/blockchain.js"), exports);
34
+ // entities
35
+ __exportStar(require("./entities/financial/account_balance.js"), exports);
36
+ __exportStar(require("./entities/financial/asset.js"), exports);
37
+ __exportStar(require("./entities/financial/currency_amount.js"), exports);
38
+ __exportStar(require("./entities/financial/currency.js"), exports);
39
+ __exportStar(require("./entities/financial/fungible_token_amount.js"), exports);
40
+ __exportStar(require("./entities/financial/fungible_token.js"), exports);
41
+ __exportStar(require("./entities/financial/non_fungible_token.js"), exports);
42
+ __exportStar(require("./entities/financial/semi_fungible_token.js"), exports);
43
+ __exportStar(require("./entities/account.js"), exports);
44
+ __exportStar(require("./entities/state.js"), exports);
45
+ // enums, types and constants
46
+ __exportStar(require("./enums.js"), exports);
47
+ __exportStar(require("./types.js"), exports);
48
+ __exportStar(require("./constants.js"), exports);
49
+ __exportStar(require("./utils/utils.js"), exports);
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,4 @@
1
- import { OnchainOperation, OperationSet, OperationStatus, SignedOperation } from "../types.js";
1
+ import { AccountCluster, OnchainOperation, OperationSet, OperationStatus, SignedOperation, UserOperation } from "../types.js";
2
2
  import { CurrencyAmount } from "../entities/financial/currency_amount.js";
3
3
  import { OperationStatusType, QuoteType } from "../enums.js";
4
4
  export interface IOperationActions {
@@ -88,7 +88,7 @@ export interface IOperationActions {
88
88
  subscribeToOperationStatuses(ids?: string[], onOperationStatusesUpdateCallback?: (statusSummary: OperationStatusType, primaryOperationStatus?: OperationStatus, allOperationStatuses?: OperationStatus[]) => void, timout?: number): {
89
89
  intervalId: NodeJS.Timeout | null;
90
90
  };
91
- sendOperationSet(accountClusterId: string, operationSet: OperationSet, signOperation: (operation: OnchainOperation) => Promise<SignedOperation | undefined>): Promise<{
91
+ sendOperationSet(accountCluster: AccountCluster, operationSet: OperationSet, signTransaction: (operation: OnchainOperation) => Promise<string | undefined>, signUserOperation: (operations: OnchainOperation[], accountAddress: string, chainId: bigint, txRpcUrl: string) => Promise<UserOperation | undefined>, signTypedData: (operation: OnchainOperation) => Promise<string | undefined>): Promise<{
92
92
  success: boolean;
93
93
  operationSetId?: string;
94
94
  primaryOperationStatus?: OperationStatus;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -32,6 +32,24 @@ export type Intent = {
32
32
  intentOperations?: OnchainOperation[];
33
33
  outputState?: State;
34
34
  };
35
+ export type UserOperation = {
36
+ sender: string;
37
+ nonce: string;
38
+ factory: string;
39
+ factoryData: string;
40
+ callData: string;
41
+ callGasLimit: string;
42
+ verificationGasLimit: string;
43
+ preVerificationGas: string;
44
+ maxFeePerGas: string;
45
+ maxPriorityFeePerGas: string;
46
+ paymasterVerificationGasLimit: string;
47
+ paymasterPostOpGasLimit: string;
48
+ signature: string;
49
+ paymaster: string;
50
+ paymasterData: string;
51
+ entrypoint: string;
52
+ };
35
53
  export interface OnchainOperation {
36
54
  chainId: bigint;
37
55
  data: string;
@@ -58,6 +76,8 @@ export type SignedOperation = {
58
76
  signature: string;
59
77
  category?: Category;
60
78
  data?: string;
79
+ from?: string;
80
+ chainId?: string;
61
81
  };
62
82
  export type OperationStatus = {
63
83
  blockHash?: string;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,274 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractGasSponsorshipData = exports.extractGasSponsorshipInformation = exports.extractGasSpendForInstance = exports.extractGasSpendForInstances = exports.extractGasSponsorshipPolicy = exports.extractAllowlistWithOpenFallback = exports.extractMaxAmountPerInterval = exports.extractBlockchainInformation = exports.extractBlockchainInformations = exports.extractStandardizedToken = exports.extractStandardizedTokens = exports.extractStandardizedBalance = exports.extractStandardizedBalances = exports.extractFungibleTokenOverview = exports.extractActivities = exports.extractOperationStatus = exports.extractOperationStatuses = exports.extractIntent = exports.extractOnchainOperation = exports.extractOperationSet = exports.extractAccountCluster = void 0;
4
+ const enums_js_1 = require("../enums.js");
5
+ const currency_amount_js_1 = require("../entities/financial/currency_amount.js");
6
+ const state_js_1 = require("../entities/state.js");
7
+ const currency_js_1 = require("../entities/financial/currency.js");
8
+ const fungible_token_amount_js_1 = require("../entities/financial/fungible_token_amount.js");
9
+ const fungible_token_js_1 = require("../entities/financial/fungible_token.js");
10
+ const account_js_1 = require("../entities/account.js");
11
+ const utils_js_1 = require("./utils.js");
12
+ const extractAccountCluster = (accountCluster) => {
13
+ if (!accountCluster) {
14
+ return undefined;
15
+ }
16
+ else if ((0, utils_js_1.hasError)(accountCluster)) {
17
+ console.error("[extractAccountCluster]", accountCluster.code, accountCluster.message);
18
+ return undefined;
19
+ }
20
+ return {
21
+ accountClusterId: accountCluster?.accountClusterId,
22
+ accounts: accountCluster?.accounts?.map((account) => account_js_1.Account.toAccount(account)),
23
+ };
24
+ };
25
+ exports.extractAccountCluster = extractAccountCluster;
26
+ const extractOperationSet = (operationSet) => {
27
+ if (!operationSet) {
28
+ return undefined;
29
+ }
30
+ else if ((0, utils_js_1.hasError)(operationSet)) {
31
+ console.error("[extractOperationSet]", operationSet);
32
+ return {
33
+ status: enums_js_1.CreateOperationsStatus.INTERNAL,
34
+ };
35
+ }
36
+ return {
37
+ status: operationSet.status,
38
+ primaryOperation: (0, exports.extractOnchainOperation)(operationSet.primaryOperation),
39
+ primaryOperationPreconditions: state_js_1.State.toState(operationSet.primaryOperationPreconditions),
40
+ inputState: state_js_1.State.toState(operationSet.inputState),
41
+ outputState: state_js_1.State.toState(operationSet.outputState),
42
+ intents: operationSet.intents?.map((intent) => (0, exports.extractIntent)(intent)),
43
+ aggregateNetworkFeeInFiatCurrency: currency_amount_js_1.CurrencyAmount.toCurrencyAmount(operationSet.aggregateNetworkFeeInFiatCurrency),
44
+ aggregateOperationFeeInFiatCurrency: currency_amount_js_1.CurrencyAmount.toCurrencyAmount(operationSet.aggregateOperationFeeInFiatCurrency),
45
+ aggregateEstimatedTimeInMs: operationSet.aggregateEstimatedTimeInMs,
46
+ };
47
+ };
48
+ exports.extractOperationSet = extractOperationSet;
49
+ const extractOnchainOperation = (onchainOperation) => {
50
+ if (!onchainOperation) {
51
+ return undefined;
52
+ }
53
+ return {
54
+ chainId: (0, utils_js_1.getChainIdFromOrbyChainId)(onchainOperation.chainId),
55
+ data: onchainOperation.data,
56
+ estimatedNetworkFees: currency_amount_js_1.CurrencyAmount.toCurrencyAmount(onchainOperation.estimatedNetworkFees),
57
+ estimatedNetworkFeesInFiatCurrency: currency_amount_js_1.CurrencyAmount.toCurrencyAmount(onchainOperation.estimatedNetworkFeesInFiatCurrency),
58
+ estimatedTimeInMs: onchainOperation.estimatedTimeInMs,
59
+ format: onchainOperation.format,
60
+ from: onchainOperation.from,
61
+ gasLimit: onchainOperation.gasLimit
62
+ ? BigInt(onchainOperation.gasLimit)
63
+ : undefined,
64
+ gasPrice: onchainOperation.gasPrice
65
+ ? BigInt(onchainOperation.gasPrice)
66
+ : undefined,
67
+ inputState: state_js_1.State.toState(onchainOperation.inputState),
68
+ maxFeePerGas: onchainOperation.maxFeePerGas
69
+ ? BigInt(onchainOperation.maxFeePerGas)
70
+ : undefined,
71
+ maxPriorityFeePerGas: onchainOperation.maxPriorityFeePerGas
72
+ ? BigInt(onchainOperation.maxPriorityFeePerGas)
73
+ : undefined,
74
+ nativeCurrency: currency_js_1.Currency.toCurrency(onchainOperation.nativeCurrency),
75
+ nonce: onchainOperation.nonce ? BigInt(onchainOperation.nonce) : undefined,
76
+ outputState: state_js_1.State.toState(onchainOperation.outputState),
77
+ to: onchainOperation.to,
78
+ txRpcUrl: onchainOperation.txRpcUrl,
79
+ type: onchainOperation.type,
80
+ value: onchainOperation.value ? BigInt(onchainOperation.value) : undefined,
81
+ };
82
+ };
83
+ exports.extractOnchainOperation = extractOnchainOperation;
84
+ const extractIntent = (intent) => {
85
+ if (!intent) {
86
+ return undefined;
87
+ }
88
+ return {
89
+ estimatedProtocolFees: fungible_token_amount_js_1.FungibleTokenAmount.toFungibleTokenAmount(intent.estimatedProtocolFees),
90
+ estimatedProtocolFeesInFiatCurrency: currency_amount_js_1.CurrencyAmount.toCurrencyAmount(intent.estimatedProtocolFeesInFiatCurrency),
91
+ inputState: state_js_1.State.toState(intent.inputState),
92
+ intentOperations: intent.intentOperations.map((operation) => (0, exports.extractOnchainOperation)(operation)),
93
+ outputState: state_js_1.State.toState(intent.outputState),
94
+ };
95
+ };
96
+ exports.extractIntent = extractIntent;
97
+ const extractOperationStatuses = (operationStatus) => {
98
+ if ((0, utils_js_1.hasError)(operationStatus)) {
99
+ console.error("Error ", operationStatus);
100
+ return undefined;
101
+ }
102
+ return operationStatus?.map((status) => (0, exports.extractOperationStatus)(status));
103
+ };
104
+ exports.extractOperationStatuses = extractOperationStatuses;
105
+ const extractOperationStatus = (status) => {
106
+ if (!status) {
107
+ return undefined;
108
+ }
109
+ return {
110
+ blockHash: status.blockHash,
111
+ blockNumber: status.blockNumber ? BigInt(status.blockNumber) : undefined,
112
+ chainId: status.chainId
113
+ ? (0, utils_js_1.getChainIdFromOrbyChainId)(status.chainId)
114
+ : undefined,
115
+ errorReason: status.errorReason,
116
+ hash: status.hash,
117
+ id: status.id,
118
+ status: status.status,
119
+ type: status.type,
120
+ };
121
+ };
122
+ exports.extractOperationStatus = extractOperationStatus;
123
+ const extractActivities = (activities) => {
124
+ if (!activities) {
125
+ return undefined;
126
+ }
127
+ return activities.map((activity) => {
128
+ return {
129
+ aggregateFiatValueOfInputState: currency_amount_js_1.CurrencyAmount.toCurrencyAmount(activity.aggregateFiatValueOfInputState),
130
+ aggregateFiatValueOfOutputState: currency_amount_js_1.CurrencyAmount.toCurrencyAmount(activity.aggregateFiatValueOfOutputState),
131
+ aggregateNetworkFeesInFiatCurrency: currency_amount_js_1.CurrencyAmount.toCurrencyAmount(activity.aggregateNetworkFeesInFiatCurrency),
132
+ aggregateProtocolFeesInFiatCurrency: currency_amount_js_1.CurrencyAmount.toCurrencyAmount(activity.aggregateProtocolFeesInFiatCurrency),
133
+ category: activity.category,
134
+ initiateAt: activity.initiateAt,
135
+ inputState: state_js_1.State.toState(activity.inputState),
136
+ operationStatuses: (0, exports.extractOperationStatuses)(activity.operationStatuses),
137
+ outputState: state_js_1.State.toState(activity.outputState),
138
+ overallStatus: activity.overallStatus,
139
+ };
140
+ });
141
+ };
142
+ exports.extractActivities = extractActivities;
143
+ const extractFungibleTokenOverview = (overview) => {
144
+ if (!overview) {
145
+ return undefined;
146
+ }
147
+ else if ((0, utils_js_1.hasError)(overview)) {
148
+ console.error("[extractFungibleTokenOverview]", overview.code, overview.message);
149
+ return undefined;
150
+ }
151
+ return {
152
+ tokenCount: overview.tokenCount,
153
+ hiddenTokenCount: overview.hiddenTokenCount,
154
+ totalValueInFiat: currency_amount_js_1.CurrencyAmount.toCurrencyAmount(overview.totalValueInFiat),
155
+ };
156
+ };
157
+ exports.extractFungibleTokenOverview = extractFungibleTokenOverview;
158
+ const extractStandardizedBalances = (balances) => {
159
+ return balances?.map((balance) => (0, exports.extractStandardizedBalance)(balance));
160
+ };
161
+ exports.extractStandardizedBalances = extractStandardizedBalances;
162
+ const extractStandardizedBalance = (balance) => {
163
+ if (!balance) {
164
+ return undefined;
165
+ }
166
+ return {
167
+ standardizedTokenId: balance.standardizedTokenId,
168
+ tokenBalances: balance.tokenBalances.map((ft) => fungible_token_amount_js_1.FungibleTokenAmount.toFungibleTokenAmount(ft)),
169
+ tokenBalancesOnChains: balance.tokenBalancesOnChains.map((ft) => fungible_token_amount_js_1.FungibleTokenAmount.toFungibleTokenAmount(ft)),
170
+ total: currency_amount_js_1.CurrencyAmount.toCurrencyAmount(balance.total),
171
+ totalValueInFiat: currency_amount_js_1.CurrencyAmount.toCurrencyAmount(balance.totalValueInFiat),
172
+ };
173
+ };
174
+ exports.extractStandardizedBalance = extractStandardizedBalance;
175
+ const extractStandardizedTokens = (tokens) => {
176
+ return tokens?.map((token) => (0, exports.extractStandardizedToken)(token));
177
+ };
178
+ exports.extractStandardizedTokens = extractStandardizedTokens;
179
+ const extractStandardizedToken = (token) => {
180
+ if (!token) {
181
+ return undefined;
182
+ }
183
+ return {
184
+ standardizedTokenId: token.standardizedTokenId,
185
+ currency: currency_js_1.Currency.toCurrency(token.currency),
186
+ priceInFiat: currency_amount_js_1.CurrencyAmount.toCurrencyAmount(token.priceInFiat),
187
+ tokens: token.tokens.map((ft) => fungible_token_js_1.FungibleToken.toFungibleToken(ft)),
188
+ };
189
+ };
190
+ exports.extractStandardizedToken = extractStandardizedToken;
191
+ const extractBlockchainInformations = (blockchainInformation) => {
192
+ return blockchainInformation?.map((info) => (0, exports.extractBlockchainInformation)(info));
193
+ };
194
+ exports.extractBlockchainInformations = extractBlockchainInformations;
195
+ const extractBlockchainInformation = (blockchainInformation) => {
196
+ if (!blockchainInformation) {
197
+ return undefined;
198
+ }
199
+ return {
200
+ chainId: (0, utils_js_1.getChainIdFromOrbyChainId)(blockchainInformation.chainId),
201
+ environment: blockchainInformation.environment,
202
+ logoUrl: blockchainInformation.logoUrl,
203
+ name: blockchainInformation.name,
204
+ };
205
+ };
206
+ exports.extractBlockchainInformation = extractBlockchainInformation;
207
+ const extractMaxAmountPerInterval = (maxAmountPerInterval) => {
208
+ if (!maxAmountPerInterval) {
209
+ return undefined;
210
+ }
211
+ return {
212
+ amount: maxAmountPerInterval.amount,
213
+ interval: {
214
+ amount: maxAmountPerInterval.interval.amount,
215
+ unit: maxAmountPerInterval.interval.unit,
216
+ },
217
+ };
218
+ };
219
+ exports.extractMaxAmountPerInterval = extractMaxAmountPerInterval;
220
+ const extractAllowlistWithOpenFallback = (allowlist) => {
221
+ if (!allowlist) {
222
+ return undefined;
223
+ }
224
+ return {
225
+ tokenAllowlist: {
226
+ tokenAllowlistType: allowlist.tokenAllowlist.tokenAllowlistType,
227
+ sponsoredFunctions: allowlist.tokenAllowlist.sponsoredFunctions,
228
+ },
229
+ arbitraryContractAllowlist: allowlist.arbitraryContractAllowlist,
230
+ };
231
+ };
232
+ exports.extractAllowlistWithOpenFallback = extractAllowlistWithOpenFallback;
233
+ const extractGasSponsorshipPolicy = (gasSponsorshipPolicy) => {
234
+ if (!gasSponsorshipPolicy) {
235
+ return undefined;
236
+ }
237
+ return {
238
+ maxTotalGasSpendForInstance: (0, exports.extractMaxAmountPerInterval)(gasSponsorshipPolicy.maxTotalGasSpendForInstance),
239
+ maxGasSpendPerTransaction: gasSponsorshipPolicy.maxGasSpendPerTransaction,
240
+ allowlistWithOpenFallback: (0, exports.extractAllowlistWithOpenFallback)(gasSponsorshipPolicy.allowlistWithOpenFallback),
241
+ maxTotalTransactionCountForInstance: (0, exports.extractMaxAmountPerInterval)(gasSponsorshipPolicy.maxTotalTransactionCountForInstance),
242
+ maxTotalGasSpendPerUser: (0, exports.extractMaxAmountPerInterval)(gasSponsorshipPolicy.maxTotalGasSpendPerUser),
243
+ maxTotalTransactionCountPerUser: (0, exports.extractMaxAmountPerInterval)(gasSponsorshipPolicy.maxTotalTransactionCountPerUser),
244
+ };
245
+ };
246
+ exports.extractGasSponsorshipPolicy = extractGasSponsorshipPolicy;
247
+ const extractGasSpendForInstances = (gasSpendForInstances) => {
248
+ return gasSpendForInstances?.map((data) => (0, exports.extractGasSpendForInstance)(data));
249
+ };
250
+ exports.extractGasSpendForInstances = extractGasSpendForInstances;
251
+ const extractGasSpendForInstance = (gasSpendForInstance) => {
252
+ if (!gasSpendForInstance) {
253
+ return;
254
+ }
255
+ return {
256
+ instanceName: gasSpendForInstance.instanceName,
257
+ gasSpentForInstance: (0, exports.extractGasSponsorshipData)(gasSpendForInstance.gasSpentForInstance),
258
+ };
259
+ };
260
+ exports.extractGasSpendForInstance = extractGasSpendForInstance;
261
+ const extractGasSponsorshipInformation = (gasSponsorshipData) => {
262
+ return gasSponsorshipData?.map((data) => (0, exports.extractGasSponsorshipData)(data));
263
+ };
264
+ exports.extractGasSponsorshipInformation = extractGasSponsorshipInformation;
265
+ const extractGasSponsorshipData = (gasSponsorshipData) => {
266
+ if (!gasSponsorshipData) {
267
+ return undefined;
268
+ }
269
+ return {
270
+ totalGasSpent: currency_amount_js_1.CurrencyAmount.toCurrencyAmount(gasSponsorshipData.totalGasSpent),
271
+ totalTransactionCount: gasSponsorshipData.totalTransactionCount,
272
+ };
273
+ };
274
+ exports.extractGasSponsorshipData = extractGasSponsorshipData;
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isMainnet = exports.getBlockchainFromName = exports.hasError = exports.getBlockchainIdFromBlockchain = exports.getOrbyChainId = exports.getChainIdFromOrbyChainId = void 0;
4
+ const enums_js_1 = require("../enums.js");
5
+ const constants_js_1 = require("../constants.js");
6
+ const getChainIdFromOrbyChainId = (value) => {
7
+ let chainId = undefined;
8
+ const formattedValue = value?.trim()?.toLowerCase();
9
+ if (formattedValue?.includes("eip155")) {
10
+ const publicIdElements = formattedValue.split("eip155-");
11
+ const potentialId = publicIdElements?.length > 1 ? publicIdElements[1] : undefined;
12
+ chainId = !Number.isNaN(Number(potentialId))
13
+ ? BigInt(potentialId)
14
+ : undefined;
15
+ }
16
+ else {
17
+ const blockchain = (0, exports.getBlockchainFromName)(formattedValue);
18
+ const potentialId = blockchain
19
+ ? (0, exports.getBlockchainIdFromBlockchain)(blockchain)
20
+ : undefined;
21
+ chainId = potentialId ? BigInt(potentialId) : undefined;
22
+ }
23
+ return chainId;
24
+ };
25
+ exports.getChainIdFromOrbyChainId = getChainIdFromOrbyChainId;
26
+ const getOrbyChainId = (chainId) => {
27
+ if (!chainId) {
28
+ return undefined;
29
+ }
30
+ return `EIP155-${chainId.toString()}`;
31
+ };
32
+ exports.getOrbyChainId = getOrbyChainId;
33
+ const getBlockchainIdFromBlockchain = (blockchain) => {
34
+ return constants_js_1.BLOCKCHAIN_ID[blockchain];
35
+ };
36
+ exports.getBlockchainIdFromBlockchain = getBlockchainIdFromBlockchain;
37
+ const hasError = (data) => {
38
+ if (data?.code && data?.message) {
39
+ return { code: data.code, message: data.message };
40
+ }
41
+ return undefined;
42
+ };
43
+ exports.hasError = hasError;
44
+ const getBlockchainFromName = (chainName) => {
45
+ const formattedChainName = chainName?.toLowerCase()?.replace("-", "_");
46
+ switch (formattedChainName) {
47
+ case "bnbt": {
48
+ return enums_js_1.Blockchain.BINANCE_TESTNET;
49
+ }
50
+ case "matic_amoy": {
51
+ return enums_js_1.Blockchain.POLYGON_AMOY;
52
+ }
53
+ case "matic": {
54
+ return enums_js_1.Blockchain.POLYGON;
55
+ }
56
+ case "mainnet": {
57
+ return enums_js_1.Blockchain.ETHEREUM;
58
+ }
59
+ case "holesky": {
60
+ return enums_js_1.Blockchain.ETHEREUM_HOLESKY;
61
+ }
62
+ case "sepolia": {
63
+ return enums_js_1.Blockchain.ETHEREUM_SEPOLIA;
64
+ }
65
+ case "unknown": {
66
+ return undefined;
67
+ }
68
+ default: {
69
+ //statements;
70
+ return formattedChainName;
71
+ }
72
+ }
73
+ };
74
+ exports.getBlockchainFromName = getBlockchainFromName;
75
+ const isMainnet = (chainId) => {
76
+ const blockchain = constants_js_1.BLOCKCHAIN_ID_TO_BLOCKCHAIN[Number(chainId)];
77
+ return constants_js_1.CHAIN_CONFIGS[blockchain].environment == enums_js_1.BlockchainEnvironment.MAINNET;
78
+ };
79
+ exports.isMainnet = isMainnet;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateAndParseAddress = validateAndParseAddress;
4
+ exports.checkValidAddress = checkValidAddress;
5
+ const address_1 = require("@ethersproject/address");
6
+ /**
7
+ * Validates an address and returns the parsed (checksummed) version of that address
8
+ * @param address the unchecksummed hex address
9
+ */
10
+ function validateAndParseAddress(address) {
11
+ try {
12
+ return (0, address_1.getAddress)(address);
13
+ }
14
+ catch (error) {
15
+ throw new Error(`${address} is not a valid address.`);
16
+ }
17
+ }
18
+ // Checks a string starts with 0x, is 42 characters long and contains only hex characters after 0x
19
+ const startsWith0xLen42HexRegex = /^0x[0-9a-fA-F]{40}$/;
20
+ /**
21
+ * Checks if an address is valid by checking 0x prefix, length === 42 and hex encoding.
22
+ * @param address the unchecksummed hex address
23
+ */
24
+ function checkValidAddress(address) {
25
+ if (startsWith0xLen42HexRegex.test(address)) {
26
+ return address;
27
+ }
28
+ throw new Error(`${address} is not a valid address.`);
29
+ }