@metamask-previews/eth-snap-keyring 16.0.0-2c74956 → 16.1.0-a621908

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.
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
+ ## [16.1.0]
11
+
12
+ ### Added
13
+
14
+ - Add Tron support ([#349](https://github.com/MetaMask/accounts/pull/349))
15
+
10
16
  ## [16.0.0]
11
17
 
12
18
  ### Changed
@@ -549,7 +555,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
549
555
 
550
556
  - Initial release.
551
557
 
552
- [Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/eth-snap-keyring@16.0.0...HEAD
558
+ [Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/eth-snap-keyring@16.1.0...HEAD
559
+ [16.1.0]: https://github.com/MetaMask/accounts/compare/@metamask/eth-snap-keyring@16.0.0...@metamask/eth-snap-keyring@16.1.0
553
560
  [16.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/eth-snap-keyring@15.0.0...@metamask/eth-snap-keyring@16.0.0
554
561
  [15.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/eth-snap-keyring@14.0.0...@metamask/eth-snap-keyring@15.0.0
555
562
  [14.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/eth-snap-keyring@13.0.0...@metamask/eth-snap-keyring@14.0.0
package/dist/account.cjs CHANGED
@@ -50,6 +50,10 @@ function assertKeyringAccount(account) {
50
50
  (0, superstruct_1.assert)(account, keyring_api_1.EthEoaAccountStruct);
51
51
  return account;
52
52
  }
53
+ case keyring_api_1.TrxAccountType.Eoa: {
54
+ (0, superstruct_1.assert)(account, keyring_api_1.TrxEoaAccountStruct);
55
+ return account;
56
+ }
53
57
  case keyring_api_1.AnyAccountType.Account: {
54
58
  (0, superstruct_1.assert)(account, keyring_api_1.KeyringAccountStruct);
55
59
  return account;
@@ -1 +1 @@
1
- {"version":3,"file":"account.cjs","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":";;;AAiCA,oDA6CC;AAQD,4CAYC;AAjGD,uDAa+B;AAC/B,uDAAiE;AAEjE,uDAA+D;AAE/D;;;GAGG;AACU,QAAA,sBAAsB,GAAG,IAAA,kBAAI,EAAC,kCAAoB,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;AAI7E;;;;;GAKG;AACH,SAAgB,oBAAoB,CAElC,OAAgB;IAChB,gFAAgF;IAChF,sFAAsF;IACtF,cAAc;IACd,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;QACrB,KAAK,4BAAc,CAAC,KAAK,CAAC,CAAC,CAAC;YAC1B,IAAA,oBAAM,EAAC,OAAO,EAAE,mCAAqB,CAAC,CAAC;YACvC,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,KAAK,4BAAc,CAAC,IAAI,CAAC,CAAC,CAAC;YACzB,IAAA,oBAAM,EAAC,OAAO,EAAE,kCAAoB,CAAC,CAAC;YACtC,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,KAAK,4BAAc,CAAC,MAAM,CAAC,CAAC,CAAC;YAC3B,IAAA,oBAAM,EAAC,OAAO,EAAE,oCAAsB,CAAC,CAAC;YACxC,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,KAAK,4BAAc,CAAC,IAAI,CAAC,CAAC,CAAC;YACzB,IAAA,oBAAM,EAAC,OAAO,EAAE,kCAAoB,CAAC,CAAC;YACtC,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,KAAK,4BAAc,CAAC,WAAW,CAAC,CAAC,CAAC;YAChC,IAAA,oBAAM,EAAC,OAAO,EAAE,kCAAoB,CAAC,CAAC;YACtC,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,KAAK,4BAAc,CAAC,OAAO,CAAC,CAAC,CAAC;YAC5B,IAAA,oBAAM,EAAC,OAAO,EAAE,qCAAuB,CAAC,CAAC;YACzC,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,KAAK,4BAAc,CAAC,GAAG,CAAC,CAAC,CAAC;YACxB,IAAA,oBAAM,EAAC,OAAO,EAAE,iCAAmB,CAAC,CAAC;YACrC,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,KAAK,4BAAc,CAAC,OAAO,CAAC,CAAC,CAAC;YAC5B,IAAA,oBAAM,EAAC,OAAO,EAAE,kCAAoB,CAAC,CAAC;YACtC,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACR,2EAA2E;YAC3E,qEAAqE;YACrE,MAAM,IAAI,KAAK,CAAC,0BAA0B,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAgB,gBAAgB;AAC9B,6EAA6E;AAC7E,kBAAqD;IAErD,6FAA6F;IAC7F,0EAA0E;IAC1E,MAAM,OAAO,GAAG,IAAA,wBAAW,EAAC,kBAAkB,CAAC;QAC7C,CAAC,CAAC,IAAA,+BAAkB,EAAC,kBAAkB,CAAC;QACxC,CAAC,CAAC,kBAAkB,CAAC;IAEvB,yFAAyF;IACzF,OAAO,oBAAoB,CAAC,OAAO,CAAC,CAAC;AACvC,CAAC","sourcesContent":["import type { KeyringAccount, KeyringAccountType } from '@metamask/keyring-api';\nimport {\n BtcAccountType,\n BtcP2pkhAccountStruct,\n BtcP2shAccountStruct,\n BtcP2wpkhAccountStruct,\n BtcP2trAccountStruct,\n EthAccountType,\n EthEoaAccountStruct,\n EthErc4337AccountStruct,\n AnyAccountType,\n KeyringAccountStruct,\n SolAccountType,\n SolDataAccountStruct,\n} from '@metamask/keyring-api';\nimport { assert, omit, type Infer } from '@metamask/superstruct';\n\nimport { isAccountV1, transformAccountV1 } from './migrations';\n\n/**\n * A `KeyringAccount` with some optional fields which can be used to keep\n * the retro-compatility with older version of keyring accounts/events.\n */\nexport const KeyringAccountV1Struct = omit(KeyringAccountStruct, ['scopes']);\n\nexport type KeyringAccountV1 = Infer<typeof KeyringAccountV1Struct>;\n\n/**\n * Assert that an account-like object matches its actual account type.\n *\n * @param account - The account-like object.\n * @returns The account as normal `KeyringAccount`.\n */\nexport function assertKeyringAccount<\n Account extends { type: KeyringAccountType },\n>(account: Account): KeyringAccount {\n // TODO: We should use a `selectiveUnion` for this and probably use it to define\n // the `KeyringAccount`. This would also required to have a \"generic `KeyringAccount`\"\n // definition.\n switch (account.type) {\n case BtcAccountType.P2pkh: {\n assert(account, BtcP2pkhAccountStruct);\n return account;\n }\n case BtcAccountType.P2sh: {\n assert(account, BtcP2shAccountStruct);\n return account;\n }\n case BtcAccountType.P2wpkh: {\n assert(account, BtcP2wpkhAccountStruct);\n return account;\n }\n case BtcAccountType.P2tr: {\n assert(account, BtcP2trAccountStruct);\n return account;\n }\n case SolAccountType.DataAccount: {\n assert(account, SolDataAccountStruct);\n return account;\n }\n case EthAccountType.Erc4337: {\n assert(account, EthErc4337AccountStruct);\n return account;\n }\n case EthAccountType.Eoa: {\n assert(account, EthEoaAccountStruct);\n return account;\n }\n case AnyAccountType.Account: {\n assert(account, KeyringAccountStruct);\n return account;\n }\n default: {\n // For now, we cannot much more than this (this should also, never happen)!\n // NOTE: We could use a \"generic `KeyringAccount` type\" here though.\n throw new Error(`Unknown account type: '${account.type}'`);\n }\n }\n}\n\n/**\n * Transform any versionned account to a `KeyringAccount`.\n *\n * @param accountToTransform - The account to transform.\n * @returns A valid transformed `KeyringAccount`.\n */\nexport function transformAccount(\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n accountToTransform: KeyringAccountV1 | KeyringAccount,\n): KeyringAccount {\n // To keep the retro-compatibility with older keyring-api versions, we identify the account's\n // version and transform it to the latest `KeyringAccount` representation.\n const account = isAccountV1(accountToTransform)\n ? transformAccountV1(accountToTransform)\n : accountToTransform;\n\n // We still assert that the converted account is valid according to their account's type.\n return assertKeyringAccount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AO,CAAC;QACjB,CAAC;QACD,KAAK,4BAAc,CAAC,GAAG,CAAC,CAAC,CAAC;YACxB,IAAA,oBAAM,EAAC,OAAO,EAAE,iCAAmB,CAAC,CAAC;YACrC,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,KAAK,4BAAc,CAAC,GAAG,CAAC,CAAC,CAAC;YACxB,IAAA,oBAAM,EAAC,OAAO,EAAE,iCAAmB,CAAC,CAAC;YACrC,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,KAAK,4BAAc,CAAC,OAAO,CAAC,CAAC,CAAC;YAC5B,IAAA,oBAAM,EAAC,OAAO,EAAE,kCAAoB,CAAC,CAAC;YACtC,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACR,2EAA2E;YAC3E,qEAAqE;YACrE,MAAM,IAAI,KAAK,CAAC,0BAA0B,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAgB,gBAAgB;AAC9B,6EAA6E;AAC7E,kBAAqD;IAErD,6FAA6F;IAC7F,0EAA0E;IAC1E,MAAM,OAAO,GAAG,IAAA,wBAAW,EAAC,kBAAkB,CAAC;QAC7C,CAAC,CAAC,IAAA,+BAAkB,EAAC,kBAAkB,CAAC;QACxC,CAAC,CAAC,kBAAkB,CAAC;IAEvB,yFAAyF;IACzF,OAAO,oBAAoB,CAAC,OAAO,CAAC,CAAC;AACvC,CAAC","sourcesContent":["import type { KeyringAccount, KeyringAccountType } from '@metamask/keyring-api';\nimport {\n BtcAccountType,\n BtcP2pkhAccountStruct,\n BtcP2shAccountStruct,\n BtcP2wpkhAccountStruct,\n BtcP2trAccountStruct,\n EthAccountType,\n EthEoaAccountStruct,\n EthErc4337AccountStruct,\n AnyAccountType,\n KeyringAccountStruct,\n SolAccountType,\n SolDataAccountStruct,\n TrxAccountType,\n TrxEoaAccountStruct,\n} from '@metamask/keyring-api';\nimport { assert, omit, type Infer } from '@metamask/superstruct';\n\nimport { isAccountV1, transformAccountV1 } from './migrations';\n\n/**\n * A `KeyringAccount` with some optional fields which can be used to keep\n * the retro-compatility with older version of keyring accounts/events.\n */\nexport const KeyringAccountV1Struct = omit(KeyringAccountStruct, ['scopes']);\n\nexport type KeyringAccountV1 = Infer<typeof KeyringAccountV1Struct>;\n\n/**\n * Assert that an account-like object matches its actual account type.\n *\n * @param account - The account-like object.\n * @returns The account as normal `KeyringAccount`.\n */\nexport function assertKeyringAccount<\n Account extends { type: KeyringAccountType },\n>(account: Account): KeyringAccount {\n // TODO: We should use a `selectiveUnion` for this and probably use it to define\n // the `KeyringAccount`. This would also required to have a \"generic `KeyringAccount`\"\n // definition.\n switch (account.type) {\n case BtcAccountType.P2pkh: {\n assert(account, BtcP2pkhAccountStruct);\n return account;\n }\n case BtcAccountType.P2sh: {\n assert(account, BtcP2shAccountStruct);\n return account;\n }\n case BtcAccountType.P2wpkh: {\n assert(account, BtcP2wpkhAccountStruct);\n return account;\n }\n case BtcAccountType.P2tr: {\n assert(account, BtcP2trAccountStruct);\n return account;\n }\n case SolAccountType.DataAccount: {\n assert(account, SolDataAccountStruct);\n return account;\n }\n case EthAccountType.Erc4337: {\n assert(account, EthErc4337AccountStruct);\n return account;\n }\n case EthAccountType.Eoa: {\n assert(account, EthEoaAccountStruct);\n return account;\n }\n case TrxAccountType.Eoa: {\n assert(account, TrxEoaAccountStruct);\n return account;\n }\n case AnyAccountType.Account: {\n assert(account, KeyringAccountStruct);\n return account;\n }\n default: {\n // For now, we cannot much more than this (this should also, never happen)!\n // NOTE: We could use a \"generic `KeyringAccount` type\" here though.\n throw new Error(`Unknown account type: '${account.type}'`);\n }\n }\n}\n\n/**\n * Transform any versionned account to a `KeyringAccount`.\n *\n * @param accountToTransform - The account to transform.\n * @returns A valid transformed `KeyringAccount`.\n */\nexport function transformAccount(\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n accountToTransform: KeyringAccountV1 | KeyringAccount,\n): KeyringAccount {\n // To keep the retro-compatibility with older keyring-api versions, we identify the account's\n // version and transform it to the latest `KeyringAccount` representation.\n const account = isAccountV1(accountToTransform)\n ? transformAccountV1(accountToTransform)\n : accountToTransform;\n\n // We still assert that the converted account is valid according to their account's type.\n return assertKeyringAccount(account);\n}\n"]}
@@ -6,7 +6,7 @@ import { type Infer } from "@metamask/superstruct";
6
6
  */
7
7
  export declare const KeyringAccountV1Struct: import("@metamask/superstruct").Struct<{
8
8
  id: string;
9
- type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
9
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
10
10
  address: string;
11
11
  options: Record<string, import("@metamask/utils").Json> & {
12
12
  entropy?: {
@@ -22,7 +22,7 @@ export declare const KeyringAccountV1Struct: import("@metamask/superstruct").Str
22
22
  methods: string[];
23
23
  }, Omit<{
24
24
  id: import("@metamask/superstruct").Struct<string, null>;
25
- type: import("@metamask/superstruct").Struct<"eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account", {
25
+ type: import("@metamask/superstruct").Struct<"eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account", {
26
26
  "eip155:eoa": "eip155:eoa";
27
27
  "eip155:erc4337": "eip155:erc4337";
28
28
  "bip122:p2pkh": "bip122:p2pkh";
@@ -30,6 +30,7 @@ export declare const KeyringAccountV1Struct: import("@metamask/superstruct").Str
30
30
  "bip122:p2wpkh": "bip122:p2wpkh";
31
31
  "bip122:p2tr": "bip122:p2tr";
32
32
  "solana:data-account": "solana:data-account";
33
+ "tron:eoa": "tron:eoa";
33
34
  "any:account": "any:account";
34
35
  }>;
35
36
  address: import("@metamask/superstruct").Struct<string, null>;
@@ -1 +1 @@
1
- {"version":3,"file":"account.d.cts","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,8BAA8B;AAehF,OAAO,EAAgB,KAAK,KAAK,EAAE,8BAA8B;AAIjE;;;GAGG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAsE/B,CAAF;;;;;;;;kBAKF,CAAC;;;aA3E2E,CAAC;AAE7E,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEpE;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,SAAS;IAAE,IAAI,EAAE,kBAAkB,CAAA;CAAE,EAC5C,OAAO,EAAE,OAAO,GAAG,cAAc,CA2ClC;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAE9B,kBAAkB,EAAE,gBAAgB,GAAG,cAAc,GACpD,cAAc,CAShB"}
1
+ {"version":3,"file":"account.d.cts","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,8BAA8B;AAiBhF,OAAO,EAAgB,KAAK,KAAK,EAAE,8BAA8B;AAIjE;;;GAGG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eA0EO,CAAC;;;;;;;;kBAMJ,CAAC;;;aAhFoC,CAAC;AAE7E,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEpE;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,SAAS;IAAE,IAAI,EAAE,kBAAkB,CAAA;CAAE,EAC5C,OAAO,EAAE,OAAO,GAAG,cAAc,CA+ClC;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAE9B,kBAAkB,EAAE,gBAAgB,GAAG,cAAc,GACpD,cAAc,CAShB"}
@@ -6,7 +6,7 @@ import { type Infer } from "@metamask/superstruct";
6
6
  */
7
7
  export declare const KeyringAccountV1Struct: import("@metamask/superstruct").Struct<{
8
8
  id: string;
9
- type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
9
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
10
10
  address: string;
11
11
  options: Record<string, import("@metamask/utils").Json> & {
12
12
  entropy?: {
@@ -22,7 +22,7 @@ export declare const KeyringAccountV1Struct: import("@metamask/superstruct").Str
22
22
  methods: string[];
23
23
  }, Omit<{
24
24
  id: import("@metamask/superstruct").Struct<string, null>;
25
- type: import("@metamask/superstruct").Struct<"eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account", {
25
+ type: import("@metamask/superstruct").Struct<"eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account", {
26
26
  "eip155:eoa": "eip155:eoa";
27
27
  "eip155:erc4337": "eip155:erc4337";
28
28
  "bip122:p2pkh": "bip122:p2pkh";
@@ -30,6 +30,7 @@ export declare const KeyringAccountV1Struct: import("@metamask/superstruct").Str
30
30
  "bip122:p2wpkh": "bip122:p2wpkh";
31
31
  "bip122:p2tr": "bip122:p2tr";
32
32
  "solana:data-account": "solana:data-account";
33
+ "tron:eoa": "tron:eoa";
33
34
  "any:account": "any:account";
34
35
  }>;
35
36
  address: import("@metamask/superstruct").Struct<string, null>;
@@ -1 +1 @@
1
- {"version":3,"file":"account.d.mts","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,8BAA8B;AAehF,OAAO,EAAgB,KAAK,KAAK,EAAE,8BAA8B;AAIjE;;;GAGG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAsE/B,CAAF;;;;;;;;kBAKF,CAAC;;;aA3E2E,CAAC;AAE7E,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEpE;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,SAAS;IAAE,IAAI,EAAE,kBAAkB,CAAA;CAAE,EAC5C,OAAO,EAAE,OAAO,GAAG,cAAc,CA2ClC;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAE9B,kBAAkB,EAAE,gBAAgB,GAAG,cAAc,GACpD,cAAc,CAShB"}
1
+ {"version":3,"file":"account.d.mts","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,8BAA8B;AAiBhF,OAAO,EAAgB,KAAK,KAAK,EAAE,8BAA8B;AAIjE;;;GAGG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eA0EO,CAAC;;;;;;;;kBAMJ,CAAC;;;aAhFoC,CAAC;AAE7E,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEpE;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,SAAS;IAAE,IAAI,EAAE,kBAAkB,CAAA;CAAE,EAC5C,OAAO,EAAE,OAAO,GAAG,cAAc,CA+ClC;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAE9B,kBAAkB,EAAE,gBAAgB,GAAG,cAAc,GACpD,cAAc,CAShB"}
package/dist/account.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { BtcAccountType, BtcP2pkhAccountStruct, BtcP2shAccountStruct, BtcP2wpkhAccountStruct, BtcP2trAccountStruct, EthAccountType, EthEoaAccountStruct, EthErc4337AccountStruct, AnyAccountType, KeyringAccountStruct, SolAccountType, SolDataAccountStruct } from "@metamask/keyring-api";
1
+ import { BtcAccountType, BtcP2pkhAccountStruct, BtcP2shAccountStruct, BtcP2wpkhAccountStruct, BtcP2trAccountStruct, EthAccountType, EthEoaAccountStruct, EthErc4337AccountStruct, AnyAccountType, KeyringAccountStruct, SolAccountType, SolDataAccountStruct, TrxAccountType, TrxEoaAccountStruct } from "@metamask/keyring-api";
2
2
  import { assert, omit } from "@metamask/superstruct";
3
3
  import { isAccountV1, transformAccountV1 } from "./migrations/index.mjs";
4
4
  /**
@@ -45,6 +45,10 @@ export function assertKeyringAccount(account) {
45
45
  assert(account, EthEoaAccountStruct);
46
46
  return account;
47
47
  }
48
+ case TrxAccountType.Eoa: {
49
+ assert(account, TrxEoaAccountStruct);
50
+ return account;
51
+ }
48
52
  case AnyAccountType.Account: {
49
53
  assert(account, KeyringAccountStruct);
50
54
  return account;
@@ -1 +1 @@
1
- {"version":3,"file":"account.mjs","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACpB,cAAc,EACd,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,EACd,oBAAoB,EACpB,cAAc,EACd,oBAAoB,EACrB,8BAA8B;AAC/B,OAAO,EAAE,MAAM,EAAE,IAAI,EAAc,8BAA8B;AAEjE,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,+BAAqB;AAE/D;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;AAI7E;;;;;GAKG;AACH,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;YAC3E,qEAAqE;YACrE,MAAM,IAAI,KAAK,CAAC,0BAA0B,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB;AAC9B,6EAA6E;AAC7E,kBAAqD;IAErD,6FAA6F;IAC7F,0EAA0E;IAC1E,MAAM,OAAO,GAAG,WAAW,CAAC,kBAAkB,CAAC;QAC7C,CAAC,CAAC,kBAAkB,CAAC,kBAAkB,CAAC;QACxC,CAAC,CAAC,kBAAkB,CAAC;IAEvB,yFAAyF;IACzF,OAAO,oBAAoB,CAAC,OAAO,CAAC,CAAC;AACvC,CAAC","sourcesContent":["import type { KeyringAccount, KeyringAccountType } from '@metamask/keyring-api';\nimport {\n BtcAccountType,\n BtcP2pkhAccountStruct,\n BtcP2shAccountStruct,\n BtcP2wpkhAccountStruct,\n BtcP2trAccountStruct,\n EthAccountType,\n EthEoaAccountStruct,\n EthErc4337AccountStruct,\n AnyAccountType,\n KeyringAccountStruct,\n SolAccountType,\n SolDataAccountStruct,\n} from '@metamask/keyring-api';\nimport { assert, omit, type Infer } from '@metamask/superstruct';\n\nimport { isAccountV1, transformAccountV1 } from './migrations';\n\n/**\n * A `KeyringAccount` with some optional fields which can be used to keep\n * the retro-compatility with older version of keyring accounts/events.\n */\nexport const KeyringAccountV1Struct = omit(KeyringAccountStruct, ['scopes']);\n\nexport type KeyringAccountV1 = Infer<typeof KeyringAccountV1Struct>;\n\n/**\n * Assert that an account-like object matches its actual account type.\n *\n * @param account - The account-like object.\n * @returns The account as normal `KeyringAccount`.\n */\nexport function assertKeyringAccount<\n Account extends { type: KeyringAccountType },\n>(account: Account): KeyringAccount {\n // TODO: We should use a `selectiveUnion` for this and probably use it to define\n // the `KeyringAccount`. This would also required to have a \"generic `KeyringAccount`\"\n // definition.\n switch (account.type) {\n case BtcAccountType.P2pkh: {\n assert(account, BtcP2pkhAccountStruct);\n return account;\n }\n case BtcAccountType.P2sh: {\n assert(account, BtcP2shAccountStruct);\n return account;\n }\n case BtcAccountType.P2wpkh: {\n assert(account, BtcP2wpkhAccountStruct);\n return account;\n }\n case BtcAccountType.P2tr: {\n assert(account, BtcP2trAccountStruct);\n return account;\n }\n case SolAccountType.DataAccount: {\n assert(account, SolDataAccountStruct);\n return account;\n }\n case EthAccountType.Erc4337: {\n assert(account, EthErc4337AccountStruct);\n return account;\n }\n case EthAccountType.Eoa: {\n assert(account, EthEoaAccountStruct);\n return account;\n }\n case AnyAccountType.Account: {\n assert(account, KeyringAccountStruct);\n return account;\n }\n default: {\n // For now, we cannot much more than this (this should also, never happen)!\n // NOTE: We could use a \"generic `KeyringAccount` type\" here though.\n throw new Error(`Unknown account type: '${account.type}'`);\n }\n }\n}\n\n/**\n * Transform any versionned account to a `KeyringAccount`.\n *\n * @param accountToTransform - The account to transform.\n * @returns A valid transformed `KeyringAccount`.\n */\nexport function transformAccount(\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n accountToTransform: KeyringAccountV1 | KeyringAccount,\n): KeyringAccount {\n // To keep the retro-compatibility with older keyring-api versions, we identify the account's\n // version and transform it to the latest `KeyringAccount` representation.\n const account = isAccountV1(accountToTransform)\n ? transformAccountV1(accountToTransform)\n : accountToTransform;\n\n // We still assert that the converted account is valid according to their account's type.\n return assertKeyringAccount(account);\n}\n"]}
1
+ {"version":3,"file":"account.mjs","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACpB,cAAc,EACd,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,EACd,oBAAoB,EACpB,cAAc,EACd,oBAAoB,EACpB,cAAc,EACd,mBAAmB,EACpB,8BAA8B;AAC/B,OAAO,EAAE,MAAM,EAAE,IAAI,EAAc,8BAA8B;AAEjE,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,+BAAqB;AA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C;YACxB,MAAM,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC;YACrC,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,KAAK,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;YAC5B,MAAM,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;YACtC,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACR,2EAA2E;YAC3E,qEAAqE;YACrE,MAAM,IAAI,KAAK,CAAC,0BAA0B,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB;AAC9B,6EAA6E;AAC7E,kBAAqD;IAErD,6FAA6F;IAC7F,0EAA0E;IAC1E,MAAM,OAAO,GAAG,WAAW,CAAC,kBAAkB,CAAC;QAC7C,CAAC,CAAC,kBAAkB,CAAC,kBAAkB,CAAC;QACxC,CAAC,CAAC,kBAAkB,CAAC;IAEvB,yFAAyF;IACzF,OAAO,oBAAoB,CAAC,OAAO,CAAC,CAAC;AACvC,CAAC","sourcesContent":["import type { KeyringAccount, KeyringAccountType } from '@metamask/keyring-api';\nimport {\n BtcAccountType,\n BtcP2pkhAccountStruct,\n BtcP2shAccountStruct,\n BtcP2wpkhAccountStruct,\n BtcP2trAccountStruct,\n EthAccountType,\n EthEoaAccountStruct,\n EthErc4337AccountStruct,\n AnyAccountType,\n KeyringAccountStruct,\n SolAccountType,\n SolDataAccountStruct,\n TrxAccountType,\n TrxEoaAccountStruct,\n} from '@metamask/keyring-api';\nimport { assert, omit, type Infer } from '@metamask/superstruct';\n\nimport { isAccountV1, transformAccountV1 } from './migrations';\n\n/**\n * A `KeyringAccount` with some optional fields which can be used to keep\n * the retro-compatility with older version of keyring accounts/events.\n */\nexport const KeyringAccountV1Struct = omit(KeyringAccountStruct, ['scopes']);\n\nexport type KeyringAccountV1 = Infer<typeof KeyringAccountV1Struct>;\n\n/**\n * Assert that an account-like object matches its actual account type.\n *\n * @param account - The account-like object.\n * @returns The account as normal `KeyringAccount`.\n */\nexport function assertKeyringAccount<\n Account extends { type: KeyringAccountType },\n>(account: Account): KeyringAccount {\n // TODO: We should use a `selectiveUnion` for this and probably use it to define\n // the `KeyringAccount`. This would also required to have a \"generic `KeyringAccount`\"\n // definition.\n switch (account.type) {\n case BtcAccountType.P2pkh: {\n assert(account, BtcP2pkhAccountStruct);\n return account;\n }\n case BtcAccountType.P2sh: {\n assert(account, BtcP2shAccountStruct);\n return account;\n }\n case BtcAccountType.P2wpkh: {\n assert(account, BtcP2wpkhAccountStruct);\n return account;\n }\n case BtcAccountType.P2tr: {\n assert(account, BtcP2trAccountStruct);\n return account;\n }\n case SolAccountType.DataAccount: {\n assert(account, SolDataAccountStruct);\n return account;\n }\n case EthAccountType.Erc4337: {\n assert(account, EthErc4337AccountStruct);\n return account;\n }\n case EthAccountType.Eoa: {\n assert(account, EthEoaAccountStruct);\n return account;\n }\n case TrxAccountType.Eoa: {\n assert(account, TrxEoaAccountStruct);\n return account;\n }\n case AnyAccountType.Account: {\n assert(account, KeyringAccountStruct);\n return account;\n }\n default: {\n // For now, we cannot much more than this (this should also, never happen)!\n // NOTE: We could use a \"generic `KeyringAccount` type\" here though.\n throw new Error(`Unknown account type: '${account.type}'`);\n }\n }\n}\n\n/**\n * Transform any versionned account to a `KeyringAccount`.\n *\n * @param accountToTransform - The account to transform.\n * @returns A valid transformed `KeyringAccount`.\n */\nexport function transformAccount(\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n accountToTransform: KeyringAccountV1 | KeyringAccount,\n): KeyringAccount {\n // To keep the retro-compatibility with older keyring-api versions, we identify the account's\n // version and transform it to the latest `KeyringAccount` representation.\n const account = isAccountV1(accountToTransform)\n ? transformAccountV1(accountToTransform)\n : accountToTransform;\n\n // We still assert that the converted account is valid according to their account's type.\n return assertKeyringAccount(account);\n}\n"]}
package/dist/events.d.cts CHANGED
@@ -2,7 +2,7 @@ import { AccountDeletedEventStruct, RequestApprovedEventStruct, RequestRejectedE
2
2
  export declare const AccountCreatedEventStruct: import("@metamask/superstruct").Struct<{
3
3
  params: {
4
4
  account: {
5
- type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
5
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
6
6
  id: string;
7
7
  options: Record<string, import("@metamask/utils").Json> & {
8
8
  entropy?: {
@@ -20,7 +20,7 @@ export declare const AccountCreatedEventStruct: import("@metamask/superstruct").
20
20
  methods: string[];
21
21
  } | {
22
22
  id: string;
23
- type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
23
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
24
24
  address: string;
25
25
  options: Record<string, import("@metamask/utils").Json> & {
26
26
  entropy?: {
@@ -46,7 +46,7 @@ export declare const AccountCreatedEventStruct: import("@metamask/superstruct").
46
46
  }, {
47
47
  params: import("@metamask/superstruct").Struct<{
48
48
  account: {
49
- type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
49
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
50
50
  id: string;
51
51
  options: Record<string, import("@metamask/utils").Json> & {
52
52
  entropy?: {
@@ -64,7 +64,7 @@ export declare const AccountCreatedEventStruct: import("@metamask/superstruct").
64
64
  methods: string[];
65
65
  } | {
66
66
  id: string;
67
- type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
67
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
68
68
  address: string;
69
69
  options: Record<string, import("@metamask/utils").Json> & {
70
70
  entropy?: {
@@ -87,7 +87,7 @@ export declare const AccountCreatedEventStruct: import("@metamask/superstruct").
87
87
  displayAccountNameSuggestion?: boolean;
88
88
  }, {
89
89
  account: import("@metamask/superstruct").Struct<{
90
- type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
90
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
91
91
  id: string;
92
92
  options: Record<string, import("@metamask/utils").Json> & {
93
93
  entropy?: {
@@ -105,7 +105,7 @@ export declare const AccountCreatedEventStruct: import("@metamask/superstruct").
105
105
  methods: string[];
106
106
  } | {
107
107
  id: string;
108
- type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
108
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
109
109
  address: string;
110
110
  options: Record<string, import("@metamask/utils").Json> & {
111
111
  entropy?: {
@@ -134,7 +134,7 @@ export declare const AccountCreatedEventStruct: import("@metamask/superstruct").
134
134
  export declare const AccountUpdatedEventStruct: import("@metamask/superstruct").Struct<{
135
135
  params: {
136
136
  account: {
137
- type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
137
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
138
138
  id: string;
139
139
  options: Record<string, import("@metamask/utils").Json> & {
140
140
  entropy?: {
@@ -152,7 +152,7 @@ export declare const AccountUpdatedEventStruct: import("@metamask/superstruct").
152
152
  methods: string[];
153
153
  } | {
154
154
  id: string;
155
- type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
155
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
156
156
  address: string;
157
157
  options: Record<string, import("@metamask/utils").Json> & {
158
158
  entropy?: {
@@ -172,7 +172,7 @@ export declare const AccountUpdatedEventStruct: import("@metamask/superstruct").
172
172
  }, {
173
173
  params: import("@metamask/superstruct").Struct<{
174
174
  account: {
175
- type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
175
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
176
176
  id: string;
177
177
  options: Record<string, import("@metamask/utils").Json> & {
178
178
  entropy?: {
@@ -190,7 +190,7 @@ export declare const AccountUpdatedEventStruct: import("@metamask/superstruct").
190
190
  methods: string[];
191
191
  } | {
192
192
  id: string;
193
- type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
193
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
194
194
  address: string;
195
195
  options: Record<string, import("@metamask/utils").Json> & {
196
196
  entropy?: {
@@ -207,7 +207,7 @@ export declare const AccountUpdatedEventStruct: import("@metamask/superstruct").
207
207
  };
208
208
  }, {
209
209
  account: import("@metamask/superstruct").Struct<{
210
- type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
210
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
211
211
  id: string;
212
212
  options: Record<string, import("@metamask/utils").Json> & {
213
213
  entropy?: {
@@ -225,7 +225,7 @@ export declare const AccountUpdatedEventStruct: import("@metamask/superstruct").
225
225
  methods: string[];
226
226
  } | {
227
227
  id: string;
228
- type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
228
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
229
229
  address: string;
230
230
  options: Record<string, import("@metamask/utils").Json> & {
231
231
  entropy?: {
@@ -1 +1 @@
1
- {"version":3,"file":"events.d.cts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,yBAAyB,EACzB,0BAA0B,EAC1B,0BAA0B,EAE3B,8BAA8B;AAM/B,eAAO,MAAM,yBAAyB;;;;;;uBAyBmW,CAAC;;;;;;;;0BAA0M,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;u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/dist/events.d.mts CHANGED
@@ -2,7 +2,7 @@ import { AccountDeletedEventStruct, RequestApprovedEventStruct, RequestRejectedE
2
2
  export declare const AccountCreatedEventStruct: import("@metamask/superstruct").Struct<{
3
3
  params: {
4
4
  account: {
5
- type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
5
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
6
6
  id: string;
7
7
  options: Record<string, import("@metamask/utils").Json> & {
8
8
  entropy?: {
@@ -20,7 +20,7 @@ export declare const AccountCreatedEventStruct: import("@metamask/superstruct").
20
20
  methods: string[];
21
21
  } | {
22
22
  id: string;
23
- type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
23
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
24
24
  address: string;
25
25
  options: Record<string, import("@metamask/utils").Json> & {
26
26
  entropy?: {
@@ -46,7 +46,7 @@ export declare const AccountCreatedEventStruct: import("@metamask/superstruct").
46
46
  }, {
47
47
  params: import("@metamask/superstruct").Struct<{
48
48
  account: {
49
- type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
49
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
50
50
  id: string;
51
51
  options: Record<string, import("@metamask/utils").Json> & {
52
52
  entropy?: {
@@ -64,7 +64,7 @@ export declare const AccountCreatedEventStruct: import("@metamask/superstruct").
64
64
  methods: string[];
65
65
  } | {
66
66
  id: string;
67
- type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
67
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
68
68
  address: string;
69
69
  options: Record<string, import("@metamask/utils").Json> & {
70
70
  entropy?: {
@@ -87,7 +87,7 @@ export declare const AccountCreatedEventStruct: import("@metamask/superstruct").
87
87
  displayAccountNameSuggestion?: boolean;
88
88
  }, {
89
89
  account: import("@metamask/superstruct").Struct<{
90
- type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
90
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
91
91
  id: string;
92
92
  options: Record<string, import("@metamask/utils").Json> & {
93
93
  entropy?: {
@@ -105,7 +105,7 @@ export declare const AccountCreatedEventStruct: import("@metamask/superstruct").
105
105
  methods: string[];
106
106
  } | {
107
107
  id: string;
108
- type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
108
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
109
109
  address: string;
110
110
  options: Record<string, import("@metamask/utils").Json> & {
111
111
  entropy?: {
@@ -134,7 +134,7 @@ export declare const AccountCreatedEventStruct: import("@metamask/superstruct").
134
134
  export declare const AccountUpdatedEventStruct: import("@metamask/superstruct").Struct<{
135
135
  params: {
136
136
  account: {
137
- type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
137
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
138
138
  id: string;
139
139
  options: Record<string, import("@metamask/utils").Json> & {
140
140
  entropy?: {
@@ -152,7 +152,7 @@ export declare const AccountUpdatedEventStruct: import("@metamask/superstruct").
152
152
  methods: string[];
153
153
  } | {
154
154
  id: string;
155
- type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
155
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
156
156
  address: string;
157
157
  options: Record<string, import("@metamask/utils").Json> & {
158
158
  entropy?: {
@@ -172,7 +172,7 @@ export declare const AccountUpdatedEventStruct: import("@metamask/superstruct").
172
172
  }, {
173
173
  params: import("@metamask/superstruct").Struct<{
174
174
  account: {
175
- type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
175
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
176
176
  id: string;
177
177
  options: Record<string, import("@metamask/utils").Json> & {
178
178
  entropy?: {
@@ -190,7 +190,7 @@ export declare const AccountUpdatedEventStruct: import("@metamask/superstruct").
190
190
  methods: string[];
191
191
  } | {
192
192
  id: string;
193
- type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
193
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
194
194
  address: string;
195
195
  options: Record<string, import("@metamask/utils").Json> & {
196
196
  entropy?: {
@@ -207,7 +207,7 @@ export declare const AccountUpdatedEventStruct: import("@metamask/superstruct").
207
207
  };
208
208
  }, {
209
209
  account: import("@metamask/superstruct").Struct<{
210
- type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
210
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
211
211
  id: string;
212
212
  options: Record<string, import("@metamask/utils").Json> & {
213
213
  entropy?: {
@@ -225,7 +225,7 @@ export declare const AccountUpdatedEventStruct: import("@metamask/superstruct").
225
225
  methods: string[];
226
226
  } | {
227
227
  id: string;
228
- type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
228
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
229
229
  address: string;
230
230
  options: Record<string, import("@metamask/utils").Json> & {
231
231
  entropy?: {
@@ -1 +1 @@
1
- {"version":3,"file":"events.d.mts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,yBAAyB,EACzB,0BAA0B,EAC1B,0BAA0B,EAE3B,8BAA8B;AAM/B,eAAO,MAAM,yBAAyB;;;;;;uBAyBmW,CAAC;;;;;;;;0BAA0M,CAAC;;;;;;;;;;;;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C1B,0BAA0B,GAC3B,CAAC"}
@@ -57,6 +57,10 @@ function getScopesForAccountV1(accountV1) {
57
57
  // Solana account supports multiple chains.
58
58
  return [keyring_api_1.SolScope.Mainnet, keyring_api_1.SolScope.Testnet, keyring_api_1.SolScope.Devnet];
59
59
  }
60
+ case keyring_api_1.TrxAccountType.Eoa: {
61
+ // TRON account supports multiple chains.
62
+ return [keyring_api_1.TrxScope.Mainnet, keyring_api_1.TrxScope.Nile, keyring_api_1.TrxScope.Shasta];
63
+ }
60
64
  default:
61
65
  // We re-use EOA scopes if we don't know what to do for now.
62
66
  return [keyring_api_1.EthScope.Eoa];
@@ -1 +1 @@
1
- {"version":3,"file":"v1.cjs","sourceRoot":"","sources":["../../src/migrations/v1.ts"],"names":[],"mappings":";;AAwBA,kCAKC;AAQD,sDAsCC;AAWD,gDAmBC;AAUD,4CAUC;AA7HD,uDAO+B;AAE/B,2DAA8D;AAC9D,uDAA2C;AAE3C,4CAIoB;AAEpB;;;;;GAKG;AACH,SAAgB,WAAW;AACzB,6EAA6E;AAC7E,OAA0C;IAE1C,OAAO,IAAA,gBAAE,EAAC,OAAO,EAAE,gCAAsB,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;GAKG;AACH,SAAgB,qBAAqB,CACnC,SAA2B;IAE3B,QAAQ,SAAS,CAAC,IAAI,EAAE,CAAC;QACvB,KAAK,4BAAc,CAAC,GAAG,CAAC,CAAC,CAAC;YACxB,mEAAmE;YACnE,6DAA6D;YAC7D,EAAE;YACF,0DAA0D;YAC1D,OAAO,CAAC,sBAAQ,CAAC,GAAG,CAAC,CAAC;QACxB,CAAC;QACD,KAAK,4BAAc,CAAC,OAAO,CAAC,CAAC,CAAC;YAC5B,sBAAsB;YACtB,wGAAwG;YACxG,0DAA0D;YAC1D,2GAA2G;YAC3G,iBAAiB;YACjB,OAAO,CAAC,sBAAQ,CAAC,OAAO,CAAC,CAAC;QAC5B,CAAC;QACD,KAAK,4BAAc,CAAC,KAAK,CAAC;QAC1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ACJ,CAAC","sourcesContent":["import {\n BtcAccountType,\n EthAccountType,\n SolAccountType,\n BtcScope,\n EthScope,\n SolScope,\n} from '@metamask/keyring-api';\nimport type { CaipChainId, KeyringAccount } from '@metamask/keyring-api';\nimport { isBtcMainnetAddress } from '@metamask/keyring-utils';\nimport { is } from '@metamask/superstruct';\n\nimport {\n assertKeyringAccount,\n KeyringAccountV1Struct,\n type KeyringAccountV1,\n} from '../account';\n\n/**\n * Checks if an account is an `KeyringAccount` v1.\n *\n * @param account - A v1 account to check.\n * @returns True if the account is v1, false otherwise.\n */\nexport function isAccountV1(\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n account: KeyringAccountV1 | KeyringAccount,\n): boolean {\n return is(account, KeyringAccountV1Struct);\n}\n\n/**\n * Gets default scopes for a v1 account.\n *\n * @param accountV1 - A v1 account.\n * @returns The list of scopes for that accounts.\n */\nexport function getScopesForAccountV1(\n accountV1: KeyringAccountV1,\n): CaipChainId[] {\n switch (accountV1.type) {\n case EthAccountType.Eoa: {\n // EVM EOA account are compatible with any EVM networks, we use the\n // 'eip155:0' scope as defined in the EVM CAIP-10 namespaces.\n //\n // See: https://namespaces.chainagnostic.org/eip155/caip10\n return [EthScope.Eoa];\n }\n case EthAccountType.Erc4337: {\n // EVM Erc4337 account\n // NOTE: A Smart Contract account might not be compatible with every chain, in this case we just default\n // to testnet since we cannot really \"guess\" it from here.\n // Also, there's no official Snap as of today that uses this account type. So this case should never happen\n // in production.\n return [EthScope.Testnet];\n }\n case BtcAccountType.P2pkh:\n case BtcAccountType.P2sh:\n case BtcAccountType.P2wpkh:\n case BtcAccountType.P2tr: {\n // Bitcoin uses different accounts for testnet and mainnet\n return [\n isBtcMainnetAddress(accountV1.address)\n ? BtcScope.Mainnet\n : BtcScope.Testnet,\n ];\n }\n case SolAccountType.DataAccount: {\n // Solana account supports multiple chains.\n return [SolScope.Mainnet, SolScope.Testnet, SolScope.Devnet];\n }\n default:\n // We re-use EOA scopes if we don't know what to do for now.\n return [EthScope.Eoa];\n }\n}\n\n/**\n * Transform an account v1. This account might have optional fields that are now required by\n * the Keyring API. This function will automatically provides the missing fields with some\n * default values.\n *\n * @param accountV1 - A v1 account to transform.\n * @throws An error if the v1 account cannot be transformed.\n * @returns A valid KeyringAccount.\n */\nexport function transformAccountV1(\n accountV1: KeyringAccountV1,\n): KeyringAccount {\n const { type } = accountV1;\n\n // EVM EOA account are compatible with any EVM networks, and we use CAIP-2\n // namespaces when the scope relates to ALL chains (from that namespace).\n // So we can automatically inject a valid `scopes` for this, but not for\n // other kind of accounts.\n if (type === EthAccountType.Eoa) {\n return {\n ...accountV1,\n scopes: getScopesForAccountV1(accountV1),\n };\n }\n\n // For all other non-EVM and ERC4337 Snap accounts, the `scopes` is required, and\n // each `*AccountStruct` should assert that automatically.\n return assertKeyringAccount(accountV1);\n}\n\n/**\n * Migrate an account v1. This account might have optional fields that are now required by\n * the Keyring API. This function will automatically provides the missing fields with some\n * meaningful default values.\n *\n * @param accountV1 - The account to migrate.\n * @returns A valid KeyringAccount.\n */\nexport function migrateAccountV1(accountV1: KeyringAccountV1): KeyringAccount {\n if (!isAccountV1(accountV1)) {\n // Nothing to do in this case.\n return accountV1 as KeyringAccount;\n }\n\n return {\n ...accountV1,\n scopes: getScopesForAccountV1(accountV1),\n };\n}\n"]}
1
+ {"version":3,"file":"v1.cjs","sourceRoot":"","sources":["../../src/migrations/v1.ts"],"names":[],"mappings":";;AA0BA,kCAKC;AAQD,sDA0CC;AAWD,gDAmBC;AAUD,4CAUC;AAnID,uDAS+B;AAE/B,2DAA8D;AAC9D,uDAA2C;AAE3C,4CAIoB;AAEpB;;;;;GAKG;AACH,SAAgB,WAAW;AACzB,6EAA6E;AAC7E,OAA0C;IAE1C,OAAO,IAAA,gBAAE,EAAC,OAAO,EAAE,gCAAsB,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;GAKG;AACH,SAAgB,qBAAqB,CACnC,SAA2B;IAE3B,QAAQ,SAAS,CAAC,IAA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M,EAAE,IAAI,EAAE,GAAG,SAAS,CAAC;IAE3B,0EAA0E;IAC1E,yEAAyE;IACzE,wEAAwE;IACxE,0BAA0B;IAC1B,IAAI,IAAI,KAAK,4BAAc,CAAC,GAAG,EAAE,CAAC;QAChC,OAAO;YACL,GAAG,SAAS;YACZ,MAAM,EAAE,qBAAqB,CAAC,SAAS,CAAC;SACzC,CAAC;IACJ,CAAC;IAED,iFAAiF;IACjF,0DAA0D;IAC1D,OAAO,IAAA,8BAAoB,EAAC,SAAS,CAAC,CAAC;AACzC,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,gBAAgB,CAAC,SAA2B;IAC1D,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC;QAC5B,8BAA8B;QAC9B,OAAO,SAA2B,CAAC;IACrC,CAAC;IAED,OAAO;QACL,GAAG,SAAS;QACZ,MAAM,EAAE,qBAAqB,CAAC,SAAS,CAAC;KACzC,CAAC;AACJ,CAAC","sourcesContent":["import {\n BtcAccountType,\n EthAccountType,\n SolAccountType,\n BtcScope,\n EthScope,\n SolScope,\n TrxScope,\n TrxAccountType,\n} from '@metamask/keyring-api';\nimport type { CaipChainId, KeyringAccount } from '@metamask/keyring-api';\nimport { isBtcMainnetAddress } from '@metamask/keyring-utils';\nimport { is } from '@metamask/superstruct';\n\nimport {\n assertKeyringAccount,\n KeyringAccountV1Struct,\n type KeyringAccountV1,\n} from '../account';\n\n/**\n * Checks if an account is an `KeyringAccount` v1.\n *\n * @param account - A v1 account to check.\n * @returns True if the account is v1, false otherwise.\n */\nexport function isAccountV1(\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n account: KeyringAccountV1 | KeyringAccount,\n): boolean {\n return is(account, KeyringAccountV1Struct);\n}\n\n/**\n * Gets default scopes for a v1 account.\n *\n * @param accountV1 - A v1 account.\n * @returns The list of scopes for that accounts.\n */\nexport function getScopesForAccountV1(\n accountV1: KeyringAccountV1,\n): CaipChainId[] {\n switch (accountV1.type) {\n case EthAccountType.Eoa: {\n // EVM EOA account are compatible with any EVM networks, we use the\n // 'eip155:0' scope as defined in the EVM CAIP-10 namespaces.\n //\n // See: https://namespaces.chainagnostic.org/eip155/caip10\n return [EthScope.Eoa];\n }\n case EthAccountType.Erc4337: {\n // EVM Erc4337 account\n // NOTE: A Smart Contract account might not be compatible with every chain, in this case we just default\n // to testnet since we cannot really \"guess\" it from here.\n // Also, there's no official Snap as of today that uses this account type. So this case should never happen\n // in production.\n return [EthScope.Testnet];\n }\n case BtcAccountType.P2pkh:\n case BtcAccountType.P2sh:\n case BtcAccountType.P2wpkh:\n case BtcAccountType.P2tr: {\n // Bitcoin uses different accounts for testnet and mainnet\n return [\n isBtcMainnetAddress(accountV1.address)\n ? BtcScope.Mainnet\n : BtcScope.Testnet,\n ];\n }\n case SolAccountType.DataAccount: {\n // Solana account supports multiple chains.\n return [SolScope.Mainnet, SolScope.Testnet, SolScope.Devnet];\n }\n case TrxAccountType.Eoa: {\n // TRON account supports multiple chains.\n return [TrxScope.Mainnet, TrxScope.Nile, TrxScope.Shasta];\n }\n default:\n // We re-use EOA scopes if we don't know what to do for now.\n return [EthScope.Eoa];\n }\n}\n\n/**\n * Transform an account v1. This account might have optional fields that are now required by\n * the Keyring API. This function will automatically provides the missing fields with some\n * default values.\n *\n * @param accountV1 - A v1 account to transform.\n * @throws An error if the v1 account cannot be transformed.\n * @returns A valid KeyringAccount.\n */\nexport function transformAccountV1(\n accountV1: KeyringAccountV1,\n): KeyringAccount {\n const { type } = accountV1;\n\n // EVM EOA account are compatible with any EVM networks, and we use CAIP-2\n // namespaces when the scope relates to ALL chains (from that namespace).\n // So we can automatically inject a valid `scopes` for this, but not for\n // other kind of accounts.\n if (type === EthAccountType.Eoa) {\n return {\n ...accountV1,\n scopes: getScopesForAccountV1(accountV1),\n };\n }\n\n // For all other non-EVM and ERC4337 Snap accounts, the `scopes` is required, and\n // each `*AccountStruct` should assert that automatically.\n return assertKeyringAccount(accountV1);\n}\n\n/**\n * Migrate an account v1. This account might have optional fields that are now required by\n * the Keyring API. This function will automatically provides the missing fields with some\n * meaningful default values.\n *\n * @param accountV1 - The account to migrate.\n * @returns A valid KeyringAccount.\n */\nexport function migrateAccountV1(accountV1: KeyringAccountV1): KeyringAccount {\n if (!isAccountV1(accountV1)) {\n // Nothing to do in this case.\n return accountV1 as KeyringAccount;\n }\n\n return {\n ...accountV1,\n scopes: getScopesForAccountV1(accountV1),\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"v1.d.cts","sourceRoot":"","sources":["../../src/migrations/v1.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,8BAA8B;AAIzE,OAAO,EAGL,KAAK,gBAAgB,EACtB,uBAAmB;AAEpB;;;;;GAKG;AACH,wBAAgB,WAAW,CAEzB,OAAO,EAAE,gBAAgB,GAAG,cAAc,GACzC,OAAO,CAET;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,gBAAgB,GAC1B,WAAW,EAAE,CAoCf;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,gBAAgB,GAC1B,cAAc,CAiBhB;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,gBAAgB,GAAG,cAAc,CAU5E"}
1
+ {"version":3,"file":"v1.d.cts","sourceRoot":"","sources":["../../src/migrations/v1.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,8BAA8B;AAIzE,OAAO,EAGL,KAAK,gBAAgB,EACtB,uBAAmB;AAEpB;;;;;GAKG;AACH,wBAAgB,WAAW,CAEzB,OAAO,EAAE,gBAAgB,GAAG,cAAc,GACzC,OAAO,CAET;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,gBAAgB,GAC1B,WAAW,EAAE,CAwCf;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,gBAAgB,GAC1B,cAAc,CAiBhB;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,gBAAgB,GAAG,cAAc,CAU5E"}
@@ -1 +1 @@
1
- {"version":3,"file":"v1.d.mts","sourceRoot":"","sources":["../../src/migrations/v1.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,8BAA8B;AAIzE,OAAO,EAGL,KAAK,gBAAgB,EACtB,uBAAmB;AAEpB;;;;;GAKG;AACH,wBAAgB,WAAW,CAEzB,OAAO,EAAE,gBAAgB,GAAG,cAAc,GACzC,OAAO,CAET;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,gBAAgB,GAC1B,WAAW,EAAE,CAoCf;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,gBAAgB,GAC1B,cAAc,CAiBhB;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,gBAAgB,GAAG,cAAc,CAU5E"}
1
+ {"version":3,"file":"v1.d.mts","sourceRoot":"","sources":["../../src/migrations/v1.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,8BAA8B;AAIzE,OAAO,EAGL,KAAK,gBAAgB,EACtB,uBAAmB;AAEpB;;;;;GAKG;AACH,wBAAgB,WAAW,CAEzB,OAAO,EAAE,gBAAgB,GAAG,cAAc,GACzC,OAAO,CAET;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,gBAAgB,GAC1B,WAAW,EAAE,CAwCf;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,gBAAgB,GAC1B,cAAc,CAiBhB;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,gBAAgB,GAAG,cAAc,CAU5E"}
@@ -1,4 +1,4 @@
1
- import { BtcAccountType, EthAccountType, SolAccountType, BtcScope, EthScope, SolScope } from "@metamask/keyring-api";
1
+ import { BtcAccountType, EthAccountType, SolAccountType, BtcScope, EthScope, SolScope, TrxScope, TrxAccountType } from "@metamask/keyring-api";
2
2
  import { isBtcMainnetAddress } from "@metamask/keyring-utils";
3
3
  import { is } from "@metamask/superstruct";
4
4
  import { assertKeyringAccount, KeyringAccountV1Struct } from "../account.mjs";
@@ -51,6 +51,10 @@ export function getScopesForAccountV1(accountV1) {
51
51
  // Solana account supports multiple chains.
52
52
  return [SolScope.Mainnet, SolScope.Testnet, SolScope.Devnet];
53
53
  }
54
+ case TrxAccountType.Eoa: {
55
+ // TRON account supports multiple chains.
56
+ return [TrxScope.Mainnet, TrxScope.Nile, TrxScope.Shasta];
57
+ }
54
58
  default:
55
59
  // We re-use EOA scopes if we don't know what to do for now.
56
60
  return [EthScope.Eoa];
@@ -1 +1 @@
1
- {"version":3,"file":"v1.mjs","sourceRoot":"","sources":["../../src/migrations/v1.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,cAAc,EACd,cAAc,EACd,QAAQ,EACR,QAAQ,EACR,QAAQ,EACT,8BAA8B;AAE/B,OAAO,EAAE,mBAAmB,EAAE,gCAAgC;AAC9D,OAAO,EAAE,EAAE,EAAE,8BAA8B;AAE3C,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EAEvB,uBAAmB;AAEpB;;;;;GAKG;AACH,MAAM,UAAU,WAAW;AACzB,6EAA6E;AAC7E,OAA0C;IAE1C,OAAO,EAAE,CAAC,OAAO,EAAE,sBAAsB,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CACnC,SAA2B;IAE3B,QAAQ,SAAS,CAAC,IAAI,EAAE,CAAC;QACvB,KAAK,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;YACxB,mEAAmE;YACnE,6DAA6D;YAC7D,EAAE;YACF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SAAS,CAAC,CAAC;AACzC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAA2B;IAC1D,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC;QAC5B,8BAA8B;QAC9B,OAAO,SAA2B,CAAC;IACrC,CAAC;IAED,OAAO;QACL,GAAG,SAAS;QACZ,MAAM,EAAE,qBAAqB,CAAC,SAAS,CAAC;KACzC,CAAC;AACJ,CAAC","sourcesContent":["import {\n BtcAccountType,\n EthAccountType,\n SolAccountType,\n BtcScope,\n EthScope,\n SolScope,\n} from '@metamask/keyring-api';\nimport type { CaipChainId, KeyringAccount } from '@metamask/keyring-api';\nimport { isBtcMainnetAddress } from '@metamask/keyring-utils';\nimport { is } from '@metamask/superstruct';\n\nimport {\n assertKeyringAccount,\n KeyringAccountV1Struct,\n type KeyringAccountV1,\n} from '../account';\n\n/**\n * Checks if an account is an `KeyringAccount` v1.\n *\n * @param account - A v1 account to check.\n * @returns True if the account is v1, false otherwise.\n */\nexport function isAccountV1(\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n account: KeyringAccountV1 | KeyringAccount,\n): boolean {\n return is(account, KeyringAccountV1Struct);\n}\n\n/**\n * Gets default scopes for a v1 account.\n *\n * @param accountV1 - A v1 account.\n * @returns The list of scopes for that accounts.\n */\nexport function getScopesForAccountV1(\n accountV1: KeyringAccountV1,\n): CaipChainId[] {\n switch (accountV1.type) {\n case EthAccountType.Eoa: {\n // EVM EOA account are compatible with any EVM networks, we use the\n // 'eip155:0' scope as defined in the EVM CAIP-10 namespaces.\n //\n // See: https://namespaces.chainagnostic.org/eip155/caip10\n return [EthScope.Eoa];\n }\n case EthAccountType.Erc4337: {\n // EVM Erc4337 account\n // NOTE: A Smart Contract account might not be compatible with every chain, in this case we just default\n // to testnet since we cannot really \"guess\" it from here.\n // Also, there's no official Snap as of today that uses this account type. So this case should never happen\n // in production.\n return [EthScope.Testnet];\n }\n case BtcAccountType.P2pkh:\n case BtcAccountType.P2sh:\n case BtcAccountType.P2wpkh:\n case BtcAccountType.P2tr: {\n // Bitcoin uses different accounts for testnet and mainnet\n return [\n isBtcMainnetAddress(accountV1.address)\n ? BtcScope.Mainnet\n : BtcScope.Testnet,\n ];\n }\n case SolAccountType.DataAccount: {\n // Solana account supports multiple chains.\n return [SolScope.Mainnet, SolScope.Testnet, SolScope.Devnet];\n }\n default:\n // We re-use EOA scopes if we don't know what to do for now.\n return [EthScope.Eoa];\n }\n}\n\n/**\n * Transform an account v1. This account might have optional fields that are now required by\n * the Keyring API. This function will automatically provides the missing fields with some\n * default values.\n *\n * @param accountV1 - A v1 account to transform.\n * @throws An error if the v1 account cannot be transformed.\n * @returns A valid KeyringAccount.\n */\nexport function transformAccountV1(\n accountV1: KeyringAccountV1,\n): KeyringAccount {\n const { type } = accountV1;\n\n // EVM EOA account are compatible with any EVM networks, and we use CAIP-2\n // namespaces when the scope relates to ALL chains (from that namespace).\n // So we can automatically inject a valid `scopes` for this, but not for\n // other kind of accounts.\n if (type === EthAccountType.Eoa) {\n return {\n ...accountV1,\n scopes: getScopesForAccountV1(accountV1),\n };\n }\n\n // For all other non-EVM and ERC4337 Snap accounts, the `scopes` is required, and\n // each `*AccountStruct` should assert that automatically.\n return assertKeyringAccount(accountV1);\n}\n\n/**\n * Migrate an account v1. This account might have optional fields that are now required by\n * the Keyring API. This function will automatically provides the missing fields with some\n * meaningful default values.\n *\n * @param accountV1 - The account to migrate.\n * @returns A valid KeyringAccount.\n */\nexport function migrateAccountV1(accountV1: KeyringAccountV1): KeyringAccount {\n if (!isAccountV1(accountV1)) {\n // Nothing to do in this case.\n return accountV1 as KeyringAccount;\n }\n\n return {\n ...accountV1,\n scopes: getScopesForAccountV1(accountV1),\n };\n}\n"]}
1
+ {"version":3,"file":"v1.mjs","sourceRoot":"","sources":["../../src/migrations/v1.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,cAAc,EACd,cAAc,EACd,QAAQ,EACR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AC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC/D,CAAC;QACD,KAAK,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;YACxB,yCAAyC;YACzC,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC5D,CAAC;QACD;YACE,4DAA4D;YAC5D,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAChC,SAA2B;IAE3B,MAAM,EAAE,IAAI,EAAE,GAAG,SAAS,CAAC;IAE3B,0EAA0E;IAC1E,yEAAyE;IACzE,wEAAwE;IACxE,0BAA0B;IAC1B,IAAI,IAAI,KAAK,cAAc,CAAC,GAAG,EAAE,CAAC;QAChC,OAAO;YACL,GAAG,SAAS;YACZ,MAAM,EAAE,qBAAqB,CAAC,SAAS,CAAC;SACzC,CAAC;IACJ,CAAC;IAED,iFAAiF;IACjF,0DAA0D;IAC1D,OAAO,oBAAoB,CAAC,SAAS,CAAC,CAAC;AACzC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAA2B;IAC1D,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC;QAC5B,8BAA8B;QAC9B,OAAO,SAA2B,CAAC;IACrC,CAAC;IAED,OAAO;QACL,GAAG,SAAS;QACZ,MAAM,EAAE,qBAAqB,CAAC,SAAS,CAAC;KACzC,CAAC;AACJ,CAAC","sourcesContent":["import {\n BtcAccountType,\n EthAccountType,\n SolAccountType,\n BtcScope,\n EthScope,\n SolScope,\n TrxScope,\n TrxAccountType,\n} from '@metamask/keyring-api';\nimport type { CaipChainId, KeyringAccount } from '@metamask/keyring-api';\nimport { isBtcMainnetAddress } from '@metamask/keyring-utils';\nimport { is } from '@metamask/superstruct';\n\nimport {\n assertKeyringAccount,\n KeyringAccountV1Struct,\n type KeyringAccountV1,\n} from '../account';\n\n/**\n * Checks if an account is an `KeyringAccount` v1.\n *\n * @param account - A v1 account to check.\n * @returns True if the account is v1, false otherwise.\n */\nexport function isAccountV1(\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n account: KeyringAccountV1 | KeyringAccount,\n): boolean {\n return is(account, KeyringAccountV1Struct);\n}\n\n/**\n * Gets default scopes for a v1 account.\n *\n * @param accountV1 - A v1 account.\n * @returns The list of scopes for that accounts.\n */\nexport function getScopesForAccountV1(\n accountV1: KeyringAccountV1,\n): CaipChainId[] {\n switch (accountV1.type) {\n case EthAccountType.Eoa: {\n // EVM EOA account are compatible with any EVM networks, we use the\n // 'eip155:0' scope as defined in the EVM CAIP-10 namespaces.\n //\n // See: https://namespaces.chainagnostic.org/eip155/caip10\n return [EthScope.Eoa];\n }\n case EthAccountType.Erc4337: {\n // EVM Erc4337 account\n // NOTE: A Smart Contract account might not be compatible with every chain, in this case we just default\n // to testnet since we cannot really \"guess\" it from here.\n // Also, there's no official Snap as of today that uses this account type. So this case should never happen\n // in production.\n return [EthScope.Testnet];\n }\n case BtcAccountType.P2pkh:\n case BtcAccountType.P2sh:\n case BtcAccountType.P2wpkh:\n case BtcAccountType.P2tr: {\n // Bitcoin uses different accounts for testnet and mainnet\n return [\n isBtcMainnetAddress(accountV1.address)\n ? BtcScope.Mainnet\n : BtcScope.Testnet,\n ];\n }\n case SolAccountType.DataAccount: {\n // Solana account supports multiple chains.\n return [SolScope.Mainnet, SolScope.Testnet, SolScope.Devnet];\n }\n case TrxAccountType.Eoa: {\n // TRON account supports multiple chains.\n return [TrxScope.Mainnet, TrxScope.Nile, TrxScope.Shasta];\n }\n default:\n // We re-use EOA scopes if we don't know what to do for now.\n return [EthScope.Eoa];\n }\n}\n\n/**\n * Transform an account v1. This account might have optional fields that are now required by\n * the Keyring API. This function will automatically provides the missing fields with some\n * default values.\n *\n * @param accountV1 - A v1 account to transform.\n * @throws An error if the v1 account cannot be transformed.\n * @returns A valid KeyringAccount.\n */\nexport function transformAccountV1(\n accountV1: KeyringAccountV1,\n): KeyringAccount {\n const { type } = accountV1;\n\n // EVM EOA account are compatible with any EVM networks, and we use CAIP-2\n // namespaces when the scope relates to ALL chains (from that namespace).\n // So we can automatically inject a valid `scopes` for this, but not for\n // other kind of accounts.\n if (type === EthAccountType.Eoa) {\n return {\n ...accountV1,\n scopes: getScopesForAccountV1(accountV1),\n };\n }\n\n // For all other non-EVM and ERC4337 Snap accounts, the `scopes` is required, and\n // each `*AccountStruct` should assert that automatically.\n return assertKeyringAccount(accountV1);\n}\n\n/**\n * Migrate an account v1. This account might have optional fields that are now required by\n * the Keyring API. This function will automatically provides the missing fields with some\n * meaningful default values.\n *\n * @param accountV1 - The account to migrate.\n * @returns A valid KeyringAccount.\n */\nexport function migrateAccountV1(accountV1: KeyringAccountV1): KeyringAccount {\n if (!isAccountV1(accountV1)) {\n // Nothing to do in this case.\n return accountV1 as KeyringAccount;\n }\n\n return {\n ...accountV1,\n scopes: getScopesForAccountV1(accountV1),\n };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/eth-snap-keyring",
3
- "version": "16.0.0-2c74956",
3
+ "version": "16.1.0-a621908",
4
4
  "description": "Snaps keyring bridge.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -40,8 +40,8 @@
40
40
  "@ethereumjs/tx": "^5.4.0",
41
41
  "@metamask/base-controller": "^7.1.1",
42
42
  "@metamask/eth-sig-util": "^8.2.0",
43
- "@metamask/keyring-api": "20.0.0",
44
- "@metamask/keyring-internal-api": "8.0.0",
43
+ "@metamask/keyring-api": "20.1.0",
44
+ "@metamask/keyring-internal-api": "8.1.0",
45
45
  "@metamask/keyring-internal-snap-client": "6.0.0",
46
46
  "@metamask/keyring-utils": "3.1.0",
47
47
  "@metamask/superstruct": "^3.1.0",