@metamask/keyring-api
Version:
MetaMask Keyring API
1 lines • 2.37 kB
Source Map (JSON)
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../src/sol/types.ts"],"names":[],"mappings":";;;AAAA,2DAAiD;AAEjD,uDAAwE;AACxE,2CAAgD;AAEhD,0CAIgB;AAEhB;;;;GAIG;AACU,QAAA,gBAAgB,GAAG,IAAA,qBAAa,EAC3C,YAAY,EACZ,iCAAiC,CAClC,CAAC;AAEF;;GAEG;AACH,IAAY,SAWX;AAXD,WAAY,SAAS;IACnB,8BAA8B;IAE9B,cAAc;IACd,2DAA2D;IAC3D,oEAAuD,CAAA;IAEvD,8DAAiD,CAAA;IACjD,gDAAmC,CAAA;IACnC,wCAA2B,CAAA;IAC3B,8BAAiB,CAAA;AACnB,CAAC,EAXW,SAAS,yBAAT,SAAS,QAWpB;AAEY,QAAA,oBAAoB,GAAG,IAAA,sBAAM,EAAC;IACzC,GAAG,0BAAoB,CAAC,MAAM;IAE9B;;OAEG;IACH,OAAO,EAAE,wBAAgB;IAEzB;;OAEG;IACH,IAAI,EAAE,IAAA,qBAAO,EAAC,GAAG,oBAAc,CAAC,WAAW,EAAE,CAAC;IAE9C;;OAEG;IACH,MAAM,EAAE,IAAA,sBAAQ,EAAC,IAAA,mBAAK,EAAC,uBAAiB,CAAC,CAAC;IAE1C;;OAEG;IACH,OAAO,EAAE,IAAA,mBAAK,EAAC,IAAA,mBAAK,EAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;CAChD,CAAC,CAAC","sourcesContent":["import { object } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport { array, enums, literal, nonempty } from '@metamask/superstruct';\nimport { definePattern } from '@metamask/utils';\n\nimport {\n CaipChainIdStruct,\n KeyringAccountStruct,\n SolAccountType,\n} from '../api';\n\n/**\n * Solana addresses are represented in the format of a 256-bit ed25519 public key and\n * are encoded using base58.\n * They are usually 32 to 44 characters long.\n */\nexport const SolAddressStruct = definePattern(\n 'SolAddress',\n /^[1-9A-HJ-NP-Za-km-z]{32,44}$/iu,\n);\n\n/**\n * Supported Solana methods.\n */\nexport enum SolMethod {\n // General transaction methods\n\n // @deprecated\n // TODO: Remove this once the new methods are fully adopted\n SendAndConfirmTransaction = 'sendAndConfirmTransaction',\n\n SignAndSendTransaction = 'signAndSendTransaction',\n SignTransaction = 'signTransaction',\n SignMessage = 'signMessage',\n SignIn = 'signIn',\n}\n\nexport const SolDataAccountStruct = object({\n ...KeyringAccountStruct.schema,\n\n /**\n * Account address.\n */\n address: SolAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${SolAccountType.DataAccount}`),\n\n /**\n * Account supported scopes (CAIP-2 chain IDs).\n */\n scopes: nonempty(array(CaipChainIdStruct)),\n\n /**\n * Account supported methods.\n */\n methods: array(enums(Object.values(SolMethod))),\n});\n\nexport type SolDataAccount = Infer<typeof SolDataAccountStruct>;\n"]}