@orb-labs/orby-core 0.0.13 → 0.0.15

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 (141) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/actions/operation.d.ts +1 -1
  3. package/dist/actions/operation.js +5 -3
  4. package/dist/cjs/actions/account_cluster.d.ts +32 -0
  5. package/dist/cjs/actions/account_cluster.js +211 -0
  6. package/dist/cjs/actions/admin.d.ts +17 -0
  7. package/dist/cjs/actions/admin.js +43 -0
  8. package/dist/cjs/actions/application.d.ts +6 -0
  9. package/dist/cjs/actions/application.js +20 -0
  10. package/dist/cjs/actions/blockchain.d.ts +16 -0
  11. package/dist/cjs/actions/blockchain.js +39 -0
  12. package/dist/cjs/actions/instance.d.ts +15 -0
  13. package/dist/cjs/actions/instance.js +98 -0
  14. package/dist/cjs/actions/operation.d.ts +99 -0
  15. package/dist/cjs/actions/operation.js +345 -0
  16. package/dist/cjs/actions/token.d.ts +15 -0
  17. package/dist/cjs/actions/token.js +50 -0
  18. package/dist/cjs/constants.d.ts +14 -0
  19. package/dist/cjs/constants.js +139 -0
  20. package/dist/cjs/entities/account.d.ts +14 -0
  21. package/dist/cjs/entities/account.js +49 -0
  22. package/dist/cjs/entities/financial/account_balance.d.ts +12 -0
  23. package/dist/cjs/entities/financial/account_balance.js +35 -0
  24. package/dist/cjs/entities/financial/asset.d.ts +31 -0
  25. package/dist/cjs/entities/financial/asset.js +42 -0
  26. package/dist/cjs/entities/financial/currency.d.ts +41 -0
  27. package/dist/cjs/entities/financial/currency.js +56 -0
  28. package/dist/cjs/entities/financial/currency_amount.d.ts +34 -0
  29. package/dist/cjs/entities/financial/currency_amount.js +99 -0
  30. package/dist/cjs/entities/financial/fungible_token.d.ts +41 -0
  31. package/dist/cjs/entities/financial/fungible_token.js +68 -0
  32. package/dist/cjs/entities/financial/fungible_token_amount.d.ts +36 -0
  33. package/dist/cjs/entities/financial/fungible_token_amount.js +102 -0
  34. package/dist/cjs/entities/financial/non_fungible_token.d.ts +39 -0
  35. package/dist/cjs/entities/financial/non_fungible_token.js +65 -0
  36. package/dist/cjs/entities/financial/semi_fungible_token.d.ts +41 -0
  37. package/dist/cjs/entities/financial/semi_fungible_token.js +67 -0
  38. package/dist/cjs/entities/library_request.d.ts +8 -0
  39. package/dist/cjs/entities/library_request.js +37 -0
  40. package/dist/cjs/entities/state.d.ts +22 -0
  41. package/dist/cjs/entities/state.js +106 -0
  42. package/dist/cjs/enums.d.ts +116 -0
  43. package/dist/cjs/enums.js +138 -0
  44. package/dist/cjs/index.d.ts +29 -0
  45. package/dist/cjs/index.js +49 -0
  46. package/dist/cjs/interfaces/account_cluster.d.ts +30 -0
  47. package/dist/cjs/interfaces/account_cluster.js +2 -0
  48. package/dist/cjs/interfaces/admin.d.ts +14 -0
  49. package/dist/cjs/interfaces/admin.js +2 -0
  50. package/dist/cjs/interfaces/application.d.ts +3 -0
  51. package/dist/cjs/interfaces/application.js +2 -0
  52. package/dist/cjs/interfaces/blockchain.d.ts +13 -0
  53. package/dist/cjs/interfaces/blockchain.js +2 -0
  54. package/dist/cjs/interfaces/instance.d.ts +12 -0
  55. package/dist/cjs/interfaces/instance.js +2 -0
  56. package/dist/cjs/interfaces/operation.d.ts +97 -0
  57. package/dist/cjs/interfaces/operation.js +2 -0
  58. package/dist/cjs/interfaces/orby.d.ts +9 -0
  59. package/dist/cjs/interfaces/orby.js +2 -0
  60. package/dist/cjs/interfaces/token.d.ts +12 -0
  61. package/dist/cjs/interfaces/token.js +2 -0
  62. package/dist/cjs/types.d.ts +152 -0
  63. package/dist/cjs/types.js +2 -0
  64. package/dist/cjs/utils/action_helpers.d.ts +22 -0
  65. package/dist/cjs/utils/action_helpers.js +274 -0
  66. package/dist/cjs/utils/utils.d.ts +10 -0
  67. package/dist/cjs/utils/utils.js +79 -0
  68. package/dist/cjs/utils/validateAndParseAddress.d.ts +10 -0
  69. package/dist/cjs/utils/validateAndParseAddress.js +29 -0
  70. package/dist/esm/actions/account_cluster.d.ts +32 -0
  71. package/dist/esm/actions/account_cluster.js +207 -0
  72. package/dist/esm/actions/admin.d.ts +17 -0
  73. package/dist/esm/actions/admin.js +39 -0
  74. package/dist/esm/actions/application.d.ts +6 -0
  75. package/dist/esm/actions/application.js +16 -0
  76. package/dist/esm/actions/blockchain.d.ts +16 -0
  77. package/dist/esm/actions/blockchain.js +35 -0
  78. package/dist/esm/actions/instance.d.ts +15 -0
  79. package/dist/esm/actions/instance.js +94 -0
  80. package/dist/esm/actions/operation.d.ts +99 -0
  81. package/dist/esm/actions/operation.js +341 -0
  82. package/dist/esm/actions/token.d.ts +15 -0
  83. package/dist/esm/actions/token.js +46 -0
  84. package/dist/esm/constants.d.ts +14 -0
  85. package/dist/esm/constants.js +133 -0
  86. package/dist/esm/entities/account.d.ts +14 -0
  87. package/dist/esm/entities/account.js +45 -0
  88. package/dist/esm/entities/financial/account_balance.d.ts +12 -0
  89. package/dist/esm/entities/financial/account_balance.js +31 -0
  90. package/dist/esm/entities/financial/asset.d.ts +31 -0
  91. package/dist/esm/entities/financial/asset.js +38 -0
  92. package/dist/esm/entities/financial/currency.d.ts +41 -0
  93. package/dist/esm/entities/financial/currency.js +49 -0
  94. package/dist/esm/entities/financial/currency_amount.d.ts +34 -0
  95. package/dist/esm/entities/financial/currency_amount.js +92 -0
  96. package/dist/esm/entities/financial/fungible_token.d.ts +41 -0
  97. package/dist/esm/entities/financial/fungible_token.js +64 -0
  98. package/dist/esm/entities/financial/fungible_token_amount.d.ts +36 -0
  99. package/dist/esm/entities/financial/fungible_token_amount.js +95 -0
  100. package/dist/esm/entities/financial/non_fungible_token.d.ts +39 -0
  101. package/dist/esm/entities/financial/non_fungible_token.js +61 -0
  102. package/dist/esm/entities/financial/semi_fungible_token.d.ts +41 -0
  103. package/dist/esm/entities/financial/semi_fungible_token.js +63 -0
  104. package/dist/esm/entities/library_request.d.ts +8 -0
  105. package/dist/esm/entities/library_request.js +30 -0
  106. package/dist/esm/entities/state.d.ts +22 -0
  107. package/dist/esm/entities/state.js +102 -0
  108. package/dist/esm/enums.d.ts +116 -0
  109. package/dist/esm/enums.js +135 -0
  110. package/dist/esm/index.d.ts +29 -0
  111. package/dist/esm/index.js +33 -0
  112. package/dist/esm/interfaces/account_cluster.d.ts +30 -0
  113. package/dist/esm/interfaces/account_cluster.js +1 -0
  114. package/dist/esm/interfaces/admin.d.ts +14 -0
  115. package/dist/esm/interfaces/admin.js +1 -0
  116. package/dist/esm/interfaces/application.d.ts +3 -0
  117. package/dist/esm/interfaces/application.js +1 -0
  118. package/dist/esm/interfaces/blockchain.d.ts +13 -0
  119. package/dist/esm/interfaces/blockchain.js +1 -0
  120. package/dist/esm/interfaces/instance.d.ts +12 -0
  121. package/dist/esm/interfaces/instance.js +1 -0
  122. package/dist/esm/interfaces/operation.d.ts +97 -0
  123. package/dist/esm/interfaces/operation.js +1 -0
  124. package/dist/esm/interfaces/orby.d.ts +9 -0
  125. package/dist/esm/interfaces/orby.js +1 -0
  126. package/dist/esm/interfaces/token.d.ts +12 -0
  127. package/dist/esm/interfaces/token.js +1 -0
  128. package/dist/esm/types.d.ts +152 -0
  129. package/dist/esm/types.js +1 -0
  130. package/dist/esm/utils/action_helpers.d.ts +22 -0
  131. package/dist/esm/utils/action_helpers.js +250 -0
  132. package/dist/esm/utils/utils.d.ts +10 -0
  133. package/dist/esm/utils/utils.js +70 -0
  134. package/dist/esm/utils/validateAndParseAddress.d.ts +10 -0
  135. package/dist/esm/utils/validateAndParseAddress.js +25 -0
  136. package/dist/interfaces/operation.d.ts +1 -1
  137. package/dist/tsconfig.cjs.tsbuildinfo +1 -0
  138. package/dist/tsconfig.esm.tsbuildinfo +1 -0
  139. package/dist/tsconfig.tsbuildinfo +1 -1
  140. package/dist/utils/action_helpers.js +1 -1
  141. package/package.json +16 -7
@@ -0,0 +1,14 @@
1
+ import { GasSpendForInstance, GasSponsorshipData } from "../types.js";
2
+ export interface IAdminActions {
3
+ createInstance(name: string): Promise<{
4
+ success: boolean;
5
+ orbyInstancePrivateUrl: string;
6
+ orbyInstancePublicUrl: string;
7
+ }>;
8
+ getInstanceUrls(name: string): Promise<{
9
+ orbyInstancePrivateUrl: string;
10
+ orbyInstancePublicUrl: string;
11
+ }>;
12
+ getGasSpentForCustomer(month: string, year: string): Promise<GasSponsorshipData>;
13
+ getGasSpentForInstances(month: string, year: string, instanceNames: string[]): Promise<GasSpendForInstance[]>;
14
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ export interface IApplicationActions {
2
+ isChainAbstractionCompatible(appDomainUrl: string): Promise<boolean>;
3
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,13 @@
1
+ import { BlockchainInformation } from "../types.js";
2
+ export interface IBlockchainActions {
3
+ getBlockchainInformation(chainId: bigint): Promise<BlockchainInformation>;
4
+ listBlockchainsInformation(offset?: number, limit?: number): Promise<{
5
+ blockchains: BlockchainInformation[];
6
+ pageInfo: {
7
+ hasNextPage: boolean;
8
+ hasPreviousPage: boolean;
9
+ totalCount: number;
10
+ };
11
+ }>;
12
+ getChainsSupportedByDefault(chainId: bigint): Promise<BlockchainInformation[]>;
13
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,12 @@
1
+ import { ChainEndpoint, GasSponsorshipPolicy } from "../types.js";
2
+ export interface IInstanceActions {
3
+ setCustomChainEndpointsForInstance(chainEndpoints: ChainEndpoint[]): Promise<boolean>;
4
+ removeCustomChainEndpointForInstance(chainIds: bigint[]): Promise<boolean>;
5
+ getCustomChainEndpointsForInstance(returnChainIdsOnly: boolean): Promise<boolean>;
6
+ enableChainAbstractionForInstance(enable: boolean): Promise<boolean>;
7
+ enableGasSponsorshipForInstance(enable: boolean): Promise<boolean>;
8
+ getGasSponsorForInstance(): Promise<string>;
9
+ getOrbyGasSponsorPolicyForInstance(): Promise<GasSponsorshipPolicy>;
10
+ setOrbyGasSponsorPolicyForInstance(gasSponsorshipPolicy: GasSponsorshipPolicy): Promise<boolean>;
11
+ removeOrbyGasSponsorPolicyForInstance(): Promise<boolean>;
12
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,97 @@
1
+ import { OnchainOperation, OperationSet, OperationStatus, SignedOperation } from "../types.js";
2
+ import { CurrencyAmount } from "../entities/financial/currency_amount.js";
3
+ import { OperationStatusType, QuoteType } from "../enums.js";
4
+ export interface IOperationActions {
5
+ getOperationsToExecuteTransaction(accountClusterId: string, to: string, data: string, value?: bigint, gasToken?: {
6
+ standardizedTokenId: string;
7
+ tokenSources?: {
8
+ chainId: bigint;
9
+ address?: string;
10
+ }[];
11
+ }): Promise<OperationSet>;
12
+ getOperationsToSignTypedData(accountClusterId: string, data: string, gasToken?: {
13
+ standardizedTokenId: string;
14
+ tokenSources?: {
15
+ chainId: bigint;
16
+ address?: string;
17
+ }[];
18
+ }): Promise<OperationSet>;
19
+ getOperationsToCancelTransaction(accountClusterId: string, operationSetId: string): Promise<OperationSet>;
20
+ isTransactionPreconditionSatisfied(accountClusterId: string, to: string, data: string, value?: bigint): Promise<boolean>;
21
+ isTypedDataPreconditionSatisfied(accountClusterId: string, data: string): Promise<boolean>;
22
+ sendSignedOperations(accountClusterId: string, signedOperations: SignedOperation[]): Promise<{
23
+ operationSetId: string;
24
+ operationResponses: OperationStatus[];
25
+ }>;
26
+ getOperationStatuses(operationIds: string[]): Promise<OperationStatus[]>;
27
+ estimateFiatCostToExecuteTransaction(to: string, data: string, value?: bigint): Promise<CurrencyAmount>;
28
+ estimateFiatCostToSignTypedData(data: string): Promise<CurrencyAmount>;
29
+ getOperationsToTransferToken(accountClusterId: string, standardizedTokenId: string, amount: bigint, recipient: {
30
+ chainId: bigint;
31
+ recipientAddress: string;
32
+ }, gasToken?: {
33
+ standardizedTokenId: string;
34
+ tokenSources?: {
35
+ chainId: bigint;
36
+ address?: string;
37
+ }[];
38
+ }): Promise<OperationSet>;
39
+ getOperationsToSwap(accountClusterId: string, swapType: QuoteType, input: {
40
+ standardizedTokenId: string;
41
+ amount?: bigint;
42
+ tokenSources?: {
43
+ chainId: bigint;
44
+ address?: string;
45
+ }[];
46
+ }, output: {
47
+ standardizedTokenId: string;
48
+ amount?: bigint;
49
+ tokenDestination?: {
50
+ chainId: bigint;
51
+ address?: string;
52
+ };
53
+ }, gasToken?: {
54
+ standardizedTokenId: string;
55
+ tokenSources?: {
56
+ chainId: bigint;
57
+ address?: string;
58
+ }[];
59
+ }): Promise<OperationSet>;
60
+ getQuote(accountClusterId: string, swapType: QuoteType, input: {
61
+ standardizedTokenId: string;
62
+ amount?: bigint;
63
+ tokenSources?: {
64
+ chainId: bigint;
65
+ address?: string;
66
+ }[];
67
+ }, output: {
68
+ standardizedTokenId: string;
69
+ amount?: bigint;
70
+ tokenDestination?: {
71
+ chainId: bigint;
72
+ address?: string;
73
+ };
74
+ }): Promise<OperationSet>;
75
+ getOperationsToBridge(accountClusterId: string, standardizedTokenId: string, amount: bigint, tokenSources?: {
76
+ chainId: bigint;
77
+ address?: string;
78
+ }[], tokenDestination?: {
79
+ chainId: bigint;
80
+ address?: string;
81
+ }, gasToken?: {
82
+ standardizedTokenId: string;
83
+ tokenSources?: {
84
+ chainId: bigint;
85
+ address?: string;
86
+ }[];
87
+ }): Promise<OperationSet>;
88
+ subscribeToOperationStatuses(ids?: string[], onOperationStatusesUpdateCallback?: (statusSummary: OperationStatusType, primaryOperationStatus?: OperationStatus, allOperationStatuses?: OperationStatus[]) => void, timout?: number): {
89
+ intervalId: NodeJS.Timeout | null;
90
+ };
91
+ sendOperationSet(accountClusterId: string, operationSet: OperationSet, signOperation: (operation: OnchainOperation) => Promise<SignedOperation | undefined>): Promise<{
92
+ success: boolean;
93
+ operationSetId?: string;
94
+ primaryOperationStatus?: OperationStatus;
95
+ operationResponses?: OperationStatus[];
96
+ }>;
97
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,9 @@
1
+ import { IAccountClusterActions } from "./account_cluster.js";
2
+ import { IAdminActions } from "./admin.js";
3
+ import { IApplicationActions } from "./application.js";
4
+ import { IBlockchainActions } from "./blockchain.js";
5
+ import { IInstanceActions } from "./instance.js";
6
+ import { IOperationActions } from "./operation.js";
7
+ import { ITokenActions } from "./token.js";
8
+ export interface Orby extends IAccountClusterActions, IAdminActions, IApplicationActions, IInstanceActions, IOperationActions, ITokenActions, IBlockchainActions {
9
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,12 @@
1
+ import { StandardizedToken } from "../types.js";
2
+ export interface ITokenActions {
3
+ getStandardizedTokenIds(tokens: {
4
+ tokenAddress: string;
5
+ chainId: bigint;
6
+ }[]): Promise<string[]>;
7
+ getStandardizedTokens(tokens: {
8
+ tokenAddress: string;
9
+ chainId: bigint;
10
+ }[]): Promise<StandardizedToken[]>;
11
+ getFungibleTokenData(standardizedTokenIds: string[]): Promise<StandardizedToken[]>;
12
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,152 @@
1
+ import { Account } from "./entities/account.js";
2
+ import { Currency } from "./entities/financial/currency.js";
3
+ import { CurrencyAmount } from "./entities/financial/currency_amount.js";
4
+ import { FungibleToken } from "./entities/financial/fungible_token.js";
5
+ import { FungibleTokenAmount } from "./entities/financial/fungible_token_amount.js";
6
+ import { State } from "./entities/state.js";
7
+ import { ActivityStatus, BlockchainEnvironment, Category, CreateOperationsStatus, OperationDataFormat, OperationStatusType, OperationType, TimeIntervalUnits, TokenAllowlistType } from "./enums.js";
8
+ export type AccountCluster = {
9
+ accountClusterId: string;
10
+ accounts: Account[];
11
+ };
12
+ export type ChainEndpoint = {
13
+ chainId: bigint;
14
+ customRpcUrls?: string[];
15
+ customIndexerUrls?: string[];
16
+ };
17
+ export interface OperationSet {
18
+ status: CreateOperationsStatus;
19
+ primaryOperation?: OnchainOperation;
20
+ primaryOperationPreconditions?: State;
21
+ inputState?: State;
22
+ outputState?: State;
23
+ intents?: Intent[];
24
+ aggregateNetworkFeeInFiatCurrency?: CurrencyAmount;
25
+ aggregateOperationFeeInFiatCurrency?: CurrencyAmount;
26
+ aggregateEstimatedTimeInMs?: number;
27
+ }
28
+ export type Intent = {
29
+ estimatedProtocolFees?: FungibleTokenAmount;
30
+ estimatedProtocolFeesInFiatCurrency?: CurrencyAmount;
31
+ inputState?: State;
32
+ intentOperations?: OnchainOperation[];
33
+ outputState?: State;
34
+ };
35
+ export interface OnchainOperation {
36
+ chainId: bigint;
37
+ data: string;
38
+ estimatedNetworkFees?: CurrencyAmount;
39
+ estimatedNetworkFeesInFiatCurrency?: CurrencyAmount;
40
+ estimatedTimeInMs?: number;
41
+ format: OperationDataFormat;
42
+ from?: string;
43
+ gasLimit?: bigint;
44
+ gasPrice?: bigint;
45
+ inputState?: State;
46
+ maxFeePerGas?: bigint;
47
+ maxPriorityFeePerGas?: bigint;
48
+ nativeCurrency?: Currency;
49
+ nonce?: bigint;
50
+ outputState?: State;
51
+ to?: string;
52
+ txRpcUrl: string;
53
+ type: OperationType;
54
+ value?: bigint;
55
+ }
56
+ export type SignedOperation = {
57
+ type: OperationType;
58
+ signature: string;
59
+ category?: Category;
60
+ data?: string;
61
+ };
62
+ export type OperationStatus = {
63
+ blockHash?: string;
64
+ blockNumber?: bigint;
65
+ chainId?: bigint;
66
+ errorReason?: string;
67
+ hash?: string;
68
+ id?: string;
69
+ status: OperationStatusType;
70
+ type: OperationType;
71
+ };
72
+ export type Activity = {
73
+ aggregateFiatValueOfInputState?: CurrencyAmount;
74
+ aggregateFiatValueOfOutputState?: CurrencyAmount;
75
+ aggregateNetworkFeesInFiatCurrency?: CurrencyAmount;
76
+ aggregateProtocolFeesInFiatCurrency?: CurrencyAmount;
77
+ category: Category;
78
+ initiateAt?: Date;
79
+ inputState?: State;
80
+ operationStatuses: OperationStatus[];
81
+ outputState?: State;
82
+ overallStatus: ActivityStatus;
83
+ };
84
+ export type FungibleTokenOverview = {
85
+ tokenCount: number;
86
+ hiddenTokenCount: number;
87
+ totalValueInFiat: CurrencyAmount;
88
+ };
89
+ export type StandardizedBalance = {
90
+ standardizedTokenId: string;
91
+ tokenBalances: FungibleTokenAmount[];
92
+ tokenBalancesOnChains: FungibleTokenAmount[];
93
+ total: CurrencyAmount;
94
+ totalValueInFiat?: CurrencyAmount;
95
+ };
96
+ export type StandardizedToken = {
97
+ standardizedTokenId: string;
98
+ currency: Currency;
99
+ priceInFiat?: CurrencyAmount;
100
+ tokens: FungibleToken[];
101
+ };
102
+ export type BlockchainInformation = {
103
+ chainId: bigint;
104
+ environment: BlockchainEnvironment;
105
+ logoUrl?: string;
106
+ name?: string;
107
+ };
108
+ export type ContractAllowlistWithAllMethodFallback = {
109
+ contractAddress: string;
110
+ sponsoredFunctions?: string[];
111
+ };
112
+ export type TokenAllowlistWithAllMethodsFallback = {
113
+ sponsoredFunctions?: string[];
114
+ tokenAllowlistType: TokenAllowlistType;
115
+ };
116
+ export type AllowlistWithOpenFallback = {
117
+ arbitraryContractAllowlist?: ContractAllowlistWithAllMethodFallback[];
118
+ tokenAllowlist?: TokenAllowlistWithAllMethodsFallback;
119
+ };
120
+ export type TimeInterval = {
121
+ amount?: bigint;
122
+ unit: TimeIntervalUnits;
123
+ };
124
+ export type MaxAmountPerInterval = {
125
+ amount: bigint;
126
+ interval: TimeInterval;
127
+ };
128
+ export type GasSponsorshipPolicy = {
129
+ allowlistWithOpenFallback?: AllowlistWithOpenFallback;
130
+ maxGasSpendPerTransaction?: bigint;
131
+ maxTotalGasSpendForInstance?: MaxAmountPerInterval;
132
+ maxTotalGasSpendPerUser?: MaxAmountPerInterval;
133
+ maxTotalTransactionCountForInstance?: MaxAmountPerInterval;
134
+ maxTotalTransactionCountPerUser?: MaxAmountPerInterval;
135
+ };
136
+ export type GasSpendForInstance = {
137
+ instanceName?: string;
138
+ gasSpentForInstance?: GasSponsorshipData;
139
+ };
140
+ export type GasSponsorshipData = {
141
+ totalGasSpent: CurrencyAmount;
142
+ totalTransactionCount: bigint;
143
+ };
144
+ export type ChainConfigs = {
145
+ environment: BlockchainEnvironment;
146
+ chainId: bigint;
147
+ };
148
+ export type VirtualNodeRpcUrlForSupportedChain = {
149
+ chainId: string;
150
+ entrypointAccountAddress: string;
151
+ virtualNodeRpcUrl: string;
152
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,22 @@
1
+ import { AccountCluster, Activity, AllowlistWithOpenFallback, BlockchainInformation, FungibleTokenOverview, GasSpendForInstance, GasSponsorshipData, GasSponsorshipPolicy, Intent, MaxAmountPerInterval, OnchainOperation, OperationSet, OperationStatus, StandardizedBalance, StandardizedToken } from "../types.js";
2
+ export declare const extractAccountCluster: (accountCluster?: any) => AccountCluster;
3
+ export declare const extractOperationSet: (operationSet?: any) => OperationSet;
4
+ export declare const extractOnchainOperation: (onchainOperation?: any) => OnchainOperation;
5
+ export declare const extractIntent: (intent?: any) => Intent;
6
+ export declare const extractOperationStatuses: (operationStatus?: any[]) => OperationStatus[];
7
+ export declare const extractOperationStatus: (status?: any) => OperationStatus;
8
+ export declare const extractActivities: (activities?: any[]) => Activity[];
9
+ export declare const extractFungibleTokenOverview: (overview?: any) => FungibleTokenOverview;
10
+ export declare const extractStandardizedBalances: (balances?: any) => StandardizedBalance[];
11
+ export declare const extractStandardizedBalance: (balance?: any) => StandardizedBalance;
12
+ export declare const extractStandardizedTokens: (tokens?: any) => StandardizedToken[];
13
+ export declare const extractStandardizedToken: (token?: any) => StandardizedToken;
14
+ export declare const extractBlockchainInformations: (blockchainInformation?: any[]) => BlockchainInformation[];
15
+ export declare const extractBlockchainInformation: (blockchainInformation?: any) => BlockchainInformation;
16
+ export declare const extractMaxAmountPerInterval: (maxAmountPerInterval?: any) => MaxAmountPerInterval;
17
+ export declare const extractAllowlistWithOpenFallback: (allowlist?: any) => AllowlistWithOpenFallback;
18
+ export declare const extractGasSponsorshipPolicy: (gasSponsorshipPolicy?: any) => GasSponsorshipPolicy;
19
+ export declare const extractGasSpendForInstances: (gasSpendForInstances?: any[]) => GasSpendForInstance[];
20
+ export declare const extractGasSpendForInstance: (gasSpendForInstance?: any) => GasSpendForInstance;
21
+ export declare const extractGasSponsorshipInformation: (gasSponsorshipData?: any[]) => GasSponsorshipData[];
22
+ export declare const extractGasSponsorshipData: (gasSponsorshipData?: any) => GasSponsorshipData;
@@ -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,10 @@
1
+ import { Blockchain } from "../enums.js";
2
+ export declare const getChainIdFromOrbyChainId: (value: string) => bigint | undefined;
3
+ export declare const getOrbyChainId: (chainId: bigint) => string;
4
+ export declare const getBlockchainIdFromBlockchain: (blockchain: Blockchain) => number;
5
+ export declare const hasError: (data: any) => {
6
+ code: number;
7
+ message: string;
8
+ };
9
+ export declare const getBlockchainFromName: (chainName: string) => Blockchain;
10
+ export declare const isMainnet: (chainId: bigint) => boolean;