@metamask/keyring-api 11.0.0 → 11.1.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 (96) hide show
  1. package/CHANGELOG.md +8 -1
  2. package/dist/KeyringClient.cjs +6 -0
  3. package/dist/KeyringClient.cjs.map +1 -1
  4. package/dist/KeyringClient.d.cts +3 -1
  5. package/dist/KeyringClient.d.cts.map +1 -1
  6. package/dist/KeyringClient.d.mts +3 -1
  7. package/dist/KeyringClient.d.mts.map +1 -1
  8. package/dist/KeyringClient.mjs +7 -1
  9. package/dist/KeyringClient.mjs.map +1 -1
  10. package/dist/api/asset.cjs +83 -0
  11. package/dist/api/asset.cjs.map +1 -0
  12. package/dist/api/asset.d.cts +93 -0
  13. package/dist/api/asset.d.cts.map +1 -0
  14. package/dist/api/asset.d.mts +93 -0
  15. package/dist/api/asset.d.mts.map +1 -0
  16. package/dist/api/asset.mjs +80 -0
  17. package/dist/api/asset.mjs.map +1 -0
  18. package/dist/api/balance.d.cts +1 -1
  19. package/dist/api/balance.d.mts +1 -1
  20. package/dist/api/index.cjs +2 -0
  21. package/dist/api/index.cjs.map +1 -1
  22. package/dist/api/index.d.cts +3 -1
  23. package/dist/api/index.d.cts.map +1 -1
  24. package/dist/api/index.d.mts +3 -1
  25. package/dist/api/index.d.mts.map +1 -1
  26. package/dist/api/index.mjs +2 -0
  27. package/dist/api/index.mjs.map +1 -1
  28. package/dist/api/keyring.cjs.map +1 -1
  29. package/dist/api/keyring.d.cts +14 -0
  30. package/dist/api/keyring.d.cts.map +1 -1
  31. package/dist/api/keyring.d.mts +14 -0
  32. package/dist/api/keyring.d.mts.map +1 -1
  33. package/dist/api/keyring.mjs.map +1 -1
  34. package/dist/api/transaction.cjs +295 -0
  35. package/dist/api/transaction.cjs.map +1 -0
  36. package/dist/api/transaction.d.cts +773 -0
  37. package/dist/api/transaction.d.cts.map +1 -0
  38. package/dist/api/transaction.d.mts +773 -0
  39. package/dist/api/transaction.d.mts.map +1 -0
  40. package/dist/api/transaction.mjs +292 -0
  41. package/dist/api/transaction.mjs.map +1 -0
  42. package/dist/eth/erc4337/types.d.cts +1 -1
  43. package/dist/eth/erc4337/types.d.mts +1 -1
  44. package/dist/internal/api.cjs +12 -1
  45. package/dist/internal/api.cjs.map +1 -1
  46. package/dist/internal/api.d.cts +318 -1
  47. package/dist/internal/api.d.cts.map +1 -1
  48. package/dist/internal/api.d.mts +318 -1
  49. package/dist/internal/api.d.mts.map +1 -1
  50. package/dist/internal/api.mjs +13 -2
  51. package/dist/internal/api.mjs.map +1 -1
  52. package/dist/internal/rpc.cjs +1 -0
  53. package/dist/internal/rpc.cjs.map +1 -1
  54. package/dist/internal/rpc.d.cts +1 -0
  55. package/dist/internal/rpc.d.cts.map +1 -1
  56. package/dist/internal/rpc.d.mts +1 -0
  57. package/dist/internal/rpc.d.mts.map +1 -1
  58. package/dist/internal/rpc.mjs +1 -0
  59. package/dist/internal/rpc.mjs.map +1 -1
  60. package/dist/rpc-handler.cjs +7 -0
  61. package/dist/rpc-handler.cjs.map +1 -1
  62. package/dist/rpc-handler.d.cts.map +1 -1
  63. package/dist/rpc-handler.d.mts.map +1 -1
  64. package/dist/rpc-handler.mjs +8 -1
  65. package/dist/rpc-handler.mjs.map +1 -1
  66. package/dist/superstruct.cjs +29 -0
  67. package/dist/superstruct.cjs.map +1 -1
  68. package/dist/superstruct.d.cts +19 -1
  69. package/dist/superstruct.d.cts.map +1 -1
  70. package/dist/superstruct.d.mts +19 -1
  71. package/dist/superstruct.d.mts.map +1 -1
  72. package/dist/superstruct.mjs +28 -0
  73. package/dist/superstruct.mjs.map +1 -1
  74. package/dist/utils/index.cjs +1 -0
  75. package/dist/utils/index.cjs.map +1 -1
  76. package/dist/utils/index.d.cts +1 -0
  77. package/dist/utils/index.d.cts.map +1 -1
  78. package/dist/utils/index.d.mts +1 -0
  79. package/dist/utils/index.d.mts.map +1 -1
  80. package/dist/utils/index.mjs +1 -0
  81. package/dist/utils/index.mjs.map +1 -1
  82. package/dist/utils/pagination.cjs +28 -0
  83. package/dist/utils/pagination.cjs.map +1 -0
  84. package/dist/utils/pagination.d.cts +59 -0
  85. package/dist/utils/pagination.d.cts.map +1 -0
  86. package/dist/utils/pagination.d.mts +59 -0
  87. package/dist/utils/pagination.d.mts.map +1 -0
  88. package/dist/utils/pagination.mjs +25 -0
  89. package/dist/utils/pagination.mjs.map +1 -0
  90. package/dist/utils/types.cjs.map +1 -1
  91. package/dist/utils/types.d.cts +24 -0
  92. package/dist/utils/types.d.cts.map +1 -1
  93. package/dist/utils/types.d.mts +24 -0
  94. package/dist/utils/types.d.mts.map +1 -1
  95. package/dist/utils/types.mjs.map +1 -1
  96. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [11.1.0]
11
+
12
+ ### Added
13
+
14
+ - Add `listAccountTransactions` keyring method ([#41](https://github.com/MetaMask/accounts/pull/41))
15
+
10
16
  ## [11.0.0]
11
17
 
12
18
  ### Added
@@ -438,7 +444,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
438
444
  - SnapController keyring client. It is intended to be used by MetaMask to talk to the snap.
439
445
  - Helper functions to create keyring handler in the snap.
440
446
 
441
- [Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@11.0.0...HEAD
447
+ [Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@11.1.0...HEAD
448
+ [11.1.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@11.0.0...@metamask/keyring-api@11.1.0
442
449
  [11.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@10.1.0...@metamask/keyring-api@11.0.0
443
450
  [10.1.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@10.0.0...@metamask/keyring-api@10.1.0
444
451
  [10.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@9.0.0...@metamask/keyring-api@10.0.0
@@ -52,6 +52,12 @@ class KeyringClient {
52
52
  params: { options },
53
53
  }), api_1.CreateAccountResponseStruct);
54
54
  }
55
+ async listAccountTransactions(id, pagination) {
56
+ return (0, superstruct_2.strictMask)(await __classPrivateFieldGet(this, _KeyringClient_instances, "m", _KeyringClient_send).call(this, {
57
+ method: rpc_1.KeyringRpcMethod.ListAccountTransactions,
58
+ params: { id, pagination },
59
+ }), api_1.ListAccountTransactionsResponseStruct);
60
+ }
55
61
  async filterAccountChains(id, chains) {
56
62
  return (0, superstruct_2.strictMask)(await __classPrivateFieldGet(this, _KeyringClient_instances, "m", _KeyringClient_send).call(this, {
57
63
  method: rpc_1.KeyringRpcMethod.FilterAccountChains,
@@ -1 +1 @@
1
- {"version":3,"file":"KeyringClient.cjs","sourceRoot":"","sources":["../src/KeyringClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uDAA+C;AAE/C,+BAAkC;AAWlC,4CAcwB;AACxB,4CAAkD;AAElD,mDAA2C;AAM3C,MAAa,aAAa;IAGxB;;;;OAIG;IACH,YAAY,MAAc;;QAPjB,wCAAgB;QAQvB,uBAAA,IAAI,yBAAW,MAAM,MAAA,CAAC;IACxB,CAAC;IAgBD,KAAK,CAAC,YAAY;QAChB,OAAO,IAAA,wBAAU,EACf,MAAM,uBAAA,IAAI,qDAAM,MAAV,IAAI,EAAO;YACf,MAAM,EAAE,sBAAgB,CAAC,YAAY;SACtC,CAAC,EACF,gCAA0B,CAC3B,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,EAAU;QACzB,OAAO,IAAA,wBAAU,EACf,MAAM,uBAAA,IAAI,qDAAM,MAAV,IAAI,EAAO;YACf,MAAM,EAAE,sBAAgB,CAAC,UAAU;YACnC,MAAM,EAAE,EAAE,EAAE,EAAE;SACf,CAAC,EACF,8BAAwB,CACzB,CAAC;IACJ,CAAC;IAED,KAAK,C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AAE,sBAAgB,CAAC,aAAa;YACtC,MAAM,EAAE,EAAE,EAAE,EAAE;SACf,CAAC,EACF,iCAA2B,CAC5B,CAAC;IACJ,CAAC;CACF;AAjKD,sCAiKC;;AArJC;;;;;GAKG;AACH,KAAK,8BAAO,OAA+C;IACzD,OAAO,uBAAA,IAAI,6BAAQ,CAAC,IAAI,CAAC;QACvB,OAAO,EAAE,KAAK;QACd,EAAE,EAAE,IAAA,SAAI,GAAE;QACV,GAAG,OAAO;KACX,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { assert } from '@metamask/superstruct';\nimport type { Json } from '@metamask/utils';\nimport { v4 as uuid } from 'uuid';\n\nimport type {\n Keyring,\n KeyringAccount,\n KeyringRequest,\n KeyringAccountData,\n KeyringResponse,\n CaipAssetType,\n Balance,\n} from './api';\nimport {\n ApproveRequestResponseStruct,\n CreateAccountResponseStruct,\n DeleteAccountResponseStruct,\n ExportAccountResponseStruct,\n FilterAccountChainsResponseStruct,\n GetAccountBalancesResponseStruct,\n GetAccountResponseStruct,\n GetRequestResponseStruct,\n ListAccountsResponseStruct,\n ListRequestsResponseStruct,\n RejectRequestResponseStruct,\n SubmitRequestResponseStruct,\n UpdateAccountResponseStruct,\n} from './internal/api';\nimport { KeyringRpcMethod } from './internal/rpc';\nimport type { JsonRpcRequest } from './JsonRpcRequest';\nimport { strictMask } from './superstruct';\n\nexport type Sender = {\n send(request: JsonRpcRequest): Promise<Json>;\n};\n\nexport class KeyringClient implements Keyring {\n readonly #sender: Sender;\n\n /**\n * Create a new instance of `KeyringClient`.\n *\n * @param sender - The `Sender` instance to use to send requests to the snap.\n */\n constructor(sender: Sender) {\n this.#sender = sender;\n }\n\n /**\n * Send a request to the snap and return the response.\n *\n * @param partial - A partial JSON-RPC request (method and params).\n * @returns A promise that resolves to the response to the request.\n */\n async #send(partial: Omit<JsonRpcRequest, 'jsonrpc' | 'id'>): Promise<Json> {\n return this.#sender.send({\n jsonrpc: '2.0',\n id: uuid(),\n ...partial,\n });\n }\n\n async listAccounts(): Promise<KeyringAccount[]> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.ListAccounts,\n }),\n ListAccountsResponseStruct,\n );\n }\n\n async getAccount(id: string): Promise<KeyringAccount> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.GetAccount,\n params: { id },\n }),\n GetAccountResponseStruct,\n );\n }\n\n async getAccountBalances(\n id: string,\n assets: CaipAssetType[],\n ): Promise<Record<CaipAssetType, Balance>> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.GetAccountBalances,\n params: { id, assets },\n }),\n GetAccountBalancesResponseStruct,\n );\n }\n\n async createAccount(\n options: Record<string, Json> = {},\n ): Promise<KeyringAccount> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.CreateAccount,\n params: { options },\n }),\n CreateAccountResponseStruct,\n );\n }\n\n async filterAccountChains(id: string, chains: string[]): Promise<string[]> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.FilterAccountChains,\n params: { id, chains },\n }),\n FilterAccountChainsResponseStruct,\n );\n }\n\n async updateAccount(account: KeyringAccount): Promise<void> {\n assert(\n await this.#send({\n method: KeyringRpcMethod.UpdateAccount,\n params: { account },\n }),\n UpdateAccountResponseStruct,\n );\n }\n\n async deleteAccount(id: string): Promise<void> {\n assert(\n await this.#send({\n method: KeyringRpcMethod.DeleteAccount,\n params: { id },\n }),\n DeleteAccountResponseStruct,\n );\n }\n\n async exportAccount(id: string): Promise<KeyringAccountData> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.ExportAccount,\n params: { id },\n }),\n ExportAccountResponseStruct,\n );\n }\n\n async listRequests(): Promise<KeyringRequest[]> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.ListRequests,\n }),\n ListRequestsResponseStruct,\n );\n }\n\n async getRequest(id: string): Promise<KeyringRequest> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.GetRequest,\n params: { id },\n }),\n GetRequestResponseStruct,\n );\n }\n\n async submitRequest(request: KeyringRequest): Promise<KeyringResponse> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.SubmitRequest,\n params: request,\n }),\n SubmitRequestResponseStruct,\n );\n }\n\n async approveRequest(\n id: string,\n data: Record<string, Json> = {},\n ): Promise<void> {\n assert(\n await this.#send({\n method: KeyringRpcMethod.ApproveRequest,\n params: { id, data },\n }),\n ApproveRequestResponseStruct,\n );\n }\n\n async rejectRequest(id: string): Promise<void> {\n assert(\n await this.#send({\n method: KeyringRpcMethod.RejectRequest,\n params: { id },\n }),\n RejectRequestResponseStruct,\n );\n }\n}\n"]}
1
+ {"version":3,"file":"KeyringClient.cjs","sourceRoot":"","sources":["../src/KeyringClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uDAA+C;AAE/C,+BAAkC;AAYlC,4CAewB;AACxB,4CAAkD;AAElD,mDAA2C;AAO3C,MAAa,aAAa;IAGxB;;;;OAIG;IACH,YAAY,MAAc;;QAPjB,wCAAgB;QAQvB,uBAAA,IAAI,yBAAW,MAAM,MAAA,CAAC;IACxB,CAAC;IAgBD,KAAK,CAAC,YAAY;QAChB,OAAO,IAAA,wBAAU,EACf,MAAM,uBAAA,IAAI,qDAAM,MAAV,IAAI,EAAO;YACf,MAAM,EAAE,sBAAgB,CAAC,YAAY;SACtC,CAAC,EACF,gCAA0B,CAC3B,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,EAAU;QACzB,OAAO,IAAA,wBAAU,EACf,MAAM,uBAAA,IAAI,qDAAM,MAAV,IAAI,EAAO;YACf,MAAM,EAAE,sBAAgB,CAAC,UAAU;YACnC,MAAM,EAAE,EAAE,EAAE,EAAE;SACf,CAAC,EACF,8BAAwB,CACzB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,kBAAkB,CACtB,EAAU,EACV,MAAuB;QAEvB,OAAO,IAAA,wBAAU,EACf,MAAM,uBAAA,IAAI,qDAAM,MAAV,IAAI,EAAO;YACf,MAAM,EAAE,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AAC;IACJ,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,EAAU;QAC5B,IAAA,oBAAM,EACJ,MAAM,uBAAA,IAAI,qDAAM,MAAV,IAAI,EAAO;YACf,MAAM,EAAE,sBAAgB,CAAC,aAAa;YACtC,MAAM,EAAE,EAAE,EAAE,EAAE;SACf,CAAC,EACF,iCAA2B,CAC5B,CAAC;IACJ,CAAC;CACF;AA9KD,sCA8KC;;AAlKC;;;;;GAKG;AACH,KAAK,8BAAO,OAA+C;IACzD,OAAO,uBAAA,IAAI,6BAAQ,CAAC,IAAI,CAAC;QACvB,OAAO,EAAE,KAAK;QACd,EAAE,EAAE,IAAA,SAAI,GAAE;QACV,GAAG,OAAO;KACX,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { assert } from '@metamask/superstruct';\nimport type { Json } from '@metamask/utils';\nimport { v4 as uuid } from 'uuid';\n\nimport type {\n Keyring,\n KeyringAccount,\n KeyringRequest,\n KeyringAccountData,\n KeyringResponse,\n CaipAssetType,\n Balance,\n TransactionsPage,\n} from './api';\nimport {\n ApproveRequestResponseStruct,\n CreateAccountResponseStruct,\n DeleteAccountResponseStruct,\n ExportAccountResponseStruct,\n FilterAccountChainsResponseStruct,\n GetAccountBalancesResponseStruct,\n GetAccountResponseStruct,\n GetRequestResponseStruct,\n ListAccountsResponseStruct,\n ListAccountTransactionsResponseStruct,\n ListRequestsResponseStruct,\n RejectRequestResponseStruct,\n SubmitRequestResponseStruct,\n UpdateAccountResponseStruct,\n} from './internal/api';\nimport { KeyringRpcMethod } from './internal/rpc';\nimport type { JsonRpcRequest } from './JsonRpcRequest';\nimport { strictMask } from './superstruct';\nimport type { Pagination } from './utils';\n\nexport type Sender = {\n send(request: JsonRpcRequest): Promise<Json>;\n};\n\nexport class KeyringClient implements Keyring {\n readonly #sender: Sender;\n\n /**\n * Create a new instance of `KeyringClient`.\n *\n * @param sender - The `Sender` instance to use to send requests to the snap.\n */\n constructor(sender: Sender) {\n this.#sender = sender;\n }\n\n /**\n * Send a request to the snap and return the response.\n *\n * @param partial - A partial JSON-RPC request (method and params).\n * @returns A promise that resolves to the response to the request.\n */\n async #send(partial: Omit<JsonRpcRequest, 'jsonrpc' | 'id'>): Promise<Json> {\n return this.#sender.send({\n jsonrpc: '2.0',\n id: uuid(),\n ...partial,\n });\n }\n\n async listAccounts(): Promise<KeyringAccount[]> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.ListAccounts,\n }),\n ListAccountsResponseStruct,\n );\n }\n\n async getAccount(id: string): Promise<KeyringAccount> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.GetAccount,\n params: { id },\n }),\n GetAccountResponseStruct,\n );\n }\n\n async getAccountBalances(\n id: string,\n assets: CaipAssetType[],\n ): Promise<Record<CaipAssetType, Balance>> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.GetAccountBalances,\n params: { id, assets },\n }),\n GetAccountBalancesResponseStruct,\n );\n }\n\n async createAccount(\n options: Record<string, Json> = {},\n ): Promise<KeyringAccount> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.CreateAccount,\n params: { options },\n }),\n CreateAccountResponseStruct,\n );\n }\n\n async listAccountTransactions(\n id: string,\n pagination: Pagination,\n ): Promise<TransactionsPage> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.ListAccountTransactions,\n params: { id, pagination },\n }),\n ListAccountTransactionsResponseStruct,\n );\n }\n\n async filterAccountChains(id: string, chains: string[]): Promise<string[]> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.FilterAccountChains,\n params: { id, chains },\n }),\n FilterAccountChainsResponseStruct,\n );\n }\n\n async updateAccount(account: KeyringAccount): Promise<void> {\n assert(\n await this.#send({\n method: KeyringRpcMethod.UpdateAccount,\n params: { account },\n }),\n UpdateAccountResponseStruct,\n );\n }\n\n async deleteAccount(id: string): Promise<void> {\n assert(\n await this.#send({\n method: KeyringRpcMethod.DeleteAccount,\n params: { id },\n }),\n DeleteAccountResponseStruct,\n );\n }\n\n async exportAccount(id: string): Promise<KeyringAccountData> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.ExportAccount,\n params: { id },\n }),\n ExportAccountResponseStruct,\n );\n }\n\n async listRequests(): Promise<KeyringRequest[]> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.ListRequests,\n }),\n ListRequestsResponseStruct,\n );\n }\n\n async getRequest(id: string): Promise<KeyringRequest> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.GetRequest,\n params: { id },\n }),\n GetRequestResponseStruct,\n );\n }\n\n async submitRequest(request: KeyringRequest): Promise<KeyringResponse> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.SubmitRequest,\n params: request,\n }),\n SubmitRequestResponseStruct,\n );\n }\n\n async approveRequest(\n id: string,\n data: Record<string, Json> = {},\n ): Promise<void> {\n assert(\n await this.#send({\n method: KeyringRpcMethod.ApproveRequest,\n params: { id, data },\n }),\n ApproveRequestResponseStruct,\n );\n }\n\n async rejectRequest(id: string): Promise<void> {\n assert(\n await this.#send({\n method: KeyringRpcMethod.RejectRequest,\n params: { id },\n }),\n RejectRequestResponseStruct,\n );\n }\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import type { Json } from "@metamask/utils";
2
- import type { Keyring, KeyringAccount, KeyringRequest, KeyringAccountData, KeyringResponse, CaipAssetType, Balance } from "./api/index.cjs";
2
+ import type { Keyring, KeyringAccount, KeyringRequest, KeyringAccountData, KeyringResponse, CaipAssetType, Balance, TransactionsPage } from "./api/index.cjs";
3
3
  import type { JsonRpcRequest } from "./JsonRpcRequest.cjs";
4
+ import type { Pagination } from "./utils/index.cjs";
4
5
  export type Sender = {
5
6
  send(request: JsonRpcRequest): Promise<Json>;
6
7
  };
@@ -16,6 +17,7 @@ export declare class KeyringClient implements Keyring {
16
17
  getAccount(id: string): Promise<KeyringAccount>;
17
18
  getAccountBalances(id: string, assets: CaipAssetType[]): Promise<Record<CaipAssetType, Balance>>;
18
19
  createAccount(options?: Record<string, Json>): Promise<KeyringAccount>;
20
+ listAccountTransactions(id: string, pagination: Pagination): Promise<TransactionsPage>;
19
21
  filterAccountChains(id: string, chains: string[]): Promise<string[]>;
20
22
  updateAccount(account: KeyringAccount): Promise<void>;
21
23
  deleteAccount(id: string): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"KeyringClient.d.cts","sourceRoot":"","sources":["../src/KeyringClient.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAG5C,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,OAAO,EACR,wBAAc;AAiBf,OAAO,KAAK,EAAE,cAAc,EAAE,6BAAyB;AAGvD,MAAM,MAAM,MAAM,GAAG;IACnB,IAAI,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9C,CAAC;AAEF,qBAAa,aAAc,YAAW,OAAO;;IAG3C;;;;OAIG;gBACS,MAAM,EAAE,MAAM;IAkBpB,YAAY,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IASzC,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAU/C,kBAAkB,CACtB,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,aAAa,EAAE,GACtB,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAUpC,aAAa,CACjB,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAM,GACjC,OAAO,CAAC,cAAc,CAAC;IAUpB,mBAAmB,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAUpE,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAUrD,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI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UpC,aAAa,CACjB,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAM,GACjC,OAAO,CAAC,cAAc,CAAC;IAUpB,uBAAuB,CAC3B,EAAE,EAAE,MAAM,EACV,UAAU,EAAE,UAAU,GACrB,OAAO,CAAC,gBAAgB,CAAC;IAUtB,mBAAmB,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAUpE,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAUrD,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAUxC,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAUtD,YAAY,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IASzC,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAU/C,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;IAUhE,cAAc,CAClB,EAAE,EAAE,MAAM,EACV,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAM,GAC9B,OAAO,CAAC,IAAI,CAAC;IAUV,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAS/C"}
@@ -1,6 +1,7 @@
1
1
  import type { Json } from "@metamask/utils";
2
- import type { Keyring, KeyringAccount, KeyringRequest, KeyringAccountData, KeyringResponse, CaipAssetType, Balance } from "./api/index.mjs";
2
+ import type { Keyring, KeyringAccount, KeyringRequest, KeyringAccountData, KeyringResponse, CaipAssetType, Balance, TransactionsPage } from "./api/index.mjs";
3
3
  import type { JsonRpcRequest } from "./JsonRpcRequest.mjs";
4
+ import type { Pagination } from "./utils/index.mjs";
4
5
  export type Sender = {
5
6
  send(request: JsonRpcRequest): Promise<Json>;
6
7
  };
@@ -16,6 +17,7 @@ export declare class KeyringClient implements Keyring {
16
17
  getAccount(id: string): Promise<KeyringAccount>;
17
18
  getAccountBalances(id: string, assets: CaipAssetType[]): Promise<Record<CaipAssetType, Balance>>;
18
19
  createAccount(options?: Record<string, Json>): Promise<KeyringAccount>;
20
+ listAccountTransactions(id: string, pagination: Pagination): Promise<TransactionsPage>;
19
21
  filterAccountChains(id: string, chains: string[]): Promise<string[]>;
20
22
  updateAccount(account: KeyringAccount): Promise<void>;
21
23
  deleteAccount(id: string): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"KeyringClient.d.mts","sourceRoot":"","sources":["../src/KeyringClient.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAG5C,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,OAAO,EACR,wBAAc;AAiBf,OAAO,KAAK,EAAE,cAAc,EAAE,6BAAyB;AAGvD,MAAM,MAAM,MAAM,GAAG;IACnB,IAAI,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9C,CAAC;AAEF,qBAAa,aAAc,YAAW,OAAO;;IAG3C;;;;OAIG;gBACS,MAAM,EAAE,MAAM;IAkBpB,YAAY,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IASzC,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAU/C,kBAAkB,CACtB,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,aAAa,EAAE,GACtB,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAUpC,aAAa,CACjB,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAM,GACjC,OAAO,CAAC,cAAc,CAAC;IAUpB,mBAAmB,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG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AG,OAAO,CAAC,cAAc,CAAC;IAU/C,kBAAkB,CACtB,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,aAAa,EAAE,GACtB,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAUpC,aAAa,CACjB,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAM,GACjC,OAAO,CAAC,cAAc,CAAC;IAUpB,uBAAuB,CAC3B,EAAE,EAAE,MAAM,EACV,UAAU,EAAE,UAAU,GACrB,OAAO,CAAC,gBAAgB,CAAC;IAUtB,mBAAmB,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAUpE,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAUrD,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAUxC,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAUtD,YAAY,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IASzC,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAU/C,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;IAUhE,cAAc,CAClB,EAAE,EAAE,MAAM,EACV,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAM,GAC9B,OAAO,CAAC,IAAI,CAAC;IAUV,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAS/C"}
@@ -12,7 +12,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
12
12
  var _KeyringClient_instances, _KeyringClient_sender, _KeyringClient_send;
13
13
  import { assert } from "@metamask/superstruct";
14
14
  import { v4 as uuid } from "uuid";
15
- import { ApproveRequestResponseStruct, CreateAccountResponseStruct, DeleteAccountResponseStruct, ExportAccountResponseStruct, FilterAccountChainsResponseStruct, GetAccountBalancesResponseStruct, GetAccountResponseStruct, GetRequestResponseStruct, ListAccountsResponseStruct, ListRequestsResponseStruct, RejectRequestResponseStruct, SubmitRequestResponseStruct, UpdateAccountResponseStruct } from "./internal/api.mjs";
15
+ import { ApproveRequestResponseStruct, CreateAccountResponseStruct, DeleteAccountResponseStruct, ExportAccountResponseStruct, FilterAccountChainsResponseStruct, GetAccountBalancesResponseStruct, GetAccountResponseStruct, GetRequestResponseStruct, ListAccountsResponseStruct, ListAccountTransactionsResponseStruct, ListRequestsResponseStruct, RejectRequestResponseStruct, SubmitRequestResponseStruct, UpdateAccountResponseStruct } from "./internal/api.mjs";
16
16
  import { KeyringRpcMethod } from "./internal/rpc.mjs";
17
17
  import { strictMask } from "./superstruct.mjs";
18
18
  export class KeyringClient {
@@ -49,6 +49,12 @@ export class KeyringClient {
49
49
  params: { options },
50
50
  }), CreateAccountResponseStruct);
51
51
  }
52
+ async listAccountTransactions(id, pagination) {
53
+ return strictMask(await __classPrivateFieldGet(this, _KeyringClient_instances, "m", _KeyringClient_send).call(this, {
54
+ method: KeyringRpcMethod.ListAccountTransactions,
55
+ params: { id, pagination },
56
+ }), ListAccountTransactionsResponseStruct);
57
+ }
52
58
  async filterAccountChains(id, chains) {
53
59
  return strictMask(await __classPrivateFieldGet(this, _KeyringClient_instances, "m", _KeyringClient_send).call(this, {
54
60
  method: KeyringRpcMethod.FilterAccountChains,
@@ -1 +1 @@
1
- {"version":3,"file":"KeyringClient.mjs","sourceRoot":"","sources":["../src/KeyringClient.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,8BAA8B;AAE/C,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,aAAa;AAWlC,OAAO,EACL,4BAA4B,EAC5B,2BAA2B,EAC3B,2BAA2B,EAC3B,2BAA2B,EAC3B,iCAAiC,EACjC,gCAAgC,EAChC,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U;YACnC,MAAM,EAAE,EAAE,EAAE,EAAE;SACf,CAAC,EACF,wBAAwB,CACzB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,OAAuB;QACzC,OAAO,UAAU,CACf,MAAM,uBAAA,IAAI,qDAAM,MAAV,IAAI,EAAO;YACf,MAAM,EAAE,gBAAgB,CAAC,aAAa;YACtC,MAAM,EAAE,OAAO;SAChB,CAAC,EACF,2BAA2B,CAC5B,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,EAAU,EACV,OAA6B,EAAE;QAE/B,MAAM,CACJ,MAAM,uBAAA,IAAI,qDAAM,MAAV,IAAI,EAAO;YACf,MAAM,EAAE,gBAAgB,CAAC,cAAc;YACvC,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE;SACrB,CAAC,EACF,4BAA4B,CAC7B,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,EAAU;QAC5B,MAAM,CACJ,MAAM,uBAAA,IAAI,qDAAM,MAAV,IAAI,EAAO;YACf,MAAM,EAAE,gBAAgB,CAAC,aAAa;YACtC,MAAM,EAAE,EAAE,EAAE,EAAE;SACf,CAAC,EACF,2BAA2B,CAC5B,CAAC;IACJ,CAAC;CACF;;AArJC;;;;;GAKG;AACH,KAAK,8BAAO,OAA+C;IACzD,OAAO,uBAAA,IAAI,6BAAQ,CAAC,IAAI,CAAC;QACvB,OAAO,EAAE,KAAK;QACd,EAAE,EAAE,IAAI,EAAE;QACV,GAAG,OAAO;KACX,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { assert } from '@metamask/superstruct';\nimport type { Json } from '@metamask/utils';\nimport { v4 as uuid } from 'uuid';\n\nimport type {\n Keyring,\n KeyringAccount,\n KeyringRequest,\n KeyringAccountData,\n KeyringResponse,\n CaipAssetType,\n Balance,\n} from './api';\nimport {\n ApproveRequestResponseStruct,\n CreateAccountResponseStruct,\n DeleteAccountResponseStruct,\n ExportAccountResponseStruct,\n FilterAccountChainsResponseStruct,\n GetAccountBalancesResponseStruct,\n GetAccountResponseStruct,\n GetRequestResponseStruct,\n ListAccountsResponseStruct,\n ListRequestsResponseStruct,\n RejectRequestResponseStruct,\n SubmitRequestResponseStruct,\n UpdateAccountResponseStruct,\n} from './internal/api';\nimport { KeyringRpcMethod } from './internal/rpc';\nimport type { JsonRpcRequest } from './JsonRpcRequest';\nimport { strictMask } from './superstruct';\n\nexport type Sender = {\n send(request: JsonRpcRequest): Promise<Json>;\n};\n\nexport class KeyringClient implements Keyring {\n readonly #sender: Sender;\n\n /**\n * Create a new instance of `KeyringClient`.\n *\n * @param sender - The `Sender` instance to use to send requests to the snap.\n */\n constructor(sender: Sender) {\n this.#sender = sender;\n }\n\n /**\n * Send a request to the snap and return the response.\n *\n * @param partial - A partial JSON-RPC request (method and params).\n * @returns A promise that resolves to the response to the request.\n */\n async #send(partial: Omit<JsonRpcRequest, 'jsonrpc' | 'id'>): Promise<Json> {\n return this.#sender.send({\n jsonrpc: '2.0',\n id: uuid(),\n ...partial,\n });\n }\n\n async listAccounts(): Promise<KeyringAccount[]> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.ListAccounts,\n }),\n ListAccountsResponseStruct,\n );\n }\n\n async getAccount(id: string): Promise<KeyringAccount> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.GetAccount,\n params: { id },\n }),\n GetAccountResponseStruct,\n );\n }\n\n async getAccountBalances(\n id: string,\n assets: CaipAssetType[],\n ): Promise<Record<CaipAssetType, Balance>> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.GetAccountBalances,\n params: { id, assets },\n }),\n GetAccountBalancesResponseStruct,\n );\n }\n\n async createAccount(\n options: Record<string, Json> = {},\n ): Promise<KeyringAccount> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.CreateAccount,\n params: { options },\n }),\n CreateAccountResponseStruct,\n );\n }\n\n async filterAccountChains(id: string, chains: string[]): Promise<string[]> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.FilterAccountChains,\n params: { id, chains },\n }),\n FilterAccountChainsResponseStruct,\n );\n }\n\n async updateAccount(account: KeyringAccount): Promise<void> {\n assert(\n await this.#send({\n method: KeyringRpcMethod.UpdateAccount,\n params: { account },\n }),\n UpdateAccountResponseStruct,\n );\n }\n\n async deleteAccount(id: string): Promise<void> {\n assert(\n await this.#send({\n method: KeyringRpcMethod.DeleteAccount,\n params: { id },\n }),\n DeleteAccountResponseStruct,\n );\n }\n\n async exportAccount(id: string): Promise<KeyringAccountData> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.ExportAccount,\n params: { id },\n }),\n ExportAccountResponseStruct,\n );\n }\n\n async listRequests(): Promise<KeyringRequest[]> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.ListRequests,\n }),\n ListRequestsResponseStruct,\n );\n }\n\n async getRequest(id: string): Promise<KeyringRequest> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.GetRequest,\n params: { id },\n }),\n GetRequestResponseStruct,\n );\n }\n\n async submitRequest(request: KeyringRequest): Promise<KeyringResponse> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.SubmitRequest,\n params: request,\n }),\n SubmitRequestResponseStruct,\n );\n }\n\n async approveRequest(\n id: string,\n data: Record<string, Json> = {},\n ): Promise<void> {\n assert(\n await this.#send({\n method: KeyringRpcMethod.ApproveRequest,\n params: { id, data },\n }),\n ApproveRequestResponseStruct,\n );\n }\n\n async rejectRequest(id: string): Promise<void> {\n assert(\n await this.#send({\n method: KeyringRpcMethod.RejectRequest,\n params: { id },\n }),\n RejectRequestResponseStruct,\n );\n }\n}\n"]}
1
+ {"version":3,"file":"KeyringClient.mjs","sourceRoot":"","sources":["../src/KeyringClient.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,8BAA8B;AAE/C,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,aAAa;AAYlC,OAAO,EACL,4BAA4B,EAC5B,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AAO,EAAE,KAAK;QACd,EAAE,EAAE,IAAI,EAAE;QACV,GAAG,OAAO;KACX,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { assert } from '@metamask/superstruct';\nimport type { Json } from '@metamask/utils';\nimport { v4 as uuid } from 'uuid';\n\nimport type {\n Keyring,\n KeyringAccount,\n KeyringRequest,\n KeyringAccountData,\n KeyringResponse,\n CaipAssetType,\n Balance,\n TransactionsPage,\n} from './api';\nimport {\n ApproveRequestResponseStruct,\n CreateAccountResponseStruct,\n DeleteAccountResponseStruct,\n ExportAccountResponseStruct,\n FilterAccountChainsResponseStruct,\n GetAccountBalancesResponseStruct,\n GetAccountResponseStruct,\n GetRequestResponseStruct,\n ListAccountsResponseStruct,\n ListAccountTransactionsResponseStruct,\n ListRequestsResponseStruct,\n RejectRequestResponseStruct,\n SubmitRequestResponseStruct,\n UpdateAccountResponseStruct,\n} from './internal/api';\nimport { KeyringRpcMethod } from './internal/rpc';\nimport type { JsonRpcRequest } from './JsonRpcRequest';\nimport { strictMask } from './superstruct';\nimport type { Pagination } from './utils';\n\nexport type Sender = {\n send(request: JsonRpcRequest): Promise<Json>;\n};\n\nexport class KeyringClient implements Keyring {\n readonly #sender: Sender;\n\n /**\n * Create a new instance of `KeyringClient`.\n *\n * @param sender - The `Sender` instance to use to send requests to the snap.\n */\n constructor(sender: Sender) {\n this.#sender = sender;\n }\n\n /**\n * Send a request to the snap and return the response.\n *\n * @param partial - A partial JSON-RPC request (method and params).\n * @returns A promise that resolves to the response to the request.\n */\n async #send(partial: Omit<JsonRpcRequest, 'jsonrpc' | 'id'>): Promise<Json> {\n return this.#sender.send({\n jsonrpc: '2.0',\n id: uuid(),\n ...partial,\n });\n }\n\n async listAccounts(): Promise<KeyringAccount[]> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.ListAccounts,\n }),\n ListAccountsResponseStruct,\n );\n }\n\n async getAccount(id: string): Promise<KeyringAccount> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.GetAccount,\n params: { id },\n }),\n GetAccountResponseStruct,\n );\n }\n\n async getAccountBalances(\n id: string,\n assets: CaipAssetType[],\n ): Promise<Record<CaipAssetType, Balance>> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.GetAccountBalances,\n params: { id, assets },\n }),\n GetAccountBalancesResponseStruct,\n );\n }\n\n async createAccount(\n options: Record<string, Json> = {},\n ): Promise<KeyringAccount> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.CreateAccount,\n params: { options },\n }),\n CreateAccountResponseStruct,\n );\n }\n\n async listAccountTransactions(\n id: string,\n pagination: Pagination,\n ): Promise<TransactionsPage> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.ListAccountTransactions,\n params: { id, pagination },\n }),\n ListAccountTransactionsResponseStruct,\n );\n }\n\n async filterAccountChains(id: string, chains: string[]): Promise<string[]> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.FilterAccountChains,\n params: { id, chains },\n }),\n FilterAccountChainsResponseStruct,\n );\n }\n\n async updateAccount(account: KeyringAccount): Promise<void> {\n assert(\n await this.#send({\n method: KeyringRpcMethod.UpdateAccount,\n params: { account },\n }),\n UpdateAccountResponseStruct,\n );\n }\n\n async deleteAccount(id: string): Promise<void> {\n assert(\n await this.#send({\n method: KeyringRpcMethod.DeleteAccount,\n params: { id },\n }),\n DeleteAccountResponseStruct,\n );\n }\n\n async exportAccount(id: string): Promise<KeyringAccountData> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.ExportAccount,\n params: { id },\n }),\n ExportAccountResponseStruct,\n );\n }\n\n async listRequests(): Promise<KeyringRequest[]> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.ListRequests,\n }),\n ListRequestsResponseStruct,\n );\n }\n\n async getRequest(id: string): Promise<KeyringRequest> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.GetRequest,\n params: { id },\n }),\n GetRequestResponseStruct,\n );\n }\n\n async submitRequest(request: KeyringRequest): Promise<KeyringResponse> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.SubmitRequest,\n params: request,\n }),\n SubmitRequestResponseStruct,\n );\n }\n\n async approveRequest(\n id: string,\n data: Record<string, Json> = {},\n ): Promise<void> {\n assert(\n await this.#send({\n method: KeyringRpcMethod.ApproveRequest,\n params: { id, data },\n }),\n ApproveRequestResponseStruct,\n );\n }\n\n async rejectRequest(id: string): Promise<void> {\n assert(\n await this.#send({\n method: KeyringRpcMethod.RejectRequest,\n params: { id },\n }),\n RejectRequestResponseStruct,\n );\n }\n}\n"]}
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AssetStruct = exports.NonFungibleAssetStruct = exports.FungibleAssetStruct = void 0;
4
+ const superstruct_1 = require("@metamask/superstruct");
5
+ const utils_1 = require("@metamask/utils");
6
+ const superstruct_2 = require("../superstruct.cjs");
7
+ const utils_2 = require("../utils/index.cjs");
8
+ /**
9
+ * Fungible asset struct.
10
+ */
11
+ exports.FungibleAssetStruct = (0, superstruct_2.object)({
12
+ /**
13
+ * It is a fungible asset.
14
+ */
15
+ fungible: (0, superstruct_1.literal)(true),
16
+ /**
17
+ * Asset type (CAIP-19).
18
+ */
19
+ type: utils_1.CaipAssetTypeStruct,
20
+ /**
21
+ * Asset unit.
22
+ */
23
+ unit: (0, superstruct_1.string)(),
24
+ /**
25
+ * Asset amount.
26
+ */
27
+ amount: utils_2.StringNumberStruct,
28
+ });
29
+ /**
30
+ * Non-fungible asset struct.
31
+ */
32
+ exports.NonFungibleAssetStruct = (0, superstruct_2.object)({
33
+ /**
34
+ * It is a non-fungible asset.
35
+ */
36
+ fungible: (0, superstruct_1.literal)(false),
37
+ /**
38
+ * Asset ID (CAIP-19).
39
+ */
40
+ id: utils_1.CaipAssetIdStruct,
41
+ });
42
+ /**
43
+ * Asset struct. This represents a fungible or non-fungible asset. Fungible
44
+ * assets include an amount and a unit in addition to the asset type. While
45
+ * non-fungible assets include only an asset ID.
46
+ *
47
+ * See {@link NonFungibleAssetStruct} and {@link FungibleAssetStruct}.
48
+ *
49
+ * All assets have a `fungible` property that is used to tag the union and
50
+ * allow the following pattern:
51
+ *
52
+ * ```ts
53
+ * if (asset.fungible) {
54
+ * // Use asset.type
55
+ * } else {
56
+ * // Use asset.id
57
+ * }
58
+ * ```
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * {
63
+ * fungible: true,
64
+ * type: 'eip155:1/slip44:60',
65
+ * unit: 'ETH',
66
+ * amount: '0.01',
67
+ * }
68
+ * ```
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * {
73
+ * fungible: false,
74
+ * id: 'eip155:1/erc721:0x06012c8cf97BEaD5deAe237070F9587f8E7A266d/771769',
75
+ * }
76
+ * ```
77
+ */
78
+ exports.AssetStruct = (0, superstruct_2.selectiveUnion)((value) => {
79
+ return (0, utils_1.isPlainObject)(value) && !value.fungible
80
+ ? exports.NonFungibleAssetStruct
81
+ : exports.FungibleAssetStruct;
82
+ });
83
+ //# sourceMappingURL=asset.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset.cjs","sourceRoot":"","sources":["../../src/api/asset.ts"],"names":[],"mappings":";;;AACA,uDAAwD;AACxD,2CAIyB;AAEzB,oDAAwD;AACxD,8CAA8C;AAE9C;;GAEG;AACU,QAAA,mBAAmB,GAAG,IAAA,oBAAM,EAAC;IACxC;;OAEG;IACH,QAAQ,EAAE,IAAA,qBAAO,EAAC,IAAI,CAAC;IAEvB;;OAEG;IACH,IAAI,EAAE,2BAAmB;IAEzB;;OAEG;IACH,IAAI,EAAE,IAAA,oBAAM,GAAE;IAEd;;OAEG;IACH,MAAM,EAAE,0BAAkB;CAC3B,CAAC,CAAC;AAEH;;GAEG;AACU,QAAA,sBAAsB,GAAG,IAAA,oBAAM,EAAC;IAC3C;;OAEG;IACH,QAAQ,EAAE,IAAA,qBAAO,EAAC,KAAK,CAAC;IAExB;;OAEG;IACH,EAAE,EAAE,yBAAiB;CACtB,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACU,QAAA,WAAW,GAAG,IAAA,4BAAc,EAAC,CAAC,KAAU,EAAE,EAAE;IACvD,OAAO,IAAA,qBAAa,EAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ;QAC5C,CAAC,CAAC,8BAAsB;QACxB,CAAC,CAAC,2BAAmB,CAAC;AAC1B,CAAC,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { literal, string } from '@metamask/superstruct';\nimport {\n CaipAssetIdStruct,\n CaipAssetTypeStruct,\n isPlainObject,\n} from '@metamask/utils';\n\nimport { object, selectiveUnion } from '../superstruct';\nimport { StringNumberStruct } from '../utils';\n\n/**\n * Fungible asset struct.\n */\nexport const FungibleAssetStruct = object({\n /**\n * It is a fungible asset.\n */\n fungible: literal(true),\n\n /**\n * Asset type (CAIP-19).\n */\n type: CaipAssetTypeStruct,\n\n /**\n * Asset unit.\n */\n unit: string(),\n\n /**\n * Asset amount.\n */\n amount: StringNumberStruct,\n});\n\n/**\n * Non-fungible asset struct.\n */\nexport const NonFungibleAssetStruct = object({\n /**\n * It is a non-fungible asset.\n */\n fungible: literal(false),\n\n /**\n * Asset ID (CAIP-19).\n */\n id: CaipAssetIdStruct,\n});\n\n/**\n * Asset struct. This represents a fungible or non-fungible asset. Fungible\n * assets include an amount and a unit in addition to the asset type. While\n * non-fungible assets include only an asset ID.\n *\n * See {@link NonFungibleAssetStruct} and {@link FungibleAssetStruct}.\n *\n * All assets have a `fungible` property that is used to tag the union and\n * allow the following pattern:\n *\n * ```ts\n * if (asset.fungible) {\n * // Use asset.type\n * } else {\n * // Use asset.id\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * fungible: true,\n * type: 'eip155:1/slip44:60',\n * unit: 'ETH',\n * amount: '0.01',\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * fungible: false,\n * id: 'eip155:1/erc721:0x06012c8cf97BEaD5deAe237070F9587f8E7A266d/771769',\n * }\n * ```\n */\nexport const AssetStruct = selectiveUnion((value: any) => {\n return isPlainObject(value) && !value.fungible\n ? NonFungibleAssetStruct\n : FungibleAssetStruct;\n});\n\n/**\n * Asset type {@see AssetStruct}.\n */\nexport type Asset = Infer<typeof AssetStruct>;\n"]}
@@ -0,0 +1,93 @@
1
+ import type { Infer } from "@metamask/superstruct";
2
+ /**
3
+ * Fungible asset struct.
4
+ */
5
+ export declare const FungibleAssetStruct: import("@metamask/superstruct").Struct<{
6
+ type: `${string}:${string}/${string}:${string}`;
7
+ fungible: true;
8
+ unit: string;
9
+ amount: string;
10
+ }, {
11
+ /**
12
+ * It is a fungible asset.
13
+ */
14
+ fungible: import("@metamask/superstruct").Struct<true, true>;
15
+ /**
16
+ * Asset type (CAIP-19).
17
+ */
18
+ type: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}`, null>;
19
+ /**
20
+ * Asset unit.
21
+ */
22
+ unit: import("@metamask/superstruct").Struct<string, null>;
23
+ /**
24
+ * Asset amount.
25
+ */
26
+ amount: import("@metamask/superstruct").Struct<string, null>;
27
+ }>;
28
+ /**
29
+ * Non-fungible asset struct.
30
+ */
31
+ export declare const NonFungibleAssetStruct: import("@metamask/superstruct").Struct<{
32
+ id: `${string}:${string}/${string}:${string}/${string}`;
33
+ fungible: false;
34
+ }, {
35
+ /**
36
+ * It is a non-fungible asset.
37
+ */
38
+ fungible: import("@metamask/superstruct").Struct<false, false>;
39
+ /**
40
+ * Asset ID (CAIP-19).
41
+ */
42
+ id: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}/${string}`, null>;
43
+ }>;
44
+ /**
45
+ * Asset struct. This represents a fungible or non-fungible asset. Fungible
46
+ * assets include an amount and a unit in addition to the asset type. While
47
+ * non-fungible assets include only an asset ID.
48
+ *
49
+ * See {@link NonFungibleAssetStruct} and {@link FungibleAssetStruct}.
50
+ *
51
+ * All assets have a `fungible` property that is used to tag the union and
52
+ * allow the following pattern:
53
+ *
54
+ * ```ts
55
+ * if (asset.fungible) {
56
+ * // Use asset.type
57
+ * } else {
58
+ * // Use asset.id
59
+ * }
60
+ * ```
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * {
65
+ * fungible: true,
66
+ * type: 'eip155:1/slip44:60',
67
+ * unit: 'ETH',
68
+ * amount: '0.01',
69
+ * }
70
+ * ```
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * {
75
+ * fungible: false,
76
+ * id: 'eip155:1/erc721:0x06012c8cf97BEaD5deAe237070F9587f8E7A266d/771769',
77
+ * }
78
+ * ```
79
+ */
80
+ export declare const AssetStruct: import("@metamask/superstruct").Struct<{
81
+ type: `${string}:${string}/${string}:${string}`;
82
+ fungible: true;
83
+ unit: string;
84
+ amount: string;
85
+ } | {
86
+ id: `${string}:${string}/${string}:${string}/${string}`;
87
+ fungible: false;
88
+ }, null>;
89
+ /**
90
+ * Asset type {@see AssetStruct}.
91
+ */
92
+ export type Asset = Infer<typeof AssetStruct>;
93
+ //# sourceMappingURL=asset.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset.d.cts","sourceRoot":"","sources":["../../src/api/asset.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAWnD;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;IAC9B;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;EAEH,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;IACjC;;OAEG;;IAGH;;OAEG;;EAEH,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,WAAW;;;;;;;;QAItB,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC"}
@@ -0,0 +1,93 @@
1
+ import type { Infer } from "@metamask/superstruct";
2
+ /**
3
+ * Fungible asset struct.
4
+ */
5
+ export declare const FungibleAssetStruct: import("@metamask/superstruct").Struct<{
6
+ type: `${string}:${string}/${string}:${string}`;
7
+ fungible: true;
8
+ unit: string;
9
+ amount: string;
10
+ }, {
11
+ /**
12
+ * It is a fungible asset.
13
+ */
14
+ fungible: import("@metamask/superstruct").Struct<true, true>;
15
+ /**
16
+ * Asset type (CAIP-19).
17
+ */
18
+ type: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}`, null>;
19
+ /**
20
+ * Asset unit.
21
+ */
22
+ unit: import("@metamask/superstruct").Struct<string, null>;
23
+ /**
24
+ * Asset amount.
25
+ */
26
+ amount: import("@metamask/superstruct").Struct<string, null>;
27
+ }>;
28
+ /**
29
+ * Non-fungible asset struct.
30
+ */
31
+ export declare const NonFungibleAssetStruct: import("@metamask/superstruct").Struct<{
32
+ id: `${string}:${string}/${string}:${string}/${string}`;
33
+ fungible: false;
34
+ }, {
35
+ /**
36
+ * It is a non-fungible asset.
37
+ */
38
+ fungible: import("@metamask/superstruct").Struct<false, false>;
39
+ /**
40
+ * Asset ID (CAIP-19).
41
+ */
42
+ id: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}/${string}`, null>;
43
+ }>;
44
+ /**
45
+ * Asset struct. This represents a fungible or non-fungible asset. Fungible
46
+ * assets include an amount and a unit in addition to the asset type. While
47
+ * non-fungible assets include only an asset ID.
48
+ *
49
+ * See {@link NonFungibleAssetStruct} and {@link FungibleAssetStruct}.
50
+ *
51
+ * All assets have a `fungible` property that is used to tag the union and
52
+ * allow the following pattern:
53
+ *
54
+ * ```ts
55
+ * if (asset.fungible) {
56
+ * // Use asset.type
57
+ * } else {
58
+ * // Use asset.id
59
+ * }
60
+ * ```
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * {
65
+ * fungible: true,
66
+ * type: 'eip155:1/slip44:60',
67
+ * unit: 'ETH',
68
+ * amount: '0.01',
69
+ * }
70
+ * ```
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * {
75
+ * fungible: false,
76
+ * id: 'eip155:1/erc721:0x06012c8cf97BEaD5deAe237070F9587f8E7A266d/771769',
77
+ * }
78
+ * ```
79
+ */
80
+ export declare const AssetStruct: import("@metamask/superstruct").Struct<{
81
+ type: `${string}:${string}/${string}:${string}`;
82
+ fungible: true;
83
+ unit: string;
84
+ amount: string;
85
+ } | {
86
+ id: `${string}:${string}/${string}:${string}/${string}`;
87
+ fungible: false;
88
+ }, null>;
89
+ /**
90
+ * Asset type {@see AssetStruct}.
91
+ */
92
+ export type Asset = Infer<typeof AssetStruct>;
93
+ //# sourceMappingURL=asset.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset.d.mts","sourceRoot":"","sources":["../../src/api/asset.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAWnD;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;IAC9B;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;EAEH,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;IACjC;;OAEG;;IAGH;;OAEG;;EAEH,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,WAAW;;;;;;;;QAItB,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC"}
@@ -0,0 +1,80 @@
1
+ import { literal, string } from "@metamask/superstruct";
2
+ import { CaipAssetIdStruct, CaipAssetTypeStruct, isPlainObject } from "@metamask/utils";
3
+ import { object, selectiveUnion } from "../superstruct.mjs";
4
+ import { StringNumberStruct } from "../utils/index.mjs";
5
+ /**
6
+ * Fungible asset struct.
7
+ */
8
+ export const FungibleAssetStruct = object({
9
+ /**
10
+ * It is a fungible asset.
11
+ */
12
+ fungible: literal(true),
13
+ /**
14
+ * Asset type (CAIP-19).
15
+ */
16
+ type: CaipAssetTypeStruct,
17
+ /**
18
+ * Asset unit.
19
+ */
20
+ unit: string(),
21
+ /**
22
+ * Asset amount.
23
+ */
24
+ amount: StringNumberStruct,
25
+ });
26
+ /**
27
+ * Non-fungible asset struct.
28
+ */
29
+ export const NonFungibleAssetStruct = object({
30
+ /**
31
+ * It is a non-fungible asset.
32
+ */
33
+ fungible: literal(false),
34
+ /**
35
+ * Asset ID (CAIP-19).
36
+ */
37
+ id: CaipAssetIdStruct,
38
+ });
39
+ /**
40
+ * Asset struct. This represents a fungible or non-fungible asset. Fungible
41
+ * assets include an amount and a unit in addition to the asset type. While
42
+ * non-fungible assets include only an asset ID.
43
+ *
44
+ * See {@link NonFungibleAssetStruct} and {@link FungibleAssetStruct}.
45
+ *
46
+ * All assets have a `fungible` property that is used to tag the union and
47
+ * allow the following pattern:
48
+ *
49
+ * ```ts
50
+ * if (asset.fungible) {
51
+ * // Use asset.type
52
+ * } else {
53
+ * // Use asset.id
54
+ * }
55
+ * ```
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * {
60
+ * fungible: true,
61
+ * type: 'eip155:1/slip44:60',
62
+ * unit: 'ETH',
63
+ * amount: '0.01',
64
+ * }
65
+ * ```
66
+ *
67
+ * @example
68
+ * ```ts
69
+ * {
70
+ * fungible: false,
71
+ * id: 'eip155:1/erc721:0x06012c8cf97BEaD5deAe237070F9587f8E7A266d/771769',
72
+ * }
73
+ * ```
74
+ */
75
+ export const AssetStruct = selectiveUnion((value) => {
76
+ return isPlainObject(value) && !value.fungible
77
+ ? NonFungibleAssetStruct
78
+ : FungibleAssetStruct;
79
+ });
80
+ //# sourceMappingURL=asset.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset.mjs","sourceRoot":"","sources":["../../src/api/asset.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,8BAA8B;AACxD,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,EACd,wBAAwB;AAEzB,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,2BAAuB;AACxD,OAAO,EAAE,kBAAkB,EAAE,2BAAiB;AAE9C;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC;IACxC;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC;IAEvB;;OAEG;IACH,IAAI,EAAE,mBAAmB;IAEzB;;OAEG;IACH,IAAI,EAAE,MAAM,EAAE;IAEd;;OAEG;IACH,MAAM,EAAE,kBAAkB;CAC3B,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC;IAC3C;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC;IAExB;;OAEG;IACH,EAAE,EAAE,iBAAiB;CACtB,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,cAAc,CAAC,CAAC,KAAU,EAAE,EAAE;IACvD,OAAO,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ;QAC5C,CAAC,CAAC,sBAAsB;QACxB,CAAC,CAAC,mBAAmB,CAAC;AAC1B,CAAC,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { literal, string } from '@metamask/superstruct';\nimport {\n CaipAssetIdStruct,\n CaipAssetTypeStruct,\n isPlainObject,\n} from '@metamask/utils';\n\nimport { object, selectiveUnion } from '../superstruct';\nimport { StringNumberStruct } from '../utils';\n\n/**\n * Fungible asset struct.\n */\nexport const FungibleAssetStruct = object({\n /**\n * It is a fungible asset.\n */\n fungible: literal(true),\n\n /**\n * Asset type (CAIP-19).\n */\n type: CaipAssetTypeStruct,\n\n /**\n * Asset unit.\n */\n unit: string(),\n\n /**\n * Asset amount.\n */\n amount: StringNumberStruct,\n});\n\n/**\n * Non-fungible asset struct.\n */\nexport const NonFungibleAssetStruct = object({\n /**\n * It is a non-fungible asset.\n */\n fungible: literal(false),\n\n /**\n * Asset ID (CAIP-19).\n */\n id: CaipAssetIdStruct,\n});\n\n/**\n * Asset struct. This represents a fungible or non-fungible asset. Fungible\n * assets include an amount and a unit in addition to the asset type. While\n * non-fungible assets include only an asset ID.\n *\n * See {@link NonFungibleAssetStruct} and {@link FungibleAssetStruct}.\n *\n * All assets have a `fungible` property that is used to tag the union and\n * allow the following pattern:\n *\n * ```ts\n * if (asset.fungible) {\n * // Use asset.type\n * } else {\n * // Use asset.id\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * fungible: true,\n * type: 'eip155:1/slip44:60',\n * unit: 'ETH',\n * amount: '0.01',\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * fungible: false,\n * id: 'eip155:1/erc721:0x06012c8cf97BEaD5deAe237070F9587f8E7A266d/771769',\n * }\n * ```\n */\nexport const AssetStruct = selectiveUnion((value: any) => {\n return isPlainObject(value) && !value.fungible\n ? NonFungibleAssetStruct\n : FungibleAssetStruct;\n});\n\n/**\n * Asset type {@see AssetStruct}.\n */\nexport type Asset = Infer<typeof AssetStruct>;\n"]}
@@ -1,7 +1,7 @@
1
1
  import type { Infer } from "@metamask/superstruct";
2
2
  export declare const BalanceStruct: import("@metamask/superstruct").Struct<{
3
- amount: string;
4
3
  unit: string;
4
+ amount: string;
5
5
  }, {
6
6
  amount: import("@metamask/superstruct").Struct<string, null>;
7
7
  unit: import("@metamask/superstruct").Struct<string, null>;
@@ -1,7 +1,7 @@
1
1
  import type { Infer } from "@metamask/superstruct";
2
2
  export declare const BalanceStruct: import("@metamask/superstruct").Struct<{
3
- amount: string;
4
3
  unit: string;
4
+ amount: string;
5
5
  }, {
6
6
  amount: import("@metamask/superstruct").Struct<string, null>;
7
7
  unit: import("@metamask/superstruct").Struct<string, null>;
@@ -15,9 +15,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./account.cjs"), exports);
18
+ __exportStar(require("./asset.cjs"), exports);
18
19
  __exportStar(require("./balance.cjs"), exports);
19
20
  __exportStar(require("./caip.cjs"), exports);
20
21
  __exportStar(require("./export.cjs"), exports);
21
22
  __exportStar(require("./request.cjs"), exports);
22
23
  __exportStar(require("./response.cjs"), exports);
24
+ __exportStar(require("./transaction.cjs"), exports);
23
25
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA0B;AAC1B,gDAA0B;AAC1B,6CAAuB;AACvB,+CAAyB;AAEzB,gDAA0B;AAC1B,iDAA2B","sourcesContent":["export * from './account';\nexport * from './balance';\nexport * from './caip';\nexport * from './export';\nexport type * from './keyring';\nexport * from './request';\nexport * from './response';\n"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA0B;AAC1B,8CAAwB;AACxB,gDAA0B;AAC1B,6CAAuB;AACvB,+CAAyB;AACzB,gDAA0B;AAC1B,iDAA2B;AAC3B,oDAA8B","sourcesContent":["export * from './account';\nexport * from './asset';\nexport * from './balance';\nexport * from './caip';\nexport * from './export';\nexport * from './request';\nexport * from './response';\nexport * from './transaction';\nexport type * from './keyring';\n"]}
@@ -1,8 +1,10 @@
1
1
  export * from "./account.cjs";
2
+ export * from "./asset.cjs";
2
3
  export * from "./balance.cjs";
3
4
  export * from "./caip.cjs";
4
5
  export * from "./export.cjs";
5
- export type * from "./keyring.cjs";
6
6
  export * from "./request.cjs";
7
7
  export * from "./response.cjs";
8
+ export * from "./transaction.cjs";
9
+ export type * from "./keyring.cjs";
8
10
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,8BAA0B;AAC1B,8BAA0B;AAC1B,2BAAuB;AACvB,6BAAyB;AACzB,mCAA+B;AAC/B,8BAA0B;AAC1B,+BAA2B"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,8BAA0B;AAC1B,4BAAwB;AACxB,8BAA0B;AAC1B,2BAAuB;AACvB,6BAAyB;AACzB,8BAA0B;AAC1B,+BAA2B;AAC3B,kCAA8B;AAC9B,mCAA+B"}