@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,32 @@
1
+ import { Account } from "../entities/account.js";
2
+ import { AccountCluster, Activity, ChainEndpoint, FungibleTokenOverview, StandardizedBalance, VirtualNodeRpcUrlForSupportedChain } from "../types.js";
3
+ import { ChainSupportStatus, LIBRARY_TYPE, Order } from "../enums.js";
4
+ import { LibraryRequest } from "../entities/library_request.js";
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
+ getVirtualNodeRpcUrlsForSupportedChains(accountClusterId: string): Promise<VirtualNodeRpcUrlForSupportedChain[]>;
11
+ enableChainAbstractionForAccountCluster(accountClusterId: string, enable: boolean): Promise<boolean>;
12
+ setCustomChainEndpointsForAccountCluster(accountClusterId: string, chainEndpoints: ChainEndpoint[]): Promise<boolean>;
13
+ removeCustomChainEndpointsForAccountCluster(accountClusterId: string, chainIds: bigint[]): Promise<boolean>;
14
+ getCustomChainEndpointsForAccountCluster(accountClusterId: string, returnChainIdsOnly: boolean): Promise<ChainEndpoint[]>;
15
+ isChainSupportedOnAccountCluster(accountClusterId: string, chainId: bigint): Promise<ChainSupportStatus>;
16
+ getNodeRpcUrl(accountClusterId: string, chainId: bigint): Promise<string>;
17
+ getVirtualNodeRpcUrl(accountClusterId: string, chainId: bigint, entrypointAccountAddress: string): Promise<string>;
18
+ getActivity(accountClusterId: string, limit?: number, offset?: number, order?: Order, startDate?: number, endDate?: number, filters?: {
19
+ transactionHash?: string;
20
+ address?: string;
21
+ }[]): Promise<{
22
+ activities: Activity[];
23
+ pageInfo: {
24
+ hasNextPage: boolean;
25
+ hasPreviousPage: boolean;
26
+ totalCount: number;
27
+ };
28
+ }>;
29
+ getPortfolioOverview(accountClusterId: string): Promise<FungibleTokenOverview>;
30
+ getFungibleTokenPortfolio(accountClusterId: string): Promise<StandardizedBalance[]>;
31
+ getFungibleTokenBalances(accountClusterId: string, offset?: number, limit?: number, chainId?: bigint, tokensToOmit?: string[]): Promise<StandardizedBalance[]>;
32
+ }
@@ -0,0 +1,17 @@
1
+ import { GasSpendForInstance, GasSponsorshipData } from "../types.js";
2
+ import { LibraryRequest } from "../entities/library_request.js";
3
+ import { LIBRARY_TYPE } from "../enums.js";
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,6 @@
1
+ import { LibraryRequest } from "../entities/library_request.js";
2
+ import { LIBRARY_TYPE } from "../enums.js";
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,16 @@
1
+ import { BlockchainInformation } from "../types.js";
2
+ import { LibraryRequest } from "../entities/library_request.js";
3
+ import { LIBRARY_TYPE } from "../enums.js";
4
+ export declare class BlockchainActions extends LibraryRequest {
5
+ constructor(library: LIBRARY_TYPE, client?: any, provider?: any);
6
+ getBlockchainInformation(chainId: bigint): Promise<BlockchainInformation>;
7
+ listBlockchainsInformation(offset?: number, limit?: number): Promise<{
8
+ blockchains: BlockchainInformation[];
9
+ pageInfo: {
10
+ hasNextPage: boolean;
11
+ hasPreviousPage: boolean;
12
+ totalCount: number;
13
+ };
14
+ }>;
15
+ getChainsSupportedByDefault(): Promise<BlockchainInformation[]>;
16
+ }
@@ -0,0 +1,15 @@
1
+ import { ChainEndpoint, GasSponsorshipPolicy } from "../types.js";
2
+ import { LIBRARY_TYPE } from "../enums.js";
3
+ import { LibraryRequest } from "../entities/library_request.js";
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
+ enableChainAbstractionForInstance(enable: boolean): Promise<boolean>;
10
+ enableGasSponsorshipForInstance(enable: boolean): Promise<boolean>;
11
+ getGasSponsorForInstance(): Promise<string>;
12
+ getOrbyGasSponsorPolicyForInstance(): Promise<GasSponsorshipPolicy>;
13
+ setOrbyGasSponsorPolicyForInstance(gasSponsorshipPolicy: GasSponsorshipPolicy): Promise<boolean>;
14
+ removeOrbyGasSponsorPolicyForInstance(): Promise<boolean>;
15
+ }
@@ -0,0 +1,99 @@
1
+ import { AccountCluster, OnchainOperation, OperationSet, OperationStatus, SignedOperation, UserOperation } from "../types.js";
2
+ import { CurrencyAmount } from "../entities/financial/currency_amount.js";
3
+ import { LIBRARY_TYPE, OperationStatusType, QuoteType } from "../enums.js";
4
+ import { LibraryRequest } from "../entities/library_request.js";
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?: bigint, gasToken?: {
8
+ standardizedTokenId: string;
9
+ tokenSources?: {
10
+ chainId: bigint;
11
+ address?: string;
12
+ }[];
13
+ }): Promise<OperationSet>;
14
+ getOperationsToSignTypedData(accountClusterId: string, data: string, gasToken?: {
15
+ standardizedTokenId: string;
16
+ tokenSources?: {
17
+ chainId: bigint;
18
+ address?: string;
19
+ }[];
20
+ }): Promise<OperationSet>;
21
+ getOperationsToCancelTransaction(accountClusterId: string, operationSetId: string): Promise<OperationSet>;
22
+ isTransactionPreconditionSatisfied(accountClusterId: string, to: string, data: string, value?: bigint): Promise<boolean>;
23
+ isTypedDataPreconditionSatisfied(accountClusterId: string, data: string): Promise<boolean>;
24
+ sendSignedOperations(accountClusterId: string, signedOperations: SignedOperation[]): Promise<{
25
+ operationSetId: string;
26
+ operationResponses: OperationStatus[];
27
+ }>;
28
+ getOperationStatuses(operationIds: string[]): Promise<OperationStatus[]>;
29
+ estimateFiatCostToExecuteTransaction(to: string, data: string, value?: bigint): Promise<CurrencyAmount>;
30
+ estimateFiatCostToSignTypedData(data: string): Promise<CurrencyAmount>;
31
+ getOperationsToTransferToken(accountClusterId: string, standardizedTokenId: string, amount: bigint, recipient: {
32
+ chainId: bigint;
33
+ recipientAddress: string;
34
+ }, gasToken?: {
35
+ standardizedTokenId: string;
36
+ tokenSources?: {
37
+ chainId: bigint;
38
+ address?: string;
39
+ }[];
40
+ }): Promise<OperationSet>;
41
+ getOperationsToSwap(accountClusterId: string, swapType: QuoteType, input: {
42
+ standardizedTokenId: string;
43
+ amount?: bigint;
44
+ tokenSources?: {
45
+ chainId: bigint;
46
+ address?: string;
47
+ }[];
48
+ }, output: {
49
+ standardizedTokenId: string;
50
+ amount?: bigint;
51
+ tokenDestination?: {
52
+ chainId: bigint;
53
+ address?: string;
54
+ };
55
+ }, gasToken?: {
56
+ standardizedTokenId: string;
57
+ tokenSources?: {
58
+ chainId: bigint;
59
+ address?: string;
60
+ }[];
61
+ }): Promise<OperationSet>;
62
+ getQuote(accountClusterId: string, swapType: QuoteType, input: {
63
+ standardizedTokenId: string;
64
+ amount?: bigint;
65
+ tokenSources?: {
66
+ chainId: bigint;
67
+ address?: string;
68
+ }[];
69
+ }, output: {
70
+ standardizedTokenId: string;
71
+ amount?: bigint;
72
+ tokenDestination?: {
73
+ chainId: bigint;
74
+ address?: string;
75
+ };
76
+ }): Promise<OperationSet>;
77
+ getOperationsToBridge(accountClusterId: string, standardizedTokenId: string, amount: bigint, tokenSources?: {
78
+ chainId: bigint;
79
+ address?: string;
80
+ }[], tokenDestination?: {
81
+ chainId: bigint;
82
+ address?: string;
83
+ }, gasToken?: {
84
+ standardizedTokenId: string;
85
+ tokenSources?: {
86
+ chainId: bigint;
87
+ address?: string;
88
+ }[];
89
+ }): Promise<OperationSet>;
90
+ subscribeToOperationStatuses(ids?: string[], onOperationStatusesUpdateCallback?: (statusSummary: OperationStatusType, primaryOperationStatus?: OperationStatus, allOperationStatuses?: OperationStatus[]) => void, timout?: number): {
91
+ intervalId: NodeJS.Timeout | null;
92
+ };
93
+ 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<{
94
+ success: boolean;
95
+ operationSetId?: string;
96
+ primaryOperationStatus?: OperationStatus;
97
+ operationResponses?: OperationStatus[];
98
+ }>;
99
+ }
@@ -1,8 +1,13 @@
1
1
  import { extractOperationSet, extractOperationStatuses, } from "../utils/action_helpers.js";
2
2
  import { CurrencyAmount } from "../entities/financial/currency_amount.js";
3
- import { OperationStatusType, OperationType, } from "../enums.js";
3
+ import { AccountType, OperationDataFormat, OperationStatusType, OperationType, } from "../enums.js";
4
4
  import { LibraryRequest } from "../entities/library_request.js";
5
5
  import { getOrbyChainId } from "../utils/utils.js";
6
+ import { Account } from "../entities/account.js";
7
+ // from here: https://stackoverflow.com/questions/65152373/typescript-serialize-bigint-in-json
8
+ BigInt.prototype.toJSON = function () {
9
+ return this.toString();
10
+ };
6
11
  export class OperationActions extends LibraryRequest {
7
12
  constructor(library, client, provider) {
8
13
  super(library, client, provider);
@@ -302,7 +307,7 @@ export class OperationActions extends LibraryRequest {
302
307
  }
303
308
  return { intervalId };
304
309
  }
305
- async sendOperationSet(accountClusterId, operationSet, signOperation) {
310
+ async sendOperationSet(accountCluster, operationSet, signTransaction, signUserOperation, signTypedData) {
306
311
  const signedOperations = [];
307
312
  const operations = operationSet.intents
308
313
  ?.map((intent) => intent.intentOperations)
@@ -319,15 +324,80 @@ export class OperationActions extends LibraryRequest {
319
324
  if (!hasPrimaryOperation) {
320
325
  return { success: false };
321
326
  }
327
+ const accountsMap = accountCluster.accounts.reduce((acc, account) => {
328
+ acc.set(account.key, account);
329
+ return acc;
330
+ }, new Map());
331
+ const smartAccountTransactions = operations.reduce((acc, operation) => {
332
+ const accountKey = Account.key(operation.from, operation.chainId);
333
+ const account = accountsMap.get(accountKey);
334
+ if (account?.accountType == AccountType.SCA &&
335
+ operation.format == OperationDataFormat.TRANSACTION) {
336
+ if (!acc.has(accountKey)) {
337
+ acc.set(accountKey, []);
338
+ }
339
+ acc.get(accountKey).push(operation);
340
+ }
341
+ return acc;
342
+ }, new Map());
322
343
  // Loop through all the operations and sign them
323
344
  for (let i = 0; i < operations.length; i++) {
324
- const signature = await signOperation(operations[i]);
345
+ const operation = operations[i];
346
+ let signature;
347
+ if (operation.format == OperationDataFormat.TRANSACTION) {
348
+ const accountKey = Account.key(operation.from, operation.chainId);
349
+ const account = accountsMap.get(accountKey);
350
+ // skip signing the transaction if the account is an SCA
351
+ if (account?.accountType == AccountType.SCA) {
352
+ continue;
353
+ }
354
+ signature = await signTransaction(operation);
355
+ }
356
+ else if (operation.format == OperationDataFormat.TYPED_DATA) {
357
+ signature = await signTypedData(operation);
358
+ }
325
359
  if (!signature) {
326
360
  return { success: false };
327
361
  }
328
- signedOperations.push(signature);
362
+ signedOperations.push({
363
+ type: operation.type,
364
+ signature: signature,
365
+ data: operation.data,
366
+ from: operation.from,
367
+ chainId: getOrbyChainId(operation.chainId),
368
+ });
369
+ }
370
+ // batch sign all the smart contract transactions
371
+ const accountKeys = Array.from(smartAccountTransactions.keys());
372
+ for (const accountKey of accountKeys) {
373
+ const transactions = smartAccountTransactions.get(accountKey);
374
+ transactions.sort((operationA, _) => {
375
+ if (operationA.type == OperationType.APPROVE_ERC20_TOKEN) {
376
+ return -1;
377
+ }
378
+ return 0;
379
+ });
380
+ const userOperation = await signUserOperation(transactions, transactions[0].from, transactions[0].chainId, transactions[0].txRpcUrl);
381
+ if (!userOperation) {
382
+ return { success: false };
383
+ }
384
+ const types = transactions.map((operation) => operation.type);
385
+ let type = types[0];
386
+ if (types.includes(OperationType.FINAL_TRANSACTION)) {
387
+ type = OperationType.FINAL_TRANSACTION;
388
+ }
389
+ else if (types.includes(OperationType.SUBMIT_INTENT)) {
390
+ type = OperationType.SUBMIT_INTENT;
391
+ }
392
+ signedOperations.push({
393
+ type,
394
+ signature: userOperation.signature,
395
+ data: JSON.stringify(userOperation),
396
+ from: transactions[0].from,
397
+ chainId: getOrbyChainId(transactions[0].chainId),
398
+ });
329
399
  }
330
- const { operationSetId, operationResponses } = await this.sendSignedOperations(accountClusterId, signedOperations);
400
+ const { operationSetId, operationResponses } = await this.sendSignedOperations(accountCluster.accountClusterId, signedOperations);
331
401
  return {
332
402
  operationSetId,
333
403
  operationResponses,
@@ -0,0 +1,15 @@
1
+ import { StandardizedToken } from "../types.js";
2
+ import { LibraryRequest } from "../entities/library_request.js";
3
+ import { LIBRARY_TYPE } from "../enums.js";
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
+ }
@@ -1,4 +1,4 @@
1
- import { extractStandardizedTokens, } from "../utils/action_helpers.js";
1
+ import { extractStandardizedTokens } from "../utils/action_helpers.js";
2
2
  import { LibraryRequest } from "../entities/library_request.js";
3
3
  import { getOrbyChainId } from "../utils/utils.js";
4
4
  export class TokenActions extends LibraryRequest {
@@ -0,0 +1,14 @@
1
+ import { Blockchain } from "./enums.js";
2
+ import { Currency } from "./entities/financial/currency.js";
3
+ import { ChainConfigs } from "./types.js";
4
+ export declare const Big: any;
5
+ export declare const BLOCKCHAIN_ID: {
6
+ [s: string]: number;
7
+ };
8
+ export declare const CHAIN_CONFIGS: {
9
+ [s: string]: ChainConfigs;
10
+ };
11
+ export declare const BLOCKCHAIN_ID_TO_BLOCKCHAIN: {
12
+ [s: number]: Blockchain;
13
+ };
14
+ export declare const FIAT_CURRENCY: Currency;
@@ -0,0 +1,14 @@
1
+ import { AccountType, VMType } from "../enums.js";
2
+ export declare class Account {
3
+ readonly address: string;
4
+ readonly chainId?: bigint;
5
+ readonly accountType: AccountType;
6
+ readonly vmType: VMType;
7
+ readonly key: string;
8
+ hasSufficientBalanceForGas: boolean;
9
+ static toAccount(account: any): Account;
10
+ constructor(address: string, accountType: AccountType, vmType: VMType, chainId?: bigint);
11
+ static key(address: string, chainId?: bigint): string;
12
+ toAccountModel(): any;
13
+ equals(other: Account): boolean;
14
+ }
@@ -5,7 +5,7 @@ export class Account {
5
5
  const chainId = account?.chainId
6
6
  ? getChainIdFromOrbyChainId(account.chainId)
7
7
  : undefined;
8
- const formattedAccountType = account?.accountType?.toLowerCase();
8
+ const formattedAccountType = account?.accountType;
9
9
  if (!chainId && formattedAccountType == AccountType.SCA) {
10
10
  return undefined;
11
11
  }
@@ -0,0 +1,12 @@
1
+ import { Account } from "../account.js";
2
+ import { FungibleTokenAmount } from "./fungible_token_amount.js";
3
+ export declare class AccountBalance {
4
+ readonly amount: FungibleTokenAmount;
5
+ readonly account: Account;
6
+ static toAccountBalance(balance?: any): AccountBalance;
7
+ constructor(amount: FungibleTokenAmount, account: Account);
8
+ equals(other: AccountBalance): boolean;
9
+ lessThan(other: AccountBalance): boolean;
10
+ greaterThan(other: AccountBalance): boolean;
11
+ greaterThanOrEqual(other: AccountBalance): boolean;
12
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * An Asset is any fungible financial instrument, including Ether, all ERC20 tokens, and NFTs
3
+ */
4
+ export declare class Asset {
5
+ /**
6
+ * The symbol of the asset, i.e. a short textual non-unique identifier
7
+ */
8
+ readonly symbol: string;
9
+ /**
10
+ * The name of the asset, i.e. a descriptive textual non-unique identifier
11
+ */
12
+ readonly name: string;
13
+ /**
14
+ * The name of the asset, i.e. a descriptive textual non-unique identifier
15
+ */
16
+ readonly coinGeckoId: string;
17
+ /**
18
+ * Constructs an instance of the `Asset`.
19
+ * @param symbol symbol of the asset
20
+ * @param name of the asset
21
+ */
22
+ constructor(symbol: string, name: string, coinGeckoId?: string);
23
+ /**
24
+ * Returns whether this asset is functionally equivalent to the other asset
25
+ * @param other the other asset
26
+ */
27
+ equals(other: Asset): boolean;
28
+ toAssetModel(): any;
29
+ static toAsset(asset?: any): Asset;
30
+ id(): string;
31
+ }
@@ -0,0 +1,41 @@
1
+ import { Asset } from "./asset.js";
2
+ /**
3
+ * A currency is any fungible financial instrument, including Ether, all ERC20 tokens, and other chain-native currencies
4
+ */
5
+ export declare class Currency extends Asset {
6
+ /**
7
+ * Returns whether the currency is native to the chain and must be wrapped (e.g. Ether)
8
+ */
9
+ readonly isNative: boolean;
10
+ /**
11
+ * Returns whether the currency is a token that is usable in Uniswap without wrapping
12
+ */
13
+ readonly isToken: boolean;
14
+ /**
15
+ * The decimals used in representing currency amounts
16
+ */
17
+ readonly decimals: number;
18
+ /**
19
+ * The url for the currency logo
20
+ */
21
+ readonly logoUrl?: string;
22
+ /**
23
+ * Constructs an instance of the base class `Currency`.
24
+ * @param decimals decimals of the currency
25
+ * @param symbol symbol of the currency
26
+ * @param name of the currency
27
+ * @param isNative whether the currency is native to the chain and must be wrapped (e.g. Ether)
28
+ * @param isToken whether the currency is a token that is usable in Uniswap without wrapping
29
+ */
30
+ constructor(decimals: number, symbol: string, name: string, logoUrl?: string, isNative?: boolean, isToken?: boolean, coinGeckoId?: string);
31
+ /**
32
+ * Returns whether this currency is functionally equivalent to the other currency
33
+ * @param other the other currency
34
+ */
35
+ equals(other: Currency): boolean;
36
+ /**
37
+ * Returns the asset representation of this currency
38
+ */
39
+ asset(): Asset;
40
+ static toCurrency(currency?: any): Currency;
41
+ }
@@ -0,0 +1,34 @@
1
+ import JSBI from "jsbi";
2
+ import { Fraction, BigintIsh, Rounding } from "@uniswap/sdk-core";
3
+ import { Currency } from "./currency.js";
4
+ export declare class CurrencyAmount extends Fraction {
5
+ readonly currency: Currency;
6
+ readonly decimalScale: JSBI;
7
+ private amountInFiatCurrency?;
8
+ /**
9
+ * Returns a new currency amount instance from the unitless amount of token, i.e. the raw amount
10
+ * @param currency the currency in the amount
11
+ * @param rawAmount the raw token or ether amount
12
+ */
13
+ static fromRawAmount(currency: Currency, rawAmount: BigintIsh | bigint): CurrencyAmount;
14
+ static toCurrencyAmount(amount?: any): CurrencyAmount;
15
+ /**
16
+ * Construct a currency amount with a denominator that is not equal to 1
17
+ * @param currency the currency
18
+ * @param numerator the numerator of the fractional token amount
19
+ * @param denominator the denominator of the fractional token amount
20
+ */
21
+ static fromFractionalAmount(currency: Currency, numerator: BigintIsh, denominator: BigintIsh): CurrencyAmount;
22
+ protected constructor(currency: Currency, numerator: BigintIsh | bigint, denominator?: BigintIsh | bigint);
23
+ add(other: CurrencyAmount): CurrencyAmount;
24
+ subtract(other: CurrencyAmount): CurrencyAmount;
25
+ multiply(other: Fraction | BigintIsh): CurrencyAmount;
26
+ divide(other: Fraction | BigintIsh): CurrencyAmount;
27
+ cloneWithAmount(amount: bigint): CurrencyAmount;
28
+ toRawAmount(): bigint;
29
+ toCurrencyValue(price: CurrencyAmount): CurrencyAmount;
30
+ fiatValue(): CurrencyAmount;
31
+ toSignificant(significantDigits?: number, format?: object, rounding?: Rounding): string;
32
+ toFixed(decimalPlaces?: number, format?: object, rounding?: Rounding): string;
33
+ toExact(format?: object): string;
34
+ }
@@ -0,0 +1,41 @@
1
+ import { Currency } from "./currency.js";
2
+ import { TokenType } from "../../enums.js";
3
+ /**
4
+ * Represents an ERC20 token with a unique address and some metadata.
5
+ */
6
+ export declare class FungibleToken extends Currency {
7
+ readonly isToken: true;
8
+ /**
9
+ * The contract address on the chain on which this token lives
10
+ */
11
+ readonly address: string;
12
+ /**
13
+ * The chain ID on which this token resides
14
+ */
15
+ readonly chainId: bigint;
16
+ /**
17
+ * @param isNative If true, it means that this token is the native token of the chain
18
+ */
19
+ readonly isNative: boolean;
20
+ static toFungibleToken(token?: any): FungibleToken;
21
+ /**
22
+ * @param chainId The chain ID on which this token resides
23
+ * @param address The contract address on the chain on which this token lives
24
+ * @param decimals {@link Currency#decimals}
25
+ * @param symbol {@link Currency#symbol}
26
+ * @param name {@link Currency#name}
27
+ * @param bypassChecksum If true it only checks for length === 42, startsWith 0x and contains only hex characters
28
+ */
29
+ constructor(chainId: bigint, address: string, decimals: number, symbol: string, name: string, bypassChecksum?: boolean, isNative?: boolean, coinGeckoId?: string, logoUrl?: string);
30
+ /**
31
+ * Returns true if the two tokens are equivalent, i.e. have the same chainId and address.
32
+ * @param other other token to compare
33
+ */
34
+ equals(other: FungibleToken): boolean;
35
+ /**
36
+ * Returns the currency object that this token represents
37
+ */
38
+ currency(): Currency;
39
+ type(): TokenType;
40
+ identifier(): string;
41
+ }
@@ -0,0 +1,36 @@
1
+ import JSBI from "jsbi";
2
+ import { Fraction, BigintIsh, Rounding } from "@uniswap/sdk-core";
3
+ import { FungibleToken } from "./fungible_token.js";
4
+ import { CurrencyAmount } from "./currency_amount.js";
5
+ export declare class FungibleTokenAmount extends Fraction {
6
+ readonly token: FungibleToken;
7
+ readonly decimalScale: JSBI;
8
+ private amountInFiatCurrency?;
9
+ /**
10
+ * Returns a new fungibleToken amount instance from the unitless amount of token, i.e. the raw amount
11
+ * @param fungibleToken the fungibleToken in the amount
12
+ * @param rawAmount the raw token or ether amount
13
+ */
14
+ static fromRawAmount(fungibleToken: FungibleToken, rawAmount: BigintIsh | bigint, amountInFiatCurrency?: CurrencyAmount): FungibleTokenAmount;
15
+ /**
16
+ * Construct a fungibleToken amount with a denominator that is not equal to 1
17
+ * @param fungibleToken the fungibleToken
18
+ * @param numerator the numerator of the fractional token amount
19
+ * @param denominator the denominator of the fractional token amount
20
+ */
21
+ static fromFractionalAmount(fungibleToken: FungibleToken, numerator: BigintIsh, denominator: BigintIsh, amountInFiatCurrency?: CurrencyAmount): FungibleTokenAmount;
22
+ static toFungibleTokenAmount(amount?: any): FungibleTokenAmount;
23
+ protected constructor(fungibleToken: FungibleToken, numerator: BigintIsh | bigint, denominator?: BigintIsh | bigint, amountInFiatCurrency?: CurrencyAmount);
24
+ equals(other: FungibleTokenAmount): boolean;
25
+ add(other: FungibleTokenAmount): FungibleTokenAmount;
26
+ subtract(other: FungibleTokenAmount): FungibleTokenAmount;
27
+ multiply(other: Fraction | BigintIsh): FungibleTokenAmount;
28
+ divide(other: Fraction | BigintIsh): FungibleTokenAmount;
29
+ greaterThanOrEqual(other: FungibleTokenAmount): boolean;
30
+ toRawAmount(): bigint;
31
+ fiatValue(): CurrencyAmount;
32
+ toCurrencyValue(price: CurrencyAmount): CurrencyAmount;
33
+ toSignificant(significantDigits?: number, format?: object, rounding?: Rounding): string;
34
+ toFixed(decimalPlaces?: number, format?: object, rounding?: Rounding): string;
35
+ toExact(format?: object): string;
36
+ }
@@ -0,0 +1,39 @@
1
+ import { Asset } from "./asset.js";
2
+ import { TokenType } from "../../enums.js";
3
+ /**
4
+ * Represents an ERC721 token with a unique address and some metadata.
5
+ */
6
+ export declare class NonFungibleToken extends Asset {
7
+ readonly isNative: false;
8
+ readonly isToken: true;
9
+ /**
10
+ * The contract address on the chain on which this token lives
11
+ */
12
+ readonly address: string;
13
+ /**
14
+ * The chain ID on which this token resides
15
+ */
16
+ readonly chainId: bigint;
17
+ readonly url?: string;
18
+ /**
19
+ * @param chainId The chain ID on which this token resides
20
+ * @param address The contract address on the chain on which this token lives
21
+ * @param symbol {@link Currency#symbol}
22
+ * @param name {@link Currency#name}
23
+ * @param url The URL of the token's metadata
24
+ * @param bypassChecksum If true it only checks for length === 42, startsWith 0x and contains only hex characters
25
+ */
26
+ constructor(chainId: bigint, address: string, symbol: string, name: string, url?: string, bypassChecksum?: boolean, coinGeckoId?: string);
27
+ static toNonFungibleToken(nft?: any): NonFungibleToken;
28
+ /**
29
+ * Returns true if the two tokens are equivalent, i.e. have the same chainId and address.
30
+ * @param other other token to compare
31
+ */
32
+ equals(other: NonFungibleToken): boolean;
33
+ /**
34
+ * Returns the asset representation of this currency
35
+ */
36
+ asset(): Asset;
37
+ type(): TokenType;
38
+ identifier(): string;
39
+ }
@@ -0,0 +1,41 @@
1
+ import { Currency } from "./currency.js";
2
+ import { TokenType } from "../../enums.js";
3
+ /**
4
+ * Represents an ERC1155 token with a unique address and some metadata.
5
+ */
6
+ export declare class SemiFungibleToken extends Currency {
7
+ readonly isNative: false;
8
+ readonly isToken: true;
9
+ /**
10
+ * The contract address on the chain on which this token lives
11
+ */
12
+ readonly address: string;
13
+ /**
14
+ * The chain ID on which this token resides
15
+ */
16
+ readonly chainId: bigint;
17
+ readonly url?: string;
18
+ /**
19
+ *
20
+ * @param chainId The chain ID on which this token resides
21
+ * @param address The contract address on the chain on which this token lives
22
+ * @param decimals {@link Currency#decimals}
23
+ * @param symbol {@link Currency#symbol}
24
+ * @param name {@link Currency#name}
25
+ * @param url The URL of the token's metadata
26
+ * @param bypassChecksum If true it only checks for length === 42, startsWith 0x and contains only hex characters
27
+ */
28
+ constructor(chainId: bigint, address: string, decimals: number, symbol: string, name: string, url?: string, bypassChecksum?: boolean, coinGeckoId?: string);
29
+ static toSemiFungibleToken(sft?: any): SemiFungibleToken;
30
+ /**
31
+ * Returns true if the two tokens are equivalent, i.e. have the same chainId and address.
32
+ * @param other other token to compare
33
+ */
34
+ equals(other: SemiFungibleToken): boolean;
35
+ /**
36
+ * Returns the currency object that this token represents
37
+ */
38
+ currency(): Currency;
39
+ type(): TokenType;
40
+ identifier(): string;
41
+ }
@@ -0,0 +1,8 @@
1
+ import { LIBRARY_TYPE } from "../enums.js";
2
+ export declare class LibraryRequest {
3
+ readonly library: LIBRARY_TYPE;
4
+ readonly client?: any;
5
+ readonly provider?: any;
6
+ constructor(library: LIBRARY_TYPE, client?: any, provider?: any);
7
+ sendRequest(method: string, params: any[]): Promise<any>;
8
+ }