@coinbase/cdp-sdk 1.33.0 → 1.34.0

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 (130) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/_cjs/accounts/evm/toEvmServerAccount.js +1 -1
  3. package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -1
  4. package/_cjs/accounts/evm/toEvmSmartAccount.js +1 -1
  5. package/_cjs/accounts/evm/toEvmSmartAccount.js.map +1 -1
  6. package/_cjs/accounts/evm/toNetworkScopedEvmServerAccount.js +2 -2
  7. package/_cjs/accounts/evm/toNetworkScopedEvmServerAccount.js.map +1 -1
  8. package/_cjs/accounts/evm/toNetworkScopedEvmSmartAccount.js +2 -2
  9. package/_cjs/accounts/evm/toNetworkScopedEvmSmartAccount.js.map +1 -1
  10. package/_cjs/actions/evm/listSpendPermissions.js +19 -1
  11. package/_cjs/actions/evm/listSpendPermissions.js.map +1 -1
  12. package/_cjs/actions/evm/spend-permissions/resolveSpendPermission.js +64 -0
  13. package/_cjs/actions/evm/spend-permissions/resolveSpendPermission.js.map +1 -0
  14. package/_cjs/client/evm/evm.js +12 -11
  15. package/_cjs/client/evm/evm.js.map +1 -1
  16. package/_cjs/index.js.map +1 -1
  17. package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +45 -2
  18. package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
  19. package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js +79 -20
  20. package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js.map +1 -1
  21. package/_cjs/openapi-client/generated/evm-token-balances/evm-token-balances.js +1 -2
  22. package/_cjs/openapi-client/generated/evm-token-balances/evm-token-balances.js.map +1 -1
  23. package/_cjs/openapi-client/generated/index.msw.js +1 -0
  24. package/_cjs/openapi-client/generated/index.msw.js.map +1 -1
  25. package/_cjs/openapi-client/generated/onchain-data/onchain-data.js +63 -0
  26. package/_cjs/openapi-client/generated/onchain-data/onchain-data.js.map +1 -0
  27. package/_cjs/openapi-client/generated/onchain-data/onchain-data.msw.js +139 -0
  28. package/_cjs/openapi-client/generated/onchain-data/onchain-data.msw.js.map +1 -0
  29. package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js +48 -4
  30. package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js.map +1 -1
  31. package/_cjs/openapi-client/index.js +1 -0
  32. package/_cjs/openapi-client/index.js.map +1 -1
  33. package/_cjs/spend-permissions/utils.js +26 -0
  34. package/_cjs/spend-permissions/utils.js.map +1 -0
  35. package/_cjs/version.js +1 -1
  36. package/_esm/accounts/evm/toEvmServerAccount.js +1 -1
  37. package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -1
  38. package/_esm/accounts/evm/toEvmSmartAccount.js +1 -1
  39. package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -1
  40. package/_esm/accounts/evm/toNetworkScopedEvmServerAccount.js +2 -2
  41. package/_esm/accounts/evm/toNetworkScopedEvmServerAccount.js.map +1 -1
  42. package/_esm/accounts/evm/toNetworkScopedEvmSmartAccount.js +2 -2
  43. package/_esm/accounts/evm/toNetworkScopedEvmSmartAccount.js.map +1 -1
  44. package/_esm/actions/evm/listSpendPermissions.js +19 -1
  45. package/_esm/actions/evm/listSpendPermissions.js.map +1 -1
  46. package/_esm/actions/evm/spend-permissions/resolveSpendPermission.js +61 -0
  47. package/_esm/actions/evm/spend-permissions/resolveSpendPermission.js.map +1 -0
  48. package/_esm/client/evm/evm.js +13 -12
  49. package/_esm/client/evm/evm.js.map +1 -1
  50. package/_esm/index.js.map +1 -1
  51. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +43 -0
  52. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
  53. package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js +79 -20
  54. package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js.map +1 -1
  55. package/_esm/openapi-client/generated/evm-token-balances/evm-token-balances.js +1 -2
  56. package/_esm/openapi-client/generated/evm-token-balances/evm-token-balances.js.map +1 -1
  57. package/_esm/openapi-client/generated/index.msw.js +1 -0
  58. package/_esm/openapi-client/generated/index.msw.js.map +1 -1
  59. package/_esm/openapi-client/generated/onchain-data/onchain-data.js +57 -0
  60. package/_esm/openapi-client/generated/onchain-data/onchain-data.js.map +1 -0
  61. package/_esm/openapi-client/generated/onchain-data/onchain-data.msw.js +129 -0
  62. package/_esm/openapi-client/generated/onchain-data/onchain-data.msw.js.map +1 -0
  63. package/_esm/openapi-client/generated/policy-engine/policy-engine.msw.js +48 -4
  64. package/_esm/openapi-client/generated/policy-engine/policy-engine.msw.js.map +1 -1
  65. package/_esm/openapi-client/index.js +1 -0
  66. package/_esm/openapi-client/index.js.map +1 -1
  67. package/_esm/spend-permissions/utils.js +23 -0
  68. package/_esm/spend-permissions/utils.js.map +1 -0
  69. package/_esm/version.js +1 -1
  70. package/_types/accounts/evm/toEvmServerAccount.d.ts.map +1 -1
  71. package/_types/accounts/evm/toNetworkScopedEvmSmartAccount.d.ts.map +1 -1
  72. package/_types/accounts/evm/types.d.ts +5 -5
  73. package/_types/accounts/evm/types.d.ts.map +1 -1
  74. package/_types/actions/evm/listSpendPermissions.d.ts +10 -2
  75. package/_types/actions/evm/listSpendPermissions.d.ts.map +1 -1
  76. package/_types/actions/evm/spend-permissions/resolveSpendPermission.d.ts +12 -0
  77. package/_types/actions/evm/spend-permissions/resolveSpendPermission.d.ts.map +1 -0
  78. package/_types/actions/evm/spend-permissions/types.d.ts +3 -2
  79. package/_types/actions/evm/spend-permissions/types.d.ts.map +1 -1
  80. package/_types/actions/evm/types.d.ts +4 -8
  81. package/_types/actions/evm/types.d.ts.map +1 -1
  82. package/_types/client/evm/evm.d.ts +3 -2
  83. package/_types/client/evm/evm.d.ts.map +1 -1
  84. package/_types/client/evm/evm.types.d.ts +7 -44
  85. package/_types/client/evm/evm.types.d.ts.map +1 -1
  86. package/_types/index.d.ts +2 -1
  87. package/_types/index.d.ts.map +1 -1
  88. package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +167 -20
  89. package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
  90. package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.d.ts.map +1 -1
  91. package/_types/openapi-client/generated/evm-token-balances/evm-token-balances.d.ts +1 -2
  92. package/_types/openapi-client/generated/evm-token-balances/evm-token-balances.d.ts.map +1 -1
  93. package/_types/openapi-client/generated/index.msw.d.ts +1 -0
  94. package/_types/openapi-client/generated/index.msw.d.ts.map +1 -1
  95. package/_types/openapi-client/generated/onchain-data/onchain-data.d.ts +59 -0
  96. package/_types/openapi-client/generated/onchain-data/onchain-data.d.ts.map +1 -0
  97. package/_types/openapi-client/generated/onchain-data/onchain-data.msw.d.ts +10 -0
  98. package/_types/openapi-client/generated/onchain-data/onchain-data.msw.d.ts.map +1 -0
  99. package/_types/openapi-client/generated/policy-engine/policy-engine.msw.d.ts.map +1 -1
  100. package/_types/openapi-client/index.d.ts +1 -0
  101. package/_types/openapi-client/index.d.ts.map +1 -1
  102. package/_types/spend-permissions/types.d.ts +40 -5
  103. package/_types/spend-permissions/types.d.ts.map +1 -1
  104. package/_types/spend-permissions/utils.d.ts +12 -0
  105. package/_types/spend-permissions/utils.d.ts.map +1 -0
  106. package/_types/version.d.ts +1 -1
  107. package/accounts/evm/toEvmServerAccount.ts +1 -3
  108. package/accounts/evm/toEvmSmartAccount.ts +1 -1
  109. package/accounts/evm/toNetworkScopedEvmServerAccount.ts +4 -4
  110. package/accounts/evm/toNetworkScopedEvmSmartAccount.ts +4 -4
  111. package/accounts/evm/types.ts +5 -5
  112. package/actions/evm/listSpendPermissions.ts +42 -3
  113. package/actions/evm/spend-permissions/resolveSpendPermission.ts +85 -0
  114. package/actions/evm/spend-permissions/types.ts +3 -2
  115. package/actions/evm/types.ts +4 -12
  116. package/client/evm/evm.ts +25 -16
  117. package/client/evm/evm.types.ts +6 -48
  118. package/index.ts +2 -1
  119. package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +185 -20
  120. package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.ts +79 -20
  121. package/openapi-client/generated/evm-token-balances/evm-token-balances.ts +1 -2
  122. package/openapi-client/generated/index.msw.ts +1 -0
  123. package/openapi-client/generated/onchain-data/onchain-data.msw.ts +185 -0
  124. package/openapi-client/generated/onchain-data/onchain-data.ts +103 -0
  125. package/openapi-client/generated/policy-engine/policy-engine.msw.ts +48 -4
  126. package/openapi-client/index.ts +1 -0
  127. package/package.json +1 -1
  128. package/spend-permissions/types.ts +46 -16
  129. package/spend-permissions/utils.ts +35 -0
  130. package/version.ts +1 -1
@@ -45,6 +45,7 @@ export const ErrorType = {
45
45
  idempotency_error: "idempotency_error",
46
46
  internal_server_error: "internal_server_error",
47
47
  invalid_request: "invalid_request",
48
+ invalid_sql_query: "invalid_sql_query",
48
49
  invalid_signature: "invalid_signature",
49
50
  malformed_transaction: "malformed_transaction",
50
51
  not_found: "not_found",
@@ -202,6 +203,20 @@ export interface UserOperationReceiptRevert {
202
203
  */
203
204
  export interface UserOperationReceipt {
204
205
  revert?: UserOperationReceiptRevert;
206
+ /**
207
+ * The hash of this transaction as 0x-prefixed string.
208
+ * @pattern ^0x[a-fA-F0-9]{64}$
209
+ */
210
+ transactionHash?: string;
211
+ /**
212
+ * The block hash of the block including the transaction as 0x-prefixed string.
213
+ * @pattern ^0x[0-9a-fA-F]{64}$|^$
214
+ */
215
+ blockHash?: string;
216
+ /** The block height (number) of the block including the transaction. */
217
+ blockNumber?: number;
218
+ /** The gas used for landing this user operation. */
219
+ gasUsed?: string;
205
220
  }
206
221
 
207
222
  /**
@@ -240,21 +255,33 @@ export interface EvmUserOperation {
240
255
  receipts?: UserOperationReceipt[];
241
256
  }
242
257
 
258
+ /**
259
+ * The network the spend permission is on.
260
+ */
261
+ export type SpendPermissionNetwork =
262
+ (typeof SpendPermissionNetwork)[keyof typeof SpendPermissionNetwork];
263
+
264
+ // eslint-disable-next-line @typescript-eslint/no-redeclare
265
+ export const SpendPermissionNetwork = {
266
+ base: "base",
267
+ "base-sepolia": "base-sepolia",
268
+ ethereum: "ethereum",
269
+ "ethereum-sepolia": "ethereum-sepolia",
270
+ optimism: "optimism",
271
+ arbitrum: "arbitrum",
272
+ avalanche: "avalanche",
273
+ polygon: "polygon",
274
+ } as const;
275
+
243
276
  export interface CreateSpendPermissionRequest {
244
- /** The network of the spend permission. */
245
- network: string;
277
+ network: SpendPermissionNetwork;
246
278
  /**
247
- * Smart account this spend permission is valid for.
248
- * @pattern ^0x[a-fA-F0-9]{40}$
249
- */
250
- account: string;
251
- /**
252
- * Entity that can spend account's tokens.
279
+ * Entity that can spend account's tokens. Can be either a Smart Account or an EOA.
253
280
  * @pattern ^0x[a-fA-F0-9]{40}$
254
281
  */
255
282
  spender: string;
256
283
  /**
257
- * Token address (ERC-7528 native token address or ERC-20 contract).
284
+ * ERC-7528 native token address (e.g. "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE" for native ETH), or an ERC-20 contract address.
258
285
  * @pattern ^0x[a-fA-F0-9]{40}$
259
286
  */
260
287
  token: string;
@@ -296,32 +323,31 @@ export interface SpendPermission {
296
323
  /** Maximum allowed value to spend, in atomic units for the specified token, within each period. */
297
324
  allowance: string;
298
325
  /** Time duration for resetting used allowance on a recurring basis (seconds). */
299
- period?: string;
326
+ period: string;
300
327
  /** The start time for this spend permission, in Unix seconds. */
301
- start?: string;
328
+ start: string;
302
329
  /** The expiration time for this spend permission, in Unix seconds. */
303
- end?: string;
330
+ end: string;
304
331
  /** An arbitrary salt to differentiate unique spend permissions with otherwise identical data. */
305
- salt?: string;
332
+ salt: string;
306
333
  /** Arbitrary data to include in the permission. */
307
- extraData?: string;
334
+ extraData: string;
308
335
  }
309
336
 
310
337
  export interface SpendPermissionResponseObject {
311
- permission?: SpendPermission;
338
+ permission: SpendPermission;
312
339
  /** Unique hash identifier for this permission. */
313
- permissionHash?: string;
340
+ permissionHash: string;
314
341
  /** Whether this permission has been revoked. */
315
- revoked?: boolean;
342
+ revoked: boolean;
316
343
  /** The UTC ISO 8601 timestamp when the permission was revoked (if applicable). */
317
344
  revokedAt?: string;
318
345
  /** The UTC ISO 8601 timestamp when the permission was created. */
319
- createdAt?: string;
346
+ createdAt: string;
320
347
  }
321
348
 
322
349
  export interface RevokeSpendPermissionRequest {
323
- /** The network of the spend permission. */
324
- network: string;
350
+ network: SpendPermissionNetwork;
325
351
  /** The hash of the spend permission to revoke. */
326
352
  permissionHash: string;
327
353
  /** The paymaster URL of the spend permission. */
@@ -1032,6 +1058,14 @@ export type EvmNetworkCriterionNetworksItem =
1032
1058
  export const EvmNetworkCriterionNetworksItem = {
1033
1059
  "base-sepolia": "base-sepolia",
1034
1060
  base: "base",
1061
+ ethereum: "ethereum",
1062
+ "ethereum-sepolia": "ethereum-sepolia",
1063
+ avalanche: "avalanche",
1064
+ polygon: "polygon",
1065
+ optimism: "optimism",
1066
+ arbitrum: "arbitrum",
1067
+ zora: "zora",
1068
+ bnb: "bnb",
1035
1069
  } as const;
1036
1070
 
1037
1071
  /**
@@ -1847,6 +1881,109 @@ export interface SolanaTokenBalance {
1847
1881
  token: SolanaToken;
1848
1882
  }
1849
1883
 
1884
+ /**
1885
+ * Request to execute a SQL query against indexed blockchain data.
1886
+ */
1887
+ export interface OnchainDataQuery {
1888
+ /**
1889
+ * SQL query to execute against the indexed blockchain data.
1890
+ * @minLength 1
1891
+ * @maxLength 10000
1892
+ */
1893
+ sql: string;
1894
+ }
1895
+
1896
+ /**
1897
+ * Row data with column names as keys.
1898
+ */
1899
+ export type OnchainDataResultResultItem = { [key: string]: unknown };
1900
+
1901
+ /**
1902
+ * Column data type (ClickHouse types).
1903
+ */
1904
+ export type OnchainDataResultSchemaColumnsItemType =
1905
+ (typeof OnchainDataResultSchemaColumnsItemType)[keyof typeof OnchainDataResultSchemaColumnsItemType];
1906
+
1907
+ // eslint-disable-next-line @typescript-eslint/no-redeclare
1908
+ export const OnchainDataResultSchemaColumnsItemType = {
1909
+ String: "String",
1910
+ UInt8: "UInt8",
1911
+ UInt16: "UInt16",
1912
+ UInt32: "UInt32",
1913
+ UInt64: "UInt64",
1914
+ UInt128: "UInt128",
1915
+ UInt256: "UInt256",
1916
+ Int8: "Int8",
1917
+ Int16: "Int16",
1918
+ Int32: "Int32",
1919
+ Int64: "Int64",
1920
+ Int128: "Int128",
1921
+ Int256: "Int256",
1922
+ Float32: "Float32",
1923
+ Float64: "Float64",
1924
+ Bool: "Bool",
1925
+ Date: "Date",
1926
+ DateTime: "DateTime",
1927
+ DateTime64: "DateTime64",
1928
+ UUID: "UUID",
1929
+ } as const;
1930
+
1931
+ export type OnchainDataResultSchemaColumnsItem = {
1932
+ /** Column name. */
1933
+ name?: string;
1934
+ /** Column data type (ClickHouse types). */
1935
+ type?: OnchainDataResultSchemaColumnsItemType;
1936
+ };
1937
+
1938
+ /**
1939
+ * Schema information for the query result. This is a derived schema from the query result, so types may not match the underlying table.
1940
+
1941
+ */
1942
+ export type OnchainDataResultSchema = {
1943
+ /** Column definitions. */
1944
+ columns?: OnchainDataResultSchemaColumnsItem[];
1945
+ };
1946
+
1947
+ /**
1948
+ * Metadata about query execution.
1949
+ */
1950
+ export type OnchainDataResultMetadata = {
1951
+ /** Whether the result was served from cache. */
1952
+ cached?: boolean;
1953
+ /** Query execution time in milliseconds. */
1954
+ executionTimeMs?: number;
1955
+ /** Number of rows returned. */
1956
+ rowCount?: number;
1957
+ };
1958
+
1959
+ /**
1960
+ * Result of executing a SQL query.
1961
+ */
1962
+ export interface OnchainDataResult {
1963
+ /** Query result as an array of objects representing rows. */
1964
+ result?: OnchainDataResultResultItem[];
1965
+ /** Schema information for the query result. This is a derived schema from the query result, so types may not match the underlying table.
1966
+ */
1967
+ schema?: OnchainDataResultSchema;
1968
+ /** Metadata about query execution. */
1969
+ metadata?: OnchainDataResultMetadata;
1970
+ }
1971
+
1972
+ /**
1973
+ * Response containing token addresses that an account has received.
1974
+ */
1975
+ export interface AccountTokenAddressesResponse {
1976
+ /** The account address that was queried. */
1977
+ accountAddress?: string;
1978
+ /** List of token contract addresses that the account has received. */
1979
+ tokenAddresses?: string[];
1980
+ /**
1981
+ * Total number of unique token addresses discovered.
1982
+ * @minimum 0
1983
+ */
1984
+ totalCount?: number;
1985
+ }
1986
+
1850
1987
  /**
1851
1988
  * The action of the payment method.
1852
1989
  */
@@ -2211,11 +2348,21 @@ export type IdempotencyErrorResponse = Error;
2211
2348
  */
2212
2349
  export type AlreadyExistsErrorResponse = Error;
2213
2350
 
2351
+ /**
2352
+ * The underlying SQL string is invalid.
2353
+ */
2354
+ export type InvalidSQLQueryErrorResponse = Error;
2355
+
2214
2356
  /**
2215
2357
  * Unauthorized.
2216
2358
  */
2217
2359
  export type UnauthorizedErrorResponse = Error;
2218
2360
 
2361
+ /**
2362
+ * The request timed out.
2363
+ */
2364
+ export type TimedOutErrorResponse = Error;
2365
+
2219
2366
  /**
2220
2367
  * Rate limit exceeded.
2221
2368
  */
@@ -2806,6 +2953,24 @@ export type ListSolanaTokenBalances200AllOf = {
2806
2953
 
2807
2954
  export type ListSolanaTokenBalances200 = ListSolanaTokenBalances200AllOf & ListResponse;
2808
2955
 
2956
+ export type ListDataTokenBalancesParams = {
2957
+ /**
2958
+ * The number of balances to return per page.
2959
+ */
2960
+ pageSize?: number;
2961
+ /**
2962
+ * The token for the next page of balances. Will be empty if there are no more balances to fetch.
2963
+ */
2964
+ pageToken?: string;
2965
+ };
2966
+
2967
+ export type ListDataTokenBalances200AllOf = {
2968
+ /** The list of EVM token balances. */
2969
+ balances: TokenBalance[];
2970
+ };
2971
+
2972
+ export type ListDataTokenBalances200 = ListDataTokenBalances200AllOf & ListResponse;
2973
+
2809
2974
  export type GetCryptoRailsParams = {
2810
2975
  /**
2811
2976
  * Comma separated list of networks to filter the rails by.
@@ -199,6 +199,19 @@ export const getPrepareUserOperationResponseMock = (
199
199
  { data: faker.helpers.fromRegExp("^0x[0-9a-fA-F]*$"), message: faker.string.alpha(20) },
200
200
  undefined,
201
201
  ]),
202
+ transactionHash: faker.helpers.arrayElement([
203
+ faker.helpers.fromRegExp("^0x[a-fA-F0-9]{64}$"),
204
+ undefined,
205
+ ]),
206
+ blockHash: faker.helpers.arrayElement([
207
+ faker.helpers.fromRegExp("^0x[0-9a-fA-F]{64}$|^$"),
208
+ undefined,
209
+ ]),
210
+ blockNumber: faker.helpers.arrayElement([
211
+ faker.number.int({ min: undefined, max: undefined }),
212
+ undefined,
213
+ ]),
214
+ gasUsed: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
202
215
  })),
203
216
  undefined,
204
217
  ]),
@@ -233,6 +246,19 @@ export const getGetUserOperationResponseMock = (
233
246
  { data: faker.helpers.fromRegExp("^0x[0-9a-fA-F]*$"), message: faker.string.alpha(20) },
234
247
  undefined,
235
248
  ]),
249
+ transactionHash: faker.helpers.arrayElement([
250
+ faker.helpers.fromRegExp("^0x[a-fA-F0-9]{64}$"),
251
+ undefined,
252
+ ]),
253
+ blockHash: faker.helpers.arrayElement([
254
+ faker.helpers.fromRegExp("^0x[0-9a-fA-F]{64}$|^$"),
255
+ undefined,
256
+ ]),
257
+ blockNumber: faker.helpers.arrayElement([
258
+ faker.number.int({ min: undefined, max: undefined }),
259
+ undefined,
260
+ ]),
261
+ gasUsed: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
236
262
  })),
237
263
  undefined,
238
264
  ]),
@@ -267,6 +293,19 @@ export const getSendUserOperationResponseMock = (
267
293
  { data: faker.helpers.fromRegExp("^0x[0-9a-fA-F]*$"), message: faker.string.alpha(20) },
268
294
  undefined,
269
295
  ]),
296
+ transactionHash: faker.helpers.arrayElement([
297
+ faker.helpers.fromRegExp("^0x[a-fA-F0-9]{64}$"),
298
+ undefined,
299
+ ]),
300
+ blockHash: faker.helpers.arrayElement([
301
+ faker.helpers.fromRegExp("^0x[0-9a-fA-F]{64}$|^$"),
302
+ undefined,
303
+ ]),
304
+ blockNumber: faker.helpers.arrayElement([
305
+ faker.number.int({ min: undefined, max: undefined }),
306
+ undefined,
307
+ ]),
308
+ gasUsed: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
270
309
  })),
271
310
  undefined,
272
311
  ]),
@@ -301,6 +340,19 @@ export const getCreateSpendPermissionResponseMock = (
301
340
  { data: faker.helpers.fromRegExp("^0x[0-9a-fA-F]*$"), message: faker.string.alpha(20) },
302
341
  undefined,
303
342
  ]),
343
+ transactionHash: faker.helpers.arrayElement([
344
+ faker.helpers.fromRegExp("^0x[a-fA-F0-9]{64}$"),
345
+ undefined,
346
+ ]),
347
+ blockHash: faker.helpers.arrayElement([
348
+ faker.helpers.fromRegExp("^0x[0-9a-fA-F]{64}$|^$"),
349
+ undefined,
350
+ ]),
351
+ blockNumber: faker.helpers.arrayElement([
352
+ faker.number.int({ min: undefined, max: undefined }),
353
+ undefined,
354
+ ]),
355
+ gasUsed: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
304
356
  })),
305
357
  undefined,
306
358
  ]),
@@ -313,30 +365,24 @@ export const getListSpendPermissionsResponseMock = (): ListSpendPermissions200 =
313
365
  { length: faker.number.int({ min: 1, max: 10 }) },
314
366
  (_, i) => i + 1,
315
367
  ).map(() => ({
316
- permission: faker.helpers.arrayElement([
317
- {
318
- account: faker.helpers.fromRegExp("^0x[a-fA-F0-9]{40}$"),
319
- spender: faker.helpers.fromRegExp("^0x[a-fA-F0-9]{40}$"),
320
- token: faker.helpers.fromRegExp("^0x[a-fA-F0-9]{40}$"),
321
- allowance: faker.string.alpha(20),
322
- period: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
323
- start: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
324
- end: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
325
- salt: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
326
- extraData: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
327
- },
328
- undefined,
329
- ]),
330
- permissionHash: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
331
- revoked: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]),
368
+ permission: {
369
+ account: faker.helpers.fromRegExp("^0x[a-fA-F0-9]{40}$"),
370
+ spender: faker.helpers.fromRegExp("^0x[a-fA-F0-9]{40}$"),
371
+ token: faker.helpers.fromRegExp("^0x[a-fA-F0-9]{40}$"),
372
+ allowance: faker.string.alpha(20),
373
+ period: faker.string.alpha(20),
374
+ start: faker.string.alpha(20),
375
+ end: faker.string.alpha(20),
376
+ salt: faker.string.alpha(20),
377
+ extraData: faker.string.alpha(20),
378
+ },
379
+ permissionHash: faker.string.alpha(20),
380
+ revoked: faker.datatype.boolean(),
332
381
  revokedAt: faker.helpers.arrayElement([
333
382
  `${faker.date.past().toISOString().split(".")[0]}Z`,
334
383
  undefined,
335
384
  ]),
336
- createdAt: faker.helpers.arrayElement([
337
- `${faker.date.past().toISOString().split(".")[0]}Z`,
338
- undefined,
339
- ]),
385
+ createdAt: `${faker.date.past().toISOString().split(".")[0]}Z`,
340
386
  })),
341
387
  },
342
388
  ...{ nextPageToken: faker.helpers.arrayElement([faker.string.alpha(20), undefined]) },
@@ -370,6 +416,19 @@ export const getRevokeSpendPermissionResponseMock = (
370
416
  { data: faker.helpers.fromRegExp("^0x[0-9a-fA-F]*$"), message: faker.string.alpha(20) },
371
417
  undefined,
372
418
  ]),
419
+ transactionHash: faker.helpers.arrayElement([
420
+ faker.helpers.fromRegExp("^0x[a-fA-F0-9]{64}$"),
421
+ undefined,
422
+ ]),
423
+ blockHash: faker.helpers.arrayElement([
424
+ faker.helpers.fromRegExp("^0x[0-9a-fA-F]{64}$|^$"),
425
+ undefined,
426
+ ]),
427
+ blockNumber: faker.helpers.arrayElement([
428
+ faker.number.int({ min: undefined, max: undefined }),
429
+ undefined,
430
+ ]),
431
+ gasUsed: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
373
432
  })),
374
433
  undefined,
375
434
  ]),
@@ -17,8 +17,7 @@ type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
17
17
 
18
18
  /**
19
19
  * Lists the token balances of an EVM address on a given network. The balances include ERC-20 tokens and the native gas token (usually ETH). The response is paginated, and by default, returns 20 balances per page.
20
-
21
- **Note:** This endpoint is still under development and does not yet provide strong freshness guarantees. Specifically, balances of new tokens can, on occasion, take up to ~30 seconds to appear, while balances of tokens already belonging to an address will generally be close to chain tip. Freshness of new token balances will improve over the coming weeks.
20
+ **Note:** This endpoint is still under development and does not yet provide strong freshness guarantees. Specifically, balances of new tokens can, on occasion, take up to ~30 seconds to appear, while balances of tokens already belonging to an address will generally be close to chain tip. Freshness of new token balances will improve over the coming weeks.
22
21
  * @summary List EVM token balances
23
22
  */
24
23
  export const listEvmTokenBalances = (
@@ -3,6 +3,7 @@ export * from "./evm-smart-accounts/evm-smart-accounts.msw.js";
3
3
  export * from "./evm-swaps/evm-swaps.msw.js";
4
4
  export * from "./evm-token-balances/evm-token-balances.msw.js";
5
5
  export * from "./faucets/faucets.msw.js";
6
+ export * from "./onchain-data/onchain-data.msw.js";
6
7
  export * from "./onramp/onramp.msw.js";
7
8
  export * from "./payments-alpha/payments-alpha.msw.js";
8
9
  export * from "./policy-engine/policy-engine.msw.js";
@@ -0,0 +1,185 @@
1
+ /**
2
+ * Generated by orval v7.6.0 🍺
3
+ * Do not edit manually.
4
+ * Coinbase Developer Platform APIs
5
+ * The Coinbase Developer Platform APIs - leading the world's transition onchain.
6
+ * OpenAPI spec version: 2.0.0
7
+ */
8
+ import { faker } from "@faker-js/faker";
9
+
10
+ import { HttpResponse, delay, http } from "msw";
11
+
12
+ import { ListEvmTokenBalancesNetwork } from "../coinbaseDeveloperPlatformAPIs.schemas.js";
13
+ import type {
14
+ AccountTokenAddressesResponse,
15
+ ListDataTokenBalances200,
16
+ OnchainDataResult,
17
+ } from "../coinbaseDeveloperPlatformAPIs.schemas.js";
18
+
19
+ export const getRunSQLQueryResponseMock = (
20
+ overrideResponse: Partial<OnchainDataResult> = {},
21
+ ): OnchainDataResult => ({
22
+ result: faker.helpers.arrayElement([
23
+ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})),
24
+ undefined,
25
+ ]),
26
+ schema: faker.helpers.arrayElement([
27
+ {
28
+ columns: faker.helpers.arrayElement([
29
+ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({
30
+ name: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
31
+ type: faker.helpers.arrayElement([
32
+ faker.helpers.arrayElement([
33
+ "String",
34
+ "UInt8",
35
+ "UInt16",
36
+ "UInt32",
37
+ "UInt64",
38
+ "UInt128",
39
+ "UInt256",
40
+ "Int8",
41
+ "Int16",
42
+ "Int32",
43
+ "Int64",
44
+ "Int128",
45
+ "Int256",
46
+ "Float32",
47
+ "Float64",
48
+ "Bool",
49
+ "Date",
50
+ "DateTime",
51
+ "DateTime64",
52
+ "UUID",
53
+ ] as const),
54
+ undefined,
55
+ ]),
56
+ })),
57
+ undefined,
58
+ ]),
59
+ },
60
+ undefined,
61
+ ]),
62
+ metadata: faker.helpers.arrayElement([
63
+ {
64
+ cached: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]),
65
+ executionTimeMs: faker.helpers.arrayElement([
66
+ faker.number.int({ min: undefined, max: undefined }),
67
+ undefined,
68
+ ]),
69
+ rowCount: faker.helpers.arrayElement([
70
+ faker.number.int({ min: undefined, max: undefined }),
71
+ undefined,
72
+ ]),
73
+ },
74
+ undefined,
75
+ ]),
76
+ ...overrideResponse,
77
+ });
78
+
79
+ export const getListTokensForAccountResponseMock = (
80
+ overrideResponse: Partial<AccountTokenAddressesResponse> = {},
81
+ ): AccountTokenAddressesResponse => ({
82
+ accountAddress: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
83
+ tokenAddresses: faker.helpers.arrayElement([
84
+ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
85
+ faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
86
+ ),
87
+ undefined,
88
+ ]),
89
+ totalCount: faker.helpers.arrayElement([faker.number.int({ min: 0, max: undefined }), undefined]),
90
+ ...overrideResponse,
91
+ });
92
+
93
+ export const getListDataTokenBalancesResponseMock = (): ListDataTokenBalances200 => ({
94
+ ...{
95
+ balances: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
96
+ () => ({
97
+ amount: {
98
+ amount: faker.helpers.fromRegExp("^[0-9]+$"),
99
+ decimals: faker.number.int({ min: undefined, max: undefined }),
100
+ },
101
+ token: {
102
+ network: faker.helpers.arrayElement(Object.values(ListEvmTokenBalancesNetwork)),
103
+ symbol: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
104
+ name: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
105
+ contractAddress: faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
106
+ },
107
+ }),
108
+ ),
109
+ },
110
+ ...{ nextPageToken: faker.helpers.arrayElement([faker.string.alpha(20), undefined]) },
111
+ });
112
+
113
+ export const getRunSQLQueryMockHandler = (
114
+ overrideResponse?:
115
+ | OnchainDataResult
116
+ | ((
117
+ info: Parameters<Parameters<typeof http.post>[1]>[0],
118
+ ) => Promise<OnchainDataResult> | OnchainDataResult),
119
+ ) => {
120
+ return http.post("*/v2/data/query/run", async info => {
121
+ await delay(0);
122
+
123
+ return new HttpResponse(
124
+ JSON.stringify(
125
+ overrideResponse !== undefined
126
+ ? typeof overrideResponse === "function"
127
+ ? await overrideResponse(info)
128
+ : overrideResponse
129
+ : getRunSQLQueryResponseMock(),
130
+ ),
131
+ { status: 200, headers: { "Content-Type": "application/json" } },
132
+ );
133
+ });
134
+ };
135
+
136
+ export const getListTokensForAccountMockHandler = (
137
+ overrideResponse?:
138
+ | AccountTokenAddressesResponse
139
+ | ((
140
+ info: Parameters<Parameters<typeof http.get>[1]>[0],
141
+ ) => Promise<AccountTokenAddressesResponse> | AccountTokenAddressesResponse),
142
+ ) => {
143
+ return http.get("*/v2/data/evm/token-ownership/:network/:address", async info => {
144
+ await delay(0);
145
+
146
+ return new HttpResponse(
147
+ JSON.stringify(
148
+ overrideResponse !== undefined
149
+ ? typeof overrideResponse === "function"
150
+ ? await overrideResponse(info)
151
+ : overrideResponse
152
+ : getListTokensForAccountResponseMock(),
153
+ ),
154
+ { status: 200, headers: { "Content-Type": "application/json" } },
155
+ );
156
+ });
157
+ };
158
+
159
+ export const getListDataTokenBalancesMockHandler = (
160
+ overrideResponse?:
161
+ | ListDataTokenBalances200
162
+ | ((
163
+ info: Parameters<Parameters<typeof http.get>[1]>[0],
164
+ ) => Promise<ListDataTokenBalances200> | ListDataTokenBalances200),
165
+ ) => {
166
+ return http.get("*/v2/data/evm/token-balances/:network/:address", async info => {
167
+ await delay(0);
168
+
169
+ return new HttpResponse(
170
+ JSON.stringify(
171
+ overrideResponse !== undefined
172
+ ? typeof overrideResponse === "function"
173
+ ? await overrideResponse(info)
174
+ : overrideResponse
175
+ : getListDataTokenBalancesResponseMock(),
176
+ ),
177
+ { status: 200, headers: { "Content-Type": "application/json" } },
178
+ );
179
+ });
180
+ };
181
+ export const getOnchainDataMock = () => [
182
+ getRunSQLQueryMockHandler(),
183
+ getListTokensForAccountMockHandler(),
184
+ getListDataTokenBalancesMockHandler(),
185
+ ];