@metamask-previews/keyring-api 23.3.0-e51c895 → 23.4.0-5951828
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 +20 -1
- package/dist/api/account-options.cjs +3 -3
- package/dist/api/account-options.cjs.map +1 -1
- package/dist/api/account-options.d.cts.map +1 -1
- package/dist/api/account-options.d.mts.map +1 -1
- package/dist/api/account-options.mjs +2 -2
- package/dist/api/account-options.mjs.map +1 -1
- package/dist/api/account.cjs +1 -1
- package/dist/api/account.cjs.map +1 -1
- package/dist/api/account.mjs +2 -2
- package/dist/api/account.mjs.map +1 -1
- package/dist/api/asset.cjs +3 -3
- package/dist/api/asset.cjs.map +1 -1
- package/dist/api/asset.d.cts.map +1 -1
- package/dist/api/asset.d.mts.map +1 -1
- package/dist/api/asset.mjs +2 -2
- package/dist/api/asset.mjs.map +1 -1
- package/dist/api/balance.cjs +1 -1
- package/dist/api/balance.cjs.map +1 -1
- package/dist/api/balance.mjs +2 -2
- package/dist/api/balance.mjs.map +1 -1
- package/dist/api/options.cjs +3 -2
- package/dist/api/options.cjs.map +1 -1
- package/dist/api/options.d.cts +1 -1
- package/dist/api/options.d.cts.map +1 -1
- package/dist/api/options.d.mts +1 -1
- package/dist/api/options.d.mts.map +1 -1
- package/dist/api/options.mjs +2 -1
- package/dist/api/options.mjs.map +1 -1
- package/dist/api/pagination.cjs +2 -3
- package/dist/api/pagination.cjs.map +1 -1
- package/dist/api/pagination.d.cts +1 -1
- package/dist/api/pagination.d.cts.map +1 -1
- package/dist/api/pagination.d.mts +1 -1
- package/dist/api/pagination.d.mts.map +1 -1
- package/dist/api/pagination.mjs +1 -2
- package/dist/api/pagination.mjs.map +1 -1
- package/dist/api/request.cjs +3 -3
- package/dist/api/request.cjs.map +1 -1
- package/dist/api/request.d.cts +1 -1
- package/dist/api/request.d.cts.map +1 -1
- package/dist/api/request.d.mts +1 -1
- package/dist/api/request.d.mts.map +1 -1
- package/dist/api/request.mjs +2 -2
- package/dist/api/request.mjs.map +1 -1
- package/dist/api/response.cjs +5 -6
- package/dist/api/response.cjs.map +1 -1
- package/dist/api/response.d.cts.map +1 -1
- package/dist/api/response.d.mts.map +1 -1
- package/dist/api/response.mjs +1 -2
- package/dist/api/response.mjs.map +1 -1
- package/dist/api/transaction.cjs +10 -10
- package/dist/api/transaction.cjs.map +1 -1
- package/dist/api/transaction.d.cts +11 -11
- package/dist/api/transaction.d.cts.map +1 -1
- package/dist/api/transaction.d.mts +11 -11
- package/dist/api/transaction.d.mts.map +1 -1
- package/dist/api/transaction.mjs +2 -2
- package/dist/api/transaction.mjs.map +1 -1
- package/dist/btc/types.cjs +5 -6
- package/dist/btc/types.cjs.map +1 -1
- package/dist/btc/types.d.cts.map +1 -1
- package/dist/btc/types.d.mts.map +1 -1
- package/dist/btc/types.mjs +1 -2
- package/dist/btc/types.mjs.map +1 -1
- package/dist/eth/erc4337/types.cjs +9 -8
- package/dist/eth/erc4337/types.cjs.map +1 -1
- package/dist/eth/erc4337/types.d.cts +4 -4
- package/dist/eth/erc4337/types.d.cts.map +1 -1
- package/dist/eth/erc4337/types.d.mts +4 -4
- package/dist/eth/erc4337/types.d.mts.map +1 -1
- package/dist/eth/erc4337/types.mjs +2 -1
- package/dist/eth/erc4337/types.mjs.map +1 -1
- package/dist/eth/rpc/params.cjs +4 -5
- package/dist/eth/rpc/params.cjs.map +1 -1
- package/dist/eth/rpc/params.d.cts.map +1 -1
- package/dist/eth/rpc/params.d.mts.map +1 -1
- package/dist/eth/rpc/params.mjs +1 -2
- package/dist/eth/rpc/params.mjs.map +1 -1
- package/dist/eth/types.cjs +4 -5
- package/dist/eth/types.cjs.map +1 -1
- package/dist/eth/types.d.cts +1 -1
- package/dist/eth/types.d.cts.map +1 -1
- package/dist/eth/types.d.mts +1 -1
- package/dist/eth/types.d.mts.map +1 -1
- package/dist/eth/types.mjs +2 -3
- package/dist/eth/types.mjs.map +1 -1
- package/dist/events.cjs +20 -20
- package/dist/events.cjs.map +1 -1
- package/dist/events.d.cts +4 -4
- package/dist/events.d.cts.map +1 -1
- package/dist/events.d.mts +4 -4
- package/dist/events.d.mts.map +1 -1
- package/dist/events.mjs +2 -2
- package/dist/events.mjs.map +1 -1
- package/dist/rpc.cjs +36 -36
- package/dist/rpc.cjs.map +1 -1
- package/dist/rpc.d.cts +78 -42
- package/dist/rpc.d.cts.map +1 -1
- package/dist/rpc.d.mts +78 -42
- package/dist/rpc.d.mts.map +1 -1
- package/dist/rpc.mjs +2 -2
- package/dist/rpc.mjs.map +1 -1
- package/dist/sol/types.cjs +1 -2
- package/dist/sol/types.cjs.map +1 -1
- package/dist/sol/types.d.cts.map +1 -1
- package/dist/sol/types.d.mts.map +1 -1
- package/dist/sol/types.mjs +1 -2
- package/dist/sol/types.mjs.map +1 -1
- package/dist/trx/types.cjs +1 -2
- package/dist/trx/types.cjs.map +1 -1
- package/dist/trx/types.d.cts.map +1 -1
- package/dist/trx/types.d.mts.map +1 -1
- package/dist/trx/types.mjs +1 -2
- package/dist/trx/types.mjs.map +1 -1
- package/dist/v2/api/index.cjs +1 -0
- package/dist/v2/api/index.cjs.map +1 -1
- package/dist/v2/api/index.d.cts +1 -0
- package/dist/v2/api/index.d.cts.map +1 -1
- package/dist/v2/api/index.d.mts +1 -0
- package/dist/v2/api/index.d.mts.map +1 -1
- package/dist/v2/api/index.mjs +1 -0
- package/dist/v2/api/index.mjs.map +1 -1
- package/dist/v2/api/keyring-capabilities.cjs +37 -0
- package/dist/v2/api/keyring-capabilities.cjs.map +1 -1
- package/dist/v2/api/keyring-capabilities.d.cts +57 -0
- package/dist/v2/api/keyring-capabilities.d.cts.map +1 -1
- package/dist/v2/api/keyring-capabilities.d.mts +57 -0
- package/dist/v2/api/keyring-capabilities.d.mts.map +1 -1
- package/dist/v2/api/keyring-capabilities.mjs +37 -0
- package/dist/v2/api/keyring-capabilities.mjs.map +1 -1
- package/dist/v2/api/keyring-rpc.cjs +10 -10
- package/dist/v2/api/keyring-rpc.cjs.map +1 -1
- package/dist/v2/api/keyring-rpc.d.cts +2 -2
- package/dist/v2/api/keyring-rpc.d.cts.map +1 -1
- package/dist/v2/api/keyring-rpc.d.mts +2 -2
- package/dist/v2/api/keyring-rpc.d.mts.map +1 -1
- package/dist/v2/api/keyring-rpc.mjs +2 -2
- package/dist/v2/api/keyring-rpc.mjs.map +1 -1
- package/dist/v2/api/keyring-snap-rpc.cjs +92 -0
- package/dist/v2/api/keyring-snap-rpc.cjs.map +1 -0
- package/dist/v2/api/keyring-snap-rpc.d.cts +545 -0
- package/dist/v2/api/keyring-snap-rpc.d.cts.map +1 -0
- package/dist/v2/api/keyring-snap-rpc.d.mts +545 -0
- package/dist/v2/api/keyring-snap-rpc.d.mts.map +1 -0
- package/dist/v2/api/keyring-snap-rpc.mjs +88 -0
- package/dist/v2/api/keyring-snap-rpc.mjs.map +1 -0
- package/dist/xlm/types.cjs +1 -2
- package/dist/xlm/types.cjs.map +1 -1
- package/dist/xlm/types.d.cts.map +1 -1
- package/dist/xlm/types.d.mts.map +1 -1
- package/dist/xlm/types.mjs +1 -2
- package/dist/xlm/types.mjs.map +1 -1
- package/package.json +2 -2
package/dist/eth/types.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { object } from "@metamask/
|
|
2
|
-
import { nonempty, array, enums, literal } from "@metamask/superstruct";
|
|
1
|
+
import { nonempty, array, enums, literal, object } from "@metamask/superstruct";
|
|
3
2
|
import { definePattern } from "@metamask/utils";
|
|
4
|
-
import { EthScope } from "./index.mjs";
|
|
5
3
|
import { CaipChainIdStruct, EthAccountType, KeyringAccountStruct } from "../api/index.mjs";
|
|
4
|
+
import { EthScope } from "./constants.mjs";
|
|
6
5
|
const ETH_BYTES_REGEX = /^0x[0-9a-f]*$/iu;
|
|
7
6
|
export const EthBytesStruct = definePattern('EthBytes', ETH_BYTES_REGEX);
|
|
8
7
|
// Stricter struct that uses `Hex` as final type.
|
package/dist/eth/types.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../src/eth/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../src/eth/types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,8BAA8B;AAChF,OAAO,EAAE,aAAa,EAAE,wBAAwB;AAGhD,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACrB,yBAAe;AAChB,OAAO,EAAE,QAAQ,EAAE,wBAAoB;AAEvC,MAAM,eAAe,GAAG,iBAAiB,CAAC;AAC1C,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;AACzE,iDAAiD;AACjD,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAa,CAC/C,gBAAgB,EAChB,eAAe,CAChB,CAAC;AAEF,MAAM,iBAAiB,GAAG,oBAAoB,CAAC;AAC/C,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAAC;AAC/E,iDAAiD;AACjD,MAAM,CAAC,MAAM,sBAAsB,GAAG,aAAa,CACjD,kBAAkB,EAClB,iBAAiB,CAClB,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAC3C,YAAY,EACZ,6BAA6B,CAC9B,CAAC;AAEF;;GAEG;AACH,MAAM,CAAN,IAAY,SAYX;AAZD,WAAY,SAAS;IACnB,0BAA0B;IAC1B,2CAA8B,CAAA;IAC9B,8BAAiB,CAAA;IACjB,oDAAuC,CAAA;IACvC,qDAAwC,CAAA;IACxC,qDAAwC,CAAA;IACxC,qDAAwC,CAAA;IACxC,mBAAmB;IACnB,8DAAiD,CAAA;IACjD,0DAA6C,CAAA;IAC7C,wDAA2C,CAAA;AAC7C,CAAC,EA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BAAkB,EAAE;QACjC,GAAG,SAAS,CAAC,iBAAiB,EAAE;KACjC,CAAC,CACH;CACF,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { nonempty, array, enums, literal, object } from '@metamask/superstruct';\nimport { definePattern } from '@metamask/utils';\nimport type { Hex } from '@metamask/utils';\n\nimport {\n CaipChainIdStruct,\n EthAccountType,\n KeyringAccountStruct,\n} from '../api';\nimport { EthScope } from './constants';\n\nconst ETH_BYTES_REGEX = /^0x[0-9a-f]*$/iu;\nexport const EthBytesStruct = definePattern('EthBytes', ETH_BYTES_REGEX);\n// Stricter struct that uses `Hex` as final type.\nexport const EthBytesStrictStruct = definePattern<Hex>(\n 'EthBytesStrict',\n ETH_BYTES_REGEX,\n);\n\nconst ETH_ADDRESS_REGEX = /^0x[0-9a-f]{40}$/iu;\nexport const EthAddressStruct = definePattern('EthAddress', ETH_ADDRESS_REGEX);\n// Stricter struct that uses `Hex` as final type.\nexport const EthAddressStrictStruct = definePattern<Hex>(\n 'EthAddressStrict',\n ETH_ADDRESS_REGEX,\n);\n\nexport const EthUint256Struct = definePattern(\n 'EthUint256',\n /^0x([1-9a-f][0-9a-f]*|0)$/iu,\n);\n\n/**\n * Supported Ethereum methods.\n */\nexport enum EthMethod {\n // General signing methods\n PersonalSign = 'personal_sign',\n Sign = 'eth_sign',\n SignTransaction = 'eth_signTransaction',\n SignTypedDataV1 = 'eth_signTypedData_v1',\n SignTypedDataV3 = 'eth_signTypedData_v3',\n SignTypedDataV4 = 'eth_signTypedData_v4',\n // ERC-4337 methods\n PrepareUserOperation = 'eth_prepareUserOperation',\n PatchUserOperation = 'eth_patchUserOperation',\n SignUserOperation = 'eth_signUserOperation',\n}\n\nexport const EthEoaAccountStruct = object({\n ...KeyringAccountStruct.schema,\n\n /**\n * Account address.\n */\n address: EthAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${EthAccountType.Eoa}`),\n\n /**\n * Account scopes (must be ['eip155:0']).\n */\n scopes: nonempty(array(literal(EthScope.Eoa))),\n\n /**\n * Account supported methods.\n */\n methods: array(\n enums([\n `${EthMethod.PersonalSign}`,\n `${EthMethod.Sign}`,\n `${EthMethod.SignTransaction}`,\n `${EthMethod.SignTypedDataV1}`,\n `${EthMethod.SignTypedDataV3}`,\n `${EthMethod.SignTypedDataV4}`,\n ]),\n ),\n});\n\nexport type EthEoaAccount = Infer<typeof EthEoaAccountStruct>;\n\nexport const EthErc4337AccountStruct = object({\n ...KeyringAccountStruct.schema,\n\n /**\n * Account address.\n */\n address: EthAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${EthAccountType.Erc4337}`),\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(\n enums([\n `${EthMethod.PersonalSign}`,\n `${EthMethod.Sign}`,\n `${EthMethod.SignTypedDataV1}`,\n `${EthMethod.SignTypedDataV3}`,\n `${EthMethod.SignTypedDataV4}`,\n `${EthMethod.PrepareUserOperation}`,\n `${EthMethod.PatchUserOperation}`,\n `${EthMethod.SignUserOperation}`,\n ]),\n ),\n});\n\nexport type EthErc4337Account = Infer<typeof EthErc4337AccountStruct>;\n"]}
|
package/dist/events.cjs
CHANGED
|
@@ -22,9 +22,9 @@ var KeyringEvent;
|
|
|
22
22
|
KeyringEvent["AccountAssetListUpdated"] = "notify:accountAssetListUpdated";
|
|
23
23
|
KeyringEvent["AccountTransactionsUpdated"] = "notify:accountTransactionsUpdated";
|
|
24
24
|
})(KeyringEvent || (exports.KeyringEvent = KeyringEvent = {}));
|
|
25
|
-
exports.AccountCreatedEventStruct = (0,
|
|
25
|
+
exports.AccountCreatedEventStruct = (0, superstruct_1.object)({
|
|
26
26
|
method: (0, superstruct_1.literal)(`${KeyringEvent.AccountCreated}`),
|
|
27
|
-
params: (0,
|
|
27
|
+
params: (0, superstruct_1.object)({
|
|
28
28
|
/**
|
|
29
29
|
* New account object.
|
|
30
30
|
*/
|
|
@@ -36,13 +36,13 @@ exports.AccountCreatedEventStruct = (0, keyring_utils_1.object)({
|
|
|
36
36
|
* client to decide whether to use it. The keyring won't be informed if the
|
|
37
37
|
* client decides to use a different name.
|
|
38
38
|
*/
|
|
39
|
-
accountNameSuggestion: (0,
|
|
39
|
+
accountNameSuggestion: (0, superstruct_1.exactOptional)((0, superstruct_1.string)()),
|
|
40
40
|
/**
|
|
41
41
|
* Instructs MetaMask to display the add account confirmation dialog in the UI.
|
|
42
42
|
*
|
|
43
43
|
* **Note:** This is not guaranteed to be honored by the MetaMask client.
|
|
44
44
|
*/
|
|
45
|
-
displayConfirmation: (0,
|
|
45
|
+
displayConfirmation: (0, superstruct_1.exactOptional)((0, superstruct_1.boolean)()),
|
|
46
46
|
/**
|
|
47
47
|
* Instructs MetaMask to display the name confirmation dialog in the UI.
|
|
48
48
|
* Otherwise, the account will be added with the suggested name, if it's not
|
|
@@ -51,34 +51,34 @@ exports.AccountCreatedEventStruct = (0, keyring_utils_1.object)({
|
|
|
51
51
|
*
|
|
52
52
|
* **Note:** This is not guaranteed to be honored by the MetaMask client.
|
|
53
53
|
*/
|
|
54
|
-
displayAccountNameSuggestion: (0,
|
|
54
|
+
displayAccountNameSuggestion: (0, superstruct_1.exactOptional)((0, superstruct_1.boolean)()),
|
|
55
55
|
/**
|
|
56
56
|
* Metamask internal options.
|
|
57
57
|
*/
|
|
58
58
|
...api_1.MetaMaskOptionsStruct.schema,
|
|
59
59
|
}),
|
|
60
60
|
});
|
|
61
|
-
exports.AccountUpdatedEventStruct = (0,
|
|
61
|
+
exports.AccountUpdatedEventStruct = (0, superstruct_1.object)({
|
|
62
62
|
method: (0, superstruct_1.literal)(`${KeyringEvent.AccountUpdated}`),
|
|
63
|
-
params: (0,
|
|
63
|
+
params: (0, superstruct_1.object)({
|
|
64
64
|
/**
|
|
65
65
|
* Updated account object.
|
|
66
66
|
*/
|
|
67
67
|
account: api_1.KeyringAccountStruct,
|
|
68
68
|
}),
|
|
69
69
|
});
|
|
70
|
-
exports.AccountDeletedEventStruct = (0,
|
|
70
|
+
exports.AccountDeletedEventStruct = (0, superstruct_1.object)({
|
|
71
71
|
method: (0, superstruct_1.literal)(`${KeyringEvent.AccountDeleted}`),
|
|
72
|
-
params: (0,
|
|
72
|
+
params: (0, superstruct_1.object)({
|
|
73
73
|
/**
|
|
74
74
|
* Deleted account ID.
|
|
75
75
|
*/
|
|
76
76
|
id: keyring_utils_1.UuidStruct,
|
|
77
77
|
}),
|
|
78
78
|
});
|
|
79
|
-
exports.RequestApprovedEventStruct = (0,
|
|
79
|
+
exports.RequestApprovedEventStruct = (0, superstruct_1.object)({
|
|
80
80
|
method: (0, superstruct_1.literal)(`${KeyringEvent.RequestApproved}`),
|
|
81
|
-
params: (0,
|
|
81
|
+
params: (0, superstruct_1.object)({
|
|
82
82
|
/**
|
|
83
83
|
* Request ID.
|
|
84
84
|
*/
|
|
@@ -89,9 +89,9 @@ exports.RequestApprovedEventStruct = (0, keyring_utils_1.object)({
|
|
|
89
89
|
result: utils_1.JsonStruct,
|
|
90
90
|
}),
|
|
91
91
|
});
|
|
92
|
-
exports.RequestRejectedEventStruct = (0,
|
|
92
|
+
exports.RequestRejectedEventStruct = (0, superstruct_1.object)({
|
|
93
93
|
method: (0, superstruct_1.literal)(`${KeyringEvent.RequestRejected}`),
|
|
94
|
-
params: (0,
|
|
94
|
+
params: (0, superstruct_1.object)({
|
|
95
95
|
/**
|
|
96
96
|
* Request ID.
|
|
97
97
|
*/
|
|
@@ -107,9 +107,9 @@ exports.RequestRejectedEventStruct = (0, keyring_utils_1.object)({
|
|
|
107
107
|
*
|
|
108
108
|
* The Snap can choose to emit this event for multiple accounts at once.
|
|
109
109
|
*/
|
|
110
|
-
exports.AccountBalancesUpdatedEventStruct = (0,
|
|
110
|
+
exports.AccountBalancesUpdatedEventStruct = (0, superstruct_1.object)({
|
|
111
111
|
method: (0, superstruct_1.literal)(`${KeyringEvent.AccountBalancesUpdated}`),
|
|
112
|
-
params: (0,
|
|
112
|
+
params: (0, superstruct_1.object)({
|
|
113
113
|
/**
|
|
114
114
|
* Balances updates of accounts owned by the Snap.
|
|
115
115
|
*/
|
|
@@ -140,9 +140,9 @@ exports.AccountBalancesUpdatedEventStruct = (0, keyring_utils_1.object)({
|
|
|
140
140
|
*
|
|
141
141
|
* The Snap can choose to emit this event for multiple accounts at once.
|
|
142
142
|
*/
|
|
143
|
-
exports.AccountTransactionsUpdatedEventStruct = (0,
|
|
143
|
+
exports.AccountTransactionsUpdatedEventStruct = (0, superstruct_1.object)({
|
|
144
144
|
method: (0, superstruct_1.literal)(`${KeyringEvent.AccountTransactionsUpdated}`),
|
|
145
|
-
params: (0,
|
|
145
|
+
params: (0, superstruct_1.object)({
|
|
146
146
|
/**
|
|
147
147
|
* Transactions updates of accounts owned by the Snap.
|
|
148
148
|
*/
|
|
@@ -164,9 +164,9 @@ exports.AccountTransactionsUpdatedEventStruct = (0, keyring_utils_1.object)({
|
|
|
164
164
|
*
|
|
165
165
|
* The Snap can choose to emit this event for multiple accounts at once.
|
|
166
166
|
*/
|
|
167
|
-
exports.AccountAssetListUpdatedEventStruct = (0,
|
|
167
|
+
exports.AccountAssetListUpdatedEventStruct = (0, superstruct_1.object)({
|
|
168
168
|
method: (0, superstruct_1.literal)(`${KeyringEvent.AccountAssetListUpdated}`),
|
|
169
|
-
params: (0,
|
|
169
|
+
params: (0, superstruct_1.object)({
|
|
170
170
|
/**
|
|
171
171
|
* Asset list update of accounts owned by the Snap.
|
|
172
172
|
*/
|
|
@@ -178,7 +178,7 @@ exports.AccountAssetListUpdatedEventStruct = (0, keyring_utils_1.object)({
|
|
|
178
178
|
/**
|
|
179
179
|
* Asset list changes for that account.
|
|
180
180
|
*/
|
|
181
|
-
(0,
|
|
181
|
+
(0, superstruct_1.object)({
|
|
182
182
|
/**
|
|
183
183
|
* New assets detected.
|
|
184
184
|
*/
|
package/dist/events.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-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YAAY,EAAE,IAAA,oBAAM;QAClB;;WAEG;QACH,+BAAe;QAEf;;WAEG;QACH,IAAA,mBAAK,EAAC,uBAAiB,CAAC,CACzB;KACF,CAAC;CACH,CAAC,CAAC;AAOH;;;;;;GAMG;AACU,QAAA,kCAAkC,GAAG,IAAA,sBAAM,EAAC;IACvD,MAAM,EAAE,IAAA,qBAAO,EAAC,GAAG,YAAY,CAAC,uBAAuB,EAAE,CAAC;IAC1D,MAAM,EAAE,IAAA,sBAAM,EAAC;QACb;;WAEG;QACH,MAAM,EAAE,IAAA,oBAAM;QACZ;;WAEG;QACH,+BAAe;QAEf;;WAEG;QACH,IAAA,sBAAM,EAAC;YACL;;eAEG;YACH,KAAK,EAAE,IAAA,mBAAK,EAAC,+BAAuB,CAAC;YAErC;;eAEG;YACH,OAAO,EAAE,IAAA,mBAAK,EAAC,+BAAuB,CAAC;SACxC,CAAC,CACH;KACF,CAAC;CACH,CAAC,CAAC","sourcesContent":["import {\n exactOptional,\n object,\n UuidStruct,\n AccountIdStruct,\n} from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport { array, boolean, literal, record, string } from '@metamask/superstruct';\nimport {\n CaipAssetTypeStruct,\n CaipAssetTypeOrIdStruct,\n JsonStruct,\n} from '@metamask/utils';\n\nimport {\n FungibleAssetAmountStruct,\n KeyringAccountStruct,\n TransactionStruct,\n MetaMaskOptionsStruct,\n} from './api';\n\n/**\n * Supported keyring events.\n */\nexport enum KeyringEvent {\n // Account events\n AccountCreated = 'notify:accountCreated',\n AccountUpdated = 'notify:accountUpdated',\n AccountDeleted = 'notify:accountDeleted',\n\n // Request events\n RequestApproved = 'notify:requestApproved',\n RequestRejected = 'notify:requestRejected',\n\n // Assets related events\n AccountBalancesUpdated = 'notify:accountBalancesUpdated',\n AccountAssetListUpdated = 'notify:accountAssetListUpdated',\n AccountTransactionsUpdated = 'notify:accountTransactionsUpdated',\n}\n\nexport const AccountCreatedEventStruct = object({\n method: literal(`${KeyringEvent.AccountCreated}`),\n params: object({\n /**\n * New account object.\n */\n account: KeyringAccountStruct,\n\n /**\n * Account name suggestion provided to the MetaMask client.\n *\n * The keyring can suggest a name for the account, but it's up to the\n * client to decide whether to use it. The keyring won't be informed if the\n * client decides to use a different name.\n */\n accountNameSuggestion: exactOptional(string()),\n\n /**\n * Instructs MetaMask to display the add account confirmation dialog in the UI.\n *\n * **Note:** This is not guaranteed to be honored by the MetaMask client.\n */\n displayConfirmation: exactOptional(boolean()),\n\n /**\n * Instructs MetaMask to display the name confirmation dialog in the UI.\n * Otherwise, the account will be added with the suggested name, if it's not\n * already in use; if it is, a suffix will be appended to the name to make it\n * unique.\n *\n * **Note:** This is not guaranteed to be honored by the MetaMask client.\n */\n displayAccountNameSuggestion: exactOptional(boolean()),\n\n /**\n * Metamask internal options.\n */\n ...MetaMaskOptionsStruct.schema,\n }),\n});\nexport type AccountCreatedEvent = Infer<typeof AccountCreatedEventStruct>;\nexport type AccountCreatedEventPayload = AccountCreatedEvent['params'];\n\nexport const AccountUpdatedEventStruct = object({\n method: literal(`${KeyringEvent.AccountUpdated}`),\n params: object({\n /**\n * Updated account object.\n */\n account: KeyringAccountStruct,\n }),\n});\nexport type AccountUpdatedEvent = Infer<typeof AccountUpdatedEventStruct>;\nexport type AccountUpdatedEventPayload = AccountUpdatedEvent['params'];\n\nexport const AccountDeletedEventStruct = object({\n method: literal(`${KeyringEvent.AccountDeleted}`),\n params: object({\n /**\n * Deleted account ID.\n */\n id: UuidStruct,\n }),\n});\nexport type AccountDeletedEvent = Infer<typeof AccountDeletedEventStruct>;\nexport type AccountDeletedEventPayload = AccountDeletedEvent['params'];\n\nexport const RequestApprovedEventStruct = object({\n method: literal(`${KeyringEvent.RequestApproved}`),\n params: object({\n /**\n * Request ID.\n */\n id: UuidStruct,\n\n /**\n * Request result.\n */\n result: JsonStruct,\n }),\n});\nexport type RequestApprovedEvent = Infer<typeof RequestApprovedEventStruct>;\nexport type RequestApprovedEventPayload = RequestApprovedEvent['params'];\n\nexport const RequestRejectedEventStruct = object({\n method: literal(`${KeyringEvent.RequestRejected}`),\n params: object({\n /**\n * Request ID.\n */\n id: UuidStruct,\n }),\n});\nexport type RequestRejectedEvent = Infer<typeof RequestRejectedEventStruct>;\nexport type RequestRejectedEventPayload = RequestRejectedEvent['params'];\n\n// Assets related events:\n// -----------------------------------------------------------------------------------------------\n\n/**\n * Event emitted when the balances of an account are updated.\n *\n * Only changes are reported.\n *\n * The Snap can choose to emit this event for multiple accounts at once.\n */\nexport const AccountBalancesUpdatedEventStruct = object({\n method: literal(`${KeyringEvent.AccountBalancesUpdated}`),\n params: object({\n /**\n * Balances updates of accounts owned by the Snap.\n */\n balances: record(\n /**\n * Account ID.\n */\n AccountIdStruct,\n\n /**\n * Mapping of each owned assets and their respective balances for that account.\n */\n record(\n /**\n * Asset type (CAIP-19).\n */\n CaipAssetTypeStruct,\n\n /**\n * Balance information for a given asset.\n */\n FungibleAssetAmountStruct,\n ),\n ),\n }),\n});\nexport type AccountBalancesUpdatedEvent = Infer<\n typeof AccountBalancesUpdatedEventStruct\n>;\nexport type AccountBalancesUpdatedEventPayload =\n AccountBalancesUpdatedEvent['params'];\n\n/**\n * Event emitted when the transactions of an account are updated (added or\n * changed).\n *\n * Only changes are reported.\n *\n * The Snap can choose to emit this event for multiple accounts at once.\n */\nexport const AccountTransactionsUpdatedEventStruct = object({\n method: literal(`${KeyringEvent.AccountTransactionsUpdated}`),\n params: object({\n /**\n * Transactions updates of accounts owned by the Snap.\n */\n transactions: record(\n /**\n * Account ID.\n */\n AccountIdStruct,\n\n /**\n * List of updated transactions for that account.\n */\n array(TransactionStruct),\n ),\n }),\n});\nexport type AccountTransactionsUpdatedEvent = Infer<\n typeof AccountTransactionsUpdatedEventStruct\n>;\nexport type AccountTransactionsUpdatedEventPayload =\n AccountTransactionsUpdatedEvent['params'];\n\n/**\n * Event emitted when the assets of an account are updated.\n *\n * Only changes are reported.\n *\n * The Snap can choose to emit this event for multiple accounts at once.\n */\nexport const AccountAssetListUpdatedEventStruct = object({\n method: literal(`${KeyringEvent.AccountAssetListUpdated}`),\n params: object({\n /**\n * Asset list update of accounts owned by the Snap.\n */\n assets: record(\n /**\n * Account ID.\n */\n AccountIdStruct,\n\n /**\n * Asset list changes for that account.\n */\n object({\n /**\n * New assets detected.\n */\n added: array(CaipAssetTypeOrIdStruct),\n\n /**\n * Assets no longer available on that account.\n */\n removed: array(CaipAssetTypeOrIdStruct),\n }),\n ),\n }),\n});\nexport type AccountAssetListUpdatedEvent = Infer<\n typeof AccountAssetListUpdatedEventStruct\n>;\nexport type AccountAssetListUpdatedEventPayload =\n AccountAssetListUpdatedEvent['params'];\n\n/**\n * Keyring events.\n */\n// For some reason, eslint sometimes infer one of those members as `any`...\ntype KeyringEvents =\n | AccountCreatedEvent\n | AccountUpdatedEvent\n | AccountDeletedEvent\n | AccountAssetListUpdatedEvent\n | AccountBalancesUpdatedEvent\n | AccountTransactionsUpdatedEvent\n | RequestApprovedEvent\n | RequestRejectedEvent;\n\n/**\n * Extract the payload for a given `KeyringEvent` event.\n */\nexport type KeyringEventPayload<Event extends KeyringEvent> = Extract<\n KeyringEvents,\n // We need to use a literal string here, since that is what `KeyringEvents`\n // is using (probably because of `superstruct`.\n { method: `${Event}` }\n>['params'];\n"]}
|
|
1
|
+
{"version":3,"file":"events.cjs","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":";;;AAAA,2DAAsE;AAEtE,uDAQ+B;AAC/B,2CAIyB;AAEzB,yCAKe;AAEf;;GAEG;AACH,IAAY,YAcX;AAdD,WAAY,YAAY;IACtB,iBAAiB;IACjB,wDAAwC,CAAA;IACxC,wDAAwC,CAAA;IACxC,wDAAwC,CAAA;IAExC,iBAAiB;IACjB,0DAA0C,CAAA;IAC1C,0DAA0C,CAAA;IAE1C,wBAAwB;IACxB,wEAAwD,CAAA;IACxD,0EAA0D,CAAA;IAC1D,gFAAgE,CAAA;AAClE,CAAC,EAdW,YAAY,4BAAZ,YAAY,Q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L;;eAEG;YACH,KAAK,EAAE,IAAA,mBAAK,EAAC,+BAAuB,CAAC;YAErC;;eAEG;YACH,OAAO,EAAE,IAAA,mBAAK,EAAC,+BAAuB,CAAC;SACxC,CAAC,CACH;KACF,CAAC;CACH,CAAC,CAAC","sourcesContent":["import { UuidStruct, AccountIdStruct } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport {\n array,\n boolean,\n literal,\n record,\n string,\n object,\n exactOptional,\n} from '@metamask/superstruct';\nimport {\n CaipAssetTypeStruct,\n CaipAssetTypeOrIdStruct,\n JsonStruct,\n} from '@metamask/utils';\n\nimport {\n FungibleAssetAmountStruct,\n KeyringAccountStruct,\n TransactionStruct,\n MetaMaskOptionsStruct,\n} from './api';\n\n/**\n * Supported keyring events.\n */\nexport enum KeyringEvent {\n // Account events\n AccountCreated = 'notify:accountCreated',\n AccountUpdated = 'notify:accountUpdated',\n AccountDeleted = 'notify:accountDeleted',\n\n // Request events\n RequestApproved = 'notify:requestApproved',\n RequestRejected = 'notify:requestRejected',\n\n // Assets related events\n AccountBalancesUpdated = 'notify:accountBalancesUpdated',\n AccountAssetListUpdated = 'notify:accountAssetListUpdated',\n AccountTransactionsUpdated = 'notify:accountTransactionsUpdated',\n}\n\nexport const AccountCreatedEventStruct = object({\n method: literal(`${KeyringEvent.AccountCreated}`),\n params: object({\n /**\n * New account object.\n */\n account: KeyringAccountStruct,\n\n /**\n * Account name suggestion provided to the MetaMask client.\n *\n * The keyring can suggest a name for the account, but it's up to the\n * client to decide whether to use it. The keyring won't be informed if the\n * client decides to use a different name.\n */\n accountNameSuggestion: exactOptional(string()),\n\n /**\n * Instructs MetaMask to display the add account confirmation dialog in the UI.\n *\n * **Note:** This is not guaranteed to be honored by the MetaMask client.\n */\n displayConfirmation: exactOptional(boolean()),\n\n /**\n * Instructs MetaMask to display the name confirmation dialog in the UI.\n * Otherwise, the account will be added with the suggested name, if it's not\n * already in use; if it is, a suffix will be appended to the name to make it\n * unique.\n *\n * **Note:** This is not guaranteed to be honored by the MetaMask client.\n */\n displayAccountNameSuggestion: exactOptional(boolean()),\n\n /**\n * Metamask internal options.\n */\n ...MetaMaskOptionsStruct.schema,\n }),\n});\nexport type AccountCreatedEvent = Infer<typeof AccountCreatedEventStruct>;\nexport type AccountCreatedEventPayload = AccountCreatedEvent['params'];\n\nexport const AccountUpdatedEventStruct = object({\n method: literal(`${KeyringEvent.AccountUpdated}`),\n params: object({\n /**\n * Updated account object.\n */\n account: KeyringAccountStruct,\n }),\n});\nexport type AccountUpdatedEvent = Infer<typeof AccountUpdatedEventStruct>;\nexport type AccountUpdatedEventPayload = AccountUpdatedEvent['params'];\n\nexport const AccountDeletedEventStruct = object({\n method: literal(`${KeyringEvent.AccountDeleted}`),\n params: object({\n /**\n * Deleted account ID.\n */\n id: UuidStruct,\n }),\n});\nexport type AccountDeletedEvent = Infer<typeof AccountDeletedEventStruct>;\nexport type AccountDeletedEventPayload = AccountDeletedEvent['params'];\n\nexport const RequestApprovedEventStruct = object({\n method: literal(`${KeyringEvent.RequestApproved}`),\n params: object({\n /**\n * Request ID.\n */\n id: UuidStruct,\n\n /**\n * Request result.\n */\n result: JsonStruct,\n }),\n});\nexport type RequestApprovedEvent = Infer<typeof RequestApprovedEventStruct>;\nexport type RequestApprovedEventPayload = RequestApprovedEvent['params'];\n\nexport const RequestRejectedEventStruct = object({\n method: literal(`${KeyringEvent.RequestRejected}`),\n params: object({\n /**\n * Request ID.\n */\n id: UuidStruct,\n }),\n});\nexport type RequestRejectedEvent = Infer<typeof RequestRejectedEventStruct>;\nexport type RequestRejectedEventPayload = RequestRejectedEvent['params'];\n\n// Assets related events:\n// -----------------------------------------------------------------------------------------------\n\n/**\n * Event emitted when the balances of an account are updated.\n *\n * Only changes are reported.\n *\n * The Snap can choose to emit this event for multiple accounts at once.\n */\nexport const AccountBalancesUpdatedEventStruct = object({\n method: literal(`${KeyringEvent.AccountBalancesUpdated}`),\n params: object({\n /**\n * Balances updates of accounts owned by the Snap.\n */\n balances: record(\n /**\n * Account ID.\n */\n AccountIdStruct,\n\n /**\n * Mapping of each owned assets and their respective balances for that account.\n */\n record(\n /**\n * Asset type (CAIP-19).\n */\n CaipAssetTypeStruct,\n\n /**\n * Balance information for a given asset.\n */\n FungibleAssetAmountStruct,\n ),\n ),\n }),\n});\nexport type AccountBalancesUpdatedEvent = Infer<\n typeof AccountBalancesUpdatedEventStruct\n>;\nexport type AccountBalancesUpdatedEventPayload =\n AccountBalancesUpdatedEvent['params'];\n\n/**\n * Event emitted when the transactions of an account are updated (added or\n * changed).\n *\n * Only changes are reported.\n *\n * The Snap can choose to emit this event for multiple accounts at once.\n */\nexport const AccountTransactionsUpdatedEventStruct = object({\n method: literal(`${KeyringEvent.AccountTransactionsUpdated}`),\n params: object({\n /**\n * Transactions updates of accounts owned by the Snap.\n */\n transactions: record(\n /**\n * Account ID.\n */\n AccountIdStruct,\n\n /**\n * List of updated transactions for that account.\n */\n array(TransactionStruct),\n ),\n }),\n});\nexport type AccountTransactionsUpdatedEvent = Infer<\n typeof AccountTransactionsUpdatedEventStruct\n>;\nexport type AccountTransactionsUpdatedEventPayload =\n AccountTransactionsUpdatedEvent['params'];\n\n/**\n * Event emitted when the assets of an account are updated.\n *\n * Only changes are reported.\n *\n * The Snap can choose to emit this event for multiple accounts at once.\n */\nexport const AccountAssetListUpdatedEventStruct = object({\n method: literal(`${KeyringEvent.AccountAssetListUpdated}`),\n params: object({\n /**\n * Asset list update of accounts owned by the Snap.\n */\n assets: record(\n /**\n * Account ID.\n */\n AccountIdStruct,\n\n /**\n * Asset list changes for that account.\n */\n object({\n /**\n * New assets detected.\n */\n added: array(CaipAssetTypeOrIdStruct),\n\n /**\n * Assets no longer available on that account.\n */\n removed: array(CaipAssetTypeOrIdStruct),\n }),\n ),\n }),\n});\nexport type AccountAssetListUpdatedEvent = Infer<\n typeof AccountAssetListUpdatedEventStruct\n>;\nexport type AccountAssetListUpdatedEventPayload =\n AccountAssetListUpdatedEvent['params'];\n\n/**\n * Keyring events.\n */\n// For some reason, eslint sometimes infer one of those members as `any`...\ntype KeyringEvents =\n | AccountCreatedEvent\n | AccountUpdatedEvent\n | AccountDeletedEvent\n | AccountAssetListUpdatedEvent\n | AccountBalancesUpdatedEvent\n | AccountTransactionsUpdatedEvent\n | RequestApprovedEvent\n | RequestRejectedEvent;\n\n/**\n * Extract the payload for a given `KeyringEvent` event.\n */\nexport type KeyringEventPayload<Event extends KeyringEvent> = Extract<\n KeyringEvents,\n // We need to use a literal string here, since that is what `KeyringEvents`\n // is using (probably because of `superstruct`.\n { method: `${Event}` }\n>['params'];\n"]}
|
package/dist/events.d.cts
CHANGED
|
@@ -72,7 +72,7 @@ export declare const AccountCreatedEventStruct: import("@metamask/superstruct").
|
|
|
72
72
|
displayConfirmation?: boolean;
|
|
73
73
|
displayAccountNameSuggestion?: boolean;
|
|
74
74
|
}, {
|
|
75
|
-
metamask: import("@metamask/superstruct").
|
|
75
|
+
metamask: import("@metamask/superstruct").ExactOptionalStruct<{
|
|
76
76
|
correlationId: string;
|
|
77
77
|
}, {
|
|
78
78
|
correlationId: import("@metamask/superstruct").Struct<string, null>;
|
|
@@ -137,13 +137,13 @@ export declare const AccountCreatedEventStruct: import("@metamask/superstruct").
|
|
|
137
137
|
* client to decide whether to use it. The keyring won't be informed if the
|
|
138
138
|
* client decides to use a different name.
|
|
139
139
|
*/
|
|
140
|
-
accountNameSuggestion: import("@metamask/superstruct").
|
|
140
|
+
accountNameSuggestion: import("@metamask/superstruct").ExactOptionalStruct<string, null>;
|
|
141
141
|
/**
|
|
142
142
|
* Instructs MetaMask to display the add account confirmation dialog in the UI.
|
|
143
143
|
*
|
|
144
144
|
* **Note:** This is not guaranteed to be honored by the MetaMask client.
|
|
145
145
|
*/
|
|
146
|
-
displayConfirmation: import("@metamask/superstruct").
|
|
146
|
+
displayConfirmation: import("@metamask/superstruct").ExactOptionalStruct<boolean, null>;
|
|
147
147
|
/**
|
|
148
148
|
* Instructs MetaMask to display the name confirmation dialog in the UI.
|
|
149
149
|
* Otherwise, the account will be added with the suggested name, if it's not
|
|
@@ -152,7 +152,7 @@ export declare const AccountCreatedEventStruct: import("@metamask/superstruct").
|
|
|
152
152
|
*
|
|
153
153
|
* **Note:** This is not guaranteed to be honored by the MetaMask client.
|
|
154
154
|
*/
|
|
155
|
-
displayAccountNameSuggestion: import("@metamask/superstruct").
|
|
155
|
+
displayAccountNameSuggestion: import("@metamask/superstruct").ExactOptionalStruct<boolean, null>;
|
|
156
156
|
}>;
|
|
157
157
|
}>;
|
|
158
158
|
export type AccountCreatedEvent = Infer<typeof AccountCreatedEventStruct>;
|
package/dist/events.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.cts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"events.d.cts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAuBnD;;GAEG;AACH,oBAAY,YAAY;IAEtB,cAAc,0BAA0B;IACxC,cAAc,0BAA0B;IACxC,cAAc,0BAA0B;IAGxC,eAAe,2BAA2B;IAC1C,eAAe,2BAA2B;IAG1C,sBAAsB,kCAAkC;IACxD,uBAAuB,mCAAmC;IAC1D,0BAA0B,sCAAsC;CACjE;AAED,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAGlC;;WAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAGH;;;;;;WAMG;;QAGH;;;;WAIG;;QAGH;;;;;;;WAOG;;;EAQL,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAC1E,MAAM,MAAM,0BAA0B,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAC;AAEv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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAG9C;;WAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAaL,CAAC;AACH,MAAM,MAAM,+BAA+B,GAAG,KAAK,CACjD,OAAO,qCAAqC,CAC7C,CAAC;AACF,MAAM,MAAM,sCAAsC,GAChD,+BAA+B,CAAC,QAAQ,CAAC,CAAC;AAE5C;;;;;;GAMG;AACH,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;QAG3C;;WAEG;;;;;;EAuBL,CAAC;AACH,MAAM,MAAM,4BAA4B,GAAG,KAAK,CAC9C,OAAO,kCAAkC,CAC1C,CAAC;AACF,MAAM,MAAM,mCAAmC,GAC7C,4BAA4B,CAAC,QAAQ,CAAC,CAAC;AAEzC;;GAEG;AAEH,KAAK,aAAa,GACd,mBAAmB,GACnB,mBAAmB,GACnB,mBAAmB,GACnB,4BAA4B,GAC5B,2BAA2B,GAC3B,+BAA+B,GAC/B,oBAAoB,GACpB,oBAAoB,CAAC;AAEzB;;GAEG;AACH,MAAM,MAAM,mBAAmB,CAAC,KAAK,SAAS,YAAY,IAAI,OAAO,CACnE,aAAa,EAGb;IAAE,MAAM,EAAE,GAAG,KAAK,EAAE,CAAA;CAAE,CACvB,CAAC,QAAQ,CAAC,CAAC"}
|
package/dist/events.d.mts
CHANGED
|
@@ -72,7 +72,7 @@ export declare const AccountCreatedEventStruct: import("@metamask/superstruct").
|
|
|
72
72
|
displayConfirmation?: boolean;
|
|
73
73
|
displayAccountNameSuggestion?: boolean;
|
|
74
74
|
}, {
|
|
75
|
-
metamask: import("@metamask/superstruct").
|
|
75
|
+
metamask: import("@metamask/superstruct").ExactOptionalStruct<{
|
|
76
76
|
correlationId: string;
|
|
77
77
|
}, {
|
|
78
78
|
correlationId: import("@metamask/superstruct").Struct<string, null>;
|
|
@@ -137,13 +137,13 @@ export declare const AccountCreatedEventStruct: import("@metamask/superstruct").
|
|
|
137
137
|
* client to decide whether to use it. The keyring won't be informed if the
|
|
138
138
|
* client decides to use a different name.
|
|
139
139
|
*/
|
|
140
|
-
accountNameSuggestion: import("@metamask/superstruct").
|
|
140
|
+
accountNameSuggestion: import("@metamask/superstruct").ExactOptionalStruct<string, null>;
|
|
141
141
|
/**
|
|
142
142
|
* Instructs MetaMask to display the add account confirmation dialog in the UI.
|
|
143
143
|
*
|
|
144
144
|
* **Note:** This is not guaranteed to be honored by the MetaMask client.
|
|
145
145
|
*/
|
|
146
|
-
displayConfirmation: import("@metamask/superstruct").
|
|
146
|
+
displayConfirmation: import("@metamask/superstruct").ExactOptionalStruct<boolean, null>;
|
|
147
147
|
/**
|
|
148
148
|
* Instructs MetaMask to display the name confirmation dialog in the UI.
|
|
149
149
|
* Otherwise, the account will be added with the suggested name, if it's not
|
|
@@ -152,7 +152,7 @@ export declare const AccountCreatedEventStruct: import("@metamask/superstruct").
|
|
|
152
152
|
*
|
|
153
153
|
* **Note:** This is not guaranteed to be honored by the MetaMask client.
|
|
154
154
|
*/
|
|
155
|
-
displayAccountNameSuggestion: import("@metamask/superstruct").
|
|
155
|
+
displayAccountNameSuggestion: import("@metamask/superstruct").ExactOptionalStruct<boolean, null>;
|
|
156
156
|
}>;
|
|
157
157
|
}>;
|
|
158
158
|
export type AccountCreatedEvent = Infer<typeof AccountCreatedEventStruct>;
|
package/dist/events.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.mts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"events.d.mts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAuBnD;;GAEG;AACH,oBAAY,YAAY;IAEtB,cAAc,0BAA0B;IACxC,cAAc,0BAA0B;IACxC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BAAoB,GACpB,oBAAoB,CAAC;AAEzB;;GAEG;AACH,MAAM,MAAM,mBAAmB,CAAC,KAAK,SAAS,YAAY,IAAI,OAAO,CACnE,aAAa,EAGb;IAAE,MAAM,EAAE,GAAG,KAAK,EAAE,CAAA;CAAE,CACvB,CAAC,QAAQ,CAAC,CAAC"}
|
package/dist/events.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { array, boolean, literal, record, string } from "@metamask/superstruct";
|
|
1
|
+
import { UuidStruct, AccountIdStruct } from "@metamask/keyring-utils";
|
|
2
|
+
import { array, boolean, literal, record, string, object, exactOptional } from "@metamask/superstruct";
|
|
3
3
|
import { CaipAssetTypeStruct, CaipAssetTypeOrIdStruct, JsonStruct } from "@metamask/utils";
|
|
4
4
|
import { FungibleAssetAmountStruct, KeyringAccountStruct, TransactionStruct, MetaMaskOptionsStruct } from "./api/index.mjs";
|
|
5
5
|
/**
|
package/dist/events.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.mjs","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,MAAM,EACN,UAAU,EACV,eAAe,EAChB,gCAAgC;AAEjC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,8BAA8B;AAChF,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,UAAU,EACX,wBAAwB;AAEzB,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACtB,wBAAc;AAEf;;GAEG;AACH,MAAM,CAAN,IAAY,YAcX;AAdD,WAAY,YAAY;IACtB,iBAAiB;IACjB,wDAAwC,CAAA;IACxC,wDAAwC,CAAA;IACxC,wDAAwC,CAAA;IAExC,iBAAiB;IACjB,0DAA0C,CAAA;IAC1C,0DAA0C,CAAA;IAE1C,wBAAwB;IACxB,wEAA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KAAK,CAAC,uBAAuB,CAAC;SACxC,CAAC,CACH;KACF,CAAC;CACH,CAAC,CAAC","sourcesContent":["import {\n exactOptional,\n object,\n UuidStruct,\n AccountIdStruct,\n} from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport { array, boolean, literal, record, string } from '@metamask/superstruct';\nimport {\n CaipAssetTypeStruct,\n CaipAssetTypeOrIdStruct,\n JsonStruct,\n} from '@metamask/utils';\n\nimport {\n FungibleAssetAmountStruct,\n KeyringAccountStruct,\n TransactionStruct,\n MetaMaskOptionsStruct,\n} from './api';\n\n/**\n * Supported keyring events.\n */\nexport enum KeyringEvent {\n // Account events\n AccountCreated = 'notify:accountCreated',\n AccountUpdated = 'notify:accountUpdated',\n AccountDeleted = 'notify:accountDeleted',\n\n // Request events\n RequestApproved = 'notify:requestApproved',\n RequestRejected = 'notify:requestRejected',\n\n // Assets related events\n AccountBalancesUpdated = 'notify:accountBalancesUpdated',\n AccountAssetListUpdated = 'notify:accountAssetListUpdated',\n AccountTransactionsUpdated = 'notify:accountTransactionsUpdated',\n}\n\nexport const AccountCreatedEventStruct = object({\n method: literal(`${KeyringEvent.AccountCreated}`),\n params: object({\n /**\n * New account object.\n */\n account: KeyringAccountStruct,\n\n /**\n * Account name suggestion provided to the MetaMask client.\n *\n * The keyring can suggest a name for the account, but it's up to the\n * client to decide whether to use it. The keyring won't be informed if the\n * client decides to use a different name.\n */\n accountNameSuggestion: exactOptional(string()),\n\n /**\n * Instructs MetaMask to display the add account confirmation dialog in the UI.\n *\n * **Note:** This is not guaranteed to be honored by the MetaMask client.\n */\n displayConfirmation: exactOptional(boolean()),\n\n /**\n * Instructs MetaMask to display the name confirmation dialog in the UI.\n * Otherwise, the account will be added with the suggested name, if it's not\n * already in use; if it is, a suffix will be appended to the name to make it\n * unique.\n *\n * **Note:** This is not guaranteed to be honored by the MetaMask client.\n */\n displayAccountNameSuggestion: exactOptional(boolean()),\n\n /**\n * Metamask internal options.\n */\n ...MetaMaskOptionsStruct.schema,\n }),\n});\nexport type AccountCreatedEvent = Infer<typeof AccountCreatedEventStruct>;\nexport type AccountCreatedEventPayload = AccountCreatedEvent['params'];\n\nexport const AccountUpdatedEventStruct = object({\n method: literal(`${KeyringEvent.AccountUpdated}`),\n params: object({\n /**\n * Updated account object.\n */\n account: KeyringAccountStruct,\n }),\n});\nexport type AccountUpdatedEvent = Infer<typeof AccountUpdatedEventStruct>;\nexport type AccountUpdatedEventPayload = AccountUpdatedEvent['params'];\n\nexport const AccountDeletedEventStruct = object({\n method: literal(`${KeyringEvent.AccountDeleted}`),\n params: object({\n /**\n * Deleted account ID.\n */\n id: UuidStruct,\n }),\n});\nexport type AccountDeletedEvent = Infer<typeof AccountDeletedEventStruct>;\nexport type AccountDeletedEventPayload = AccountDeletedEvent['params'];\n\nexport const RequestApprovedEventStruct = object({\n method: literal(`${KeyringEvent.RequestApproved}`),\n params: object({\n /**\n * Request ID.\n */\n id: UuidStruct,\n\n /**\n * Request result.\n */\n result: JsonStruct,\n }),\n});\nexport type RequestApprovedEvent = Infer<typeof RequestApprovedEventStruct>;\nexport type RequestApprovedEventPayload = RequestApprovedEvent['params'];\n\nexport const RequestRejectedEventStruct = object({\n method: literal(`${KeyringEvent.RequestRejected}`),\n params: object({\n /**\n * Request ID.\n */\n id: UuidStruct,\n }),\n});\nexport type RequestRejectedEvent = Infer<typeof RequestRejectedEventStruct>;\nexport type RequestRejectedEventPayload = RequestRejectedEvent['params'];\n\n// Assets related events:\n// -----------------------------------------------------------------------------------------------\n\n/**\n * Event emitted when the balances of an account are updated.\n *\n * Only changes are reported.\n *\n * The Snap can choose to emit this event for multiple accounts at once.\n */\nexport const AccountBalancesUpdatedEventStruct = object({\n method: literal(`${KeyringEvent.AccountBalancesUpdated}`),\n params: object({\n /**\n * Balances updates of accounts owned by the Snap.\n */\n balances: record(\n /**\n * Account ID.\n */\n AccountIdStruct,\n\n /**\n * Mapping of each owned assets and their respective balances for that account.\n */\n record(\n /**\n * Asset type (CAIP-19).\n */\n CaipAssetTypeStruct,\n\n /**\n * Balance information for a given asset.\n */\n FungibleAssetAmountStruct,\n ),\n ),\n }),\n});\nexport type AccountBalancesUpdatedEvent = Infer<\n typeof AccountBalancesUpdatedEventStruct\n>;\nexport type AccountBalancesUpdatedEventPayload =\n AccountBalancesUpdatedEvent['params'];\n\n/**\n * Event emitted when the transactions of an account are updated (added or\n * changed).\n *\n * Only changes are reported.\n *\n * The Snap can choose to emit this event for multiple accounts at once.\n */\nexport const AccountTransactionsUpdatedEventStruct = object({\n method: literal(`${KeyringEvent.AccountTransactionsUpdated}`),\n params: object({\n /**\n * Transactions updates of accounts owned by the Snap.\n */\n transactions: record(\n /**\n * Account ID.\n */\n AccountIdStruct,\n\n /**\n * List of updated transactions for that account.\n */\n array(TransactionStruct),\n ),\n }),\n});\nexport type AccountTransactionsUpdatedEvent = Infer<\n typeof AccountTransactionsUpdatedEventStruct\n>;\nexport type AccountTransactionsUpdatedEventPayload =\n AccountTransactionsUpdatedEvent['params'];\n\n/**\n * Event emitted when the assets of an account are updated.\n *\n * Only changes are reported.\n *\n * The Snap can choose to emit this event for multiple accounts at once.\n */\nexport const AccountAssetListUpdatedEventStruct = object({\n method: literal(`${KeyringEvent.AccountAssetListUpdated}`),\n params: object({\n /**\n * Asset list update of accounts owned by the Snap.\n */\n assets: record(\n /**\n * Account ID.\n */\n AccountIdStruct,\n\n /**\n * Asset list changes for that account.\n */\n object({\n /**\n * New assets detected.\n */\n added: array(CaipAssetTypeOrIdStruct),\n\n /**\n * Assets no longer available on that account.\n */\n removed: array(CaipAssetTypeOrIdStruct),\n }),\n ),\n }),\n});\nexport type AccountAssetListUpdatedEvent = Infer<\n typeof AccountAssetListUpdatedEventStruct\n>;\nexport type AccountAssetListUpdatedEventPayload =\n AccountAssetListUpdatedEvent['params'];\n\n/**\n * Keyring events.\n */\n// For some reason, eslint sometimes infer one of those members as `any`...\ntype KeyringEvents =\n | AccountCreatedEvent\n | AccountUpdatedEvent\n | AccountDeletedEvent\n | AccountAssetListUpdatedEvent\n | AccountBalancesUpdatedEvent\n | AccountTransactionsUpdatedEvent\n | RequestApprovedEvent\n | RequestRejectedEvent;\n\n/**\n * Extract the payload for a given `KeyringEvent` event.\n */\nexport type KeyringEventPayload<Event extends KeyringEvent> = Extract<\n KeyringEvents,\n // We need to use a literal string here, since that is what `KeyringEvents`\n // is using (probably because of `superstruct`.\n { method: `${Event}` }\n>['params'];\n"]}
|
|
1
|
+
{"version":3,"file":"events.mjs","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,gCAAgC;AAEtE,OAAO,EACL,KAAK,EACL,OAAO,EACP,OAAO,EACP,MAAM,EACN,MAAM,EACN,MAAM,EACN,aAAa,EACd,8BAA8B;AAC/B,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,UAAU,EACX,wBAAwB;AAEzB,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACtB,wBAAc;AAEf;;GAEG;AACH,MAAM,CAAN,IAAY,YAcX;AAdD,WAAY,YAAY;IACtB,iBAAiB;IACjB,wDAAwC,CAAA;IACxC,wDAAwC,CAAA;IACxC,wDAAwC,CAAA;IAExC,iBAAiB;IACjB,0DAA0C,CAAA;IAC1C,0DAA0C,CAAA;IAE1C,wBAAwB;IACxB,wEAAwD,CAAA;IACxD,0EAA0D,CAAA;IAC1D,gFAAgE,CAAA;AAClE,CAAC,EAdW,YAAY,KAAZ,YAAY,QAcvB;AAED,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC;IAC9C,MAAM,EAAE,OAAO,CAAC,GAAG,YAAY,CAAC,cAAc,EAAE,CAAC;IACjD,MAAM,EAAE,MAAM,CAAC;QACb;;WAEG;QACH,OAAO,EAAE,oBAAoB;QAE7B;;;;;;WAMG;QACH,qBAAqB,EAAE,aAAa,CAAC,MAAM,EAAE,CAAC;QAE9C;;;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AAsB,EAAE,CAAC;IACzD,MAAM,EAAE,MAAM,CAAC;QACb;;WAEG;QACH,QAAQ,EAAE,MAAM;QACd;;WAEG;QACH,eAAe;QAEf;;WAEG;QACH,MAAM;QACJ;;WAEG;QACH,mBAAmB;QAEnB;;WAEG;QACH,yBAAyB,CAC1B,CACF;KACF,CAAC;CACH,CAAC,CAAC;AAOH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAG,MAAM,CAAC;IAC1D,MAAM,EAAE,OAAO,CAAC,GAAG,YAAY,CAAC,0BAA0B,EAAE,CAAC;IAC7D,MAAM,EAAE,MAAM,CAAC;QACb;;WAEG;QACH,YAAY,EAAE,MAAM;QAClB;;WAEG;QACH,eAAe;QAEf;;WAEG;QACH,KAAK,CAAC,iBAAiB,CAAC,CACzB;KACF,CAAC;CACH,CAAC,CAAC;AAOH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAG,MAAM,CAAC;IACvD,MAAM,EAAE,OAAO,CAAC,GAAG,YAAY,CAAC,uBAAuB,EAAE,CAAC;IAC1D,MAAM,EAAE,MAAM,CAAC;QACb;;WAEG;QACH,MAAM,EAAE,MAAM;QACZ;;WAEG;QACH,eAAe;QAEf;;WAEG;QACH,MAAM,CAAC;YACL;;eAEG;YACH,KAAK,EAAE,KAAK,CAAC,uBAAuB,CAAC;YAErC;;eAEG;YACH,OAAO,EAAE,KAAK,CAAC,uBAAuB,CAAC;SACxC,CAAC,CACH;KACF,CAAC;CACH,CAAC,CAAC","sourcesContent":["import { UuidStruct, AccountIdStruct } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport {\n array,\n boolean,\n literal,\n record,\n string,\n object,\n exactOptional,\n} from '@metamask/superstruct';\nimport {\n CaipAssetTypeStruct,\n CaipAssetTypeOrIdStruct,\n JsonStruct,\n} from '@metamask/utils';\n\nimport {\n FungibleAssetAmountStruct,\n KeyringAccountStruct,\n TransactionStruct,\n MetaMaskOptionsStruct,\n} from './api';\n\n/**\n * Supported keyring events.\n */\nexport enum KeyringEvent {\n // Account events\n AccountCreated = 'notify:accountCreated',\n AccountUpdated = 'notify:accountUpdated',\n AccountDeleted = 'notify:accountDeleted',\n\n // Request events\n RequestApproved = 'notify:requestApproved',\n RequestRejected = 'notify:requestRejected',\n\n // Assets related events\n AccountBalancesUpdated = 'notify:accountBalancesUpdated',\n AccountAssetListUpdated = 'notify:accountAssetListUpdated',\n AccountTransactionsUpdated = 'notify:accountTransactionsUpdated',\n}\n\nexport const AccountCreatedEventStruct = object({\n method: literal(`${KeyringEvent.AccountCreated}`),\n params: object({\n /**\n * New account object.\n */\n account: KeyringAccountStruct,\n\n /**\n * Account name suggestion provided to the MetaMask client.\n *\n * The keyring can suggest a name for the account, but it's up to the\n * client to decide whether to use it. The keyring won't be informed if the\n * client decides to use a different name.\n */\n accountNameSuggestion: exactOptional(string()),\n\n /**\n * Instructs MetaMask to display the add account confirmation dialog in the UI.\n *\n * **Note:** This is not guaranteed to be honored by the MetaMask client.\n */\n displayConfirmation: exactOptional(boolean()),\n\n /**\n * Instructs MetaMask to display the name confirmation dialog in the UI.\n * Otherwise, the account will be added with the suggested name, if it's not\n * already in use; if it is, a suffix will be appended to the name to make it\n * unique.\n *\n * **Note:** This is not guaranteed to be honored by the MetaMask client.\n */\n displayAccountNameSuggestion: exactOptional(boolean()),\n\n /**\n * Metamask internal options.\n */\n ...MetaMaskOptionsStruct.schema,\n }),\n});\nexport type AccountCreatedEvent = Infer<typeof AccountCreatedEventStruct>;\nexport type AccountCreatedEventPayload = AccountCreatedEvent['params'];\n\nexport const AccountUpdatedEventStruct = object({\n method: literal(`${KeyringEvent.AccountUpdated}`),\n params: object({\n /**\n * Updated account object.\n */\n account: KeyringAccountStruct,\n }),\n});\nexport type AccountUpdatedEvent = Infer<typeof AccountUpdatedEventStruct>;\nexport type AccountUpdatedEventPayload = AccountUpdatedEvent['params'];\n\nexport const AccountDeletedEventStruct = object({\n method: literal(`${KeyringEvent.AccountDeleted}`),\n params: object({\n /**\n * Deleted account ID.\n */\n id: UuidStruct,\n }),\n});\nexport type AccountDeletedEvent = Infer<typeof AccountDeletedEventStruct>;\nexport type AccountDeletedEventPayload = AccountDeletedEvent['params'];\n\nexport const RequestApprovedEventStruct = object({\n method: literal(`${KeyringEvent.RequestApproved}`),\n params: object({\n /**\n * Request ID.\n */\n id: UuidStruct,\n\n /**\n * Request result.\n */\n result: JsonStruct,\n }),\n});\nexport type RequestApprovedEvent = Infer<typeof RequestApprovedEventStruct>;\nexport type RequestApprovedEventPayload = RequestApprovedEvent['params'];\n\nexport const RequestRejectedEventStruct = object({\n method: literal(`${KeyringEvent.RequestRejected}`),\n params: object({\n /**\n * Request ID.\n */\n id: UuidStruct,\n }),\n});\nexport type RequestRejectedEvent = Infer<typeof RequestRejectedEventStruct>;\nexport type RequestRejectedEventPayload = RequestRejectedEvent['params'];\n\n// Assets related events:\n// -----------------------------------------------------------------------------------------------\n\n/**\n * Event emitted when the balances of an account are updated.\n *\n * Only changes are reported.\n *\n * The Snap can choose to emit this event for multiple accounts at once.\n */\nexport const AccountBalancesUpdatedEventStruct = object({\n method: literal(`${KeyringEvent.AccountBalancesUpdated}`),\n params: object({\n /**\n * Balances updates of accounts owned by the Snap.\n */\n balances: record(\n /**\n * Account ID.\n */\n AccountIdStruct,\n\n /**\n * Mapping of each owned assets and their respective balances for that account.\n */\n record(\n /**\n * Asset type (CAIP-19).\n */\n CaipAssetTypeStruct,\n\n /**\n * Balance information for a given asset.\n */\n FungibleAssetAmountStruct,\n ),\n ),\n }),\n});\nexport type AccountBalancesUpdatedEvent = Infer<\n typeof AccountBalancesUpdatedEventStruct\n>;\nexport type AccountBalancesUpdatedEventPayload =\n AccountBalancesUpdatedEvent['params'];\n\n/**\n * Event emitted when the transactions of an account are updated (added or\n * changed).\n *\n * Only changes are reported.\n *\n * The Snap can choose to emit this event for multiple accounts at once.\n */\nexport const AccountTransactionsUpdatedEventStruct = object({\n method: literal(`${KeyringEvent.AccountTransactionsUpdated}`),\n params: object({\n /**\n * Transactions updates of accounts owned by the Snap.\n */\n transactions: record(\n /**\n * Account ID.\n */\n AccountIdStruct,\n\n /**\n * List of updated transactions for that account.\n */\n array(TransactionStruct),\n ),\n }),\n});\nexport type AccountTransactionsUpdatedEvent = Infer<\n typeof AccountTransactionsUpdatedEventStruct\n>;\nexport type AccountTransactionsUpdatedEventPayload =\n AccountTransactionsUpdatedEvent['params'];\n\n/**\n * Event emitted when the assets of an account are updated.\n *\n * Only changes are reported.\n *\n * The Snap can choose to emit this event for multiple accounts at once.\n */\nexport const AccountAssetListUpdatedEventStruct = object({\n method: literal(`${KeyringEvent.AccountAssetListUpdated}`),\n params: object({\n /**\n * Asset list update of accounts owned by the Snap.\n */\n assets: record(\n /**\n * Account ID.\n */\n AccountIdStruct,\n\n /**\n * Asset list changes for that account.\n */\n object({\n /**\n * New assets detected.\n */\n added: array(CaipAssetTypeOrIdStruct),\n\n /**\n * Assets no longer available on that account.\n */\n removed: array(CaipAssetTypeOrIdStruct),\n }),\n ),\n }),\n});\nexport type AccountAssetListUpdatedEvent = Infer<\n typeof AccountAssetListUpdatedEventStruct\n>;\nexport type AccountAssetListUpdatedEventPayload =\n AccountAssetListUpdatedEvent['params'];\n\n/**\n * Keyring events.\n */\n// For some reason, eslint sometimes infer one of those members as `any`...\ntype KeyringEvents =\n | AccountCreatedEvent\n | AccountUpdatedEvent\n | AccountDeletedEvent\n | AccountAssetListUpdatedEvent\n | AccountBalancesUpdatedEvent\n | AccountTransactionsUpdatedEvent\n | RequestApprovedEvent\n | RequestRejectedEvent;\n\n/**\n * Extract the payload for a given `KeyringEvent` event.\n */\nexport type KeyringEventPayload<Event extends KeyringEvent> = Extract<\n KeyringEvents,\n // We need to use a literal string here, since that is what `KeyringEvents`\n // is using (probably because of `superstruct`.\n { method: `${Event}` }\n>['params'];\n"]}
|
package/dist/rpc.cjs
CHANGED
|
@@ -52,57 +52,57 @@ const CommonHeader = {
|
|
|
52
52
|
};
|
|
53
53
|
// ----------------------------------------------------------------------------
|
|
54
54
|
// List accounts
|
|
55
|
-
exports.ListAccountsRequestStruct = (0,
|
|
55
|
+
exports.ListAccountsRequestStruct = (0, superstruct_1.object)({
|
|
56
56
|
...CommonHeader,
|
|
57
57
|
method: (0, superstruct_1.literal)('keyring_listAccounts'),
|
|
58
58
|
});
|
|
59
59
|
exports.ListAccountsResponseStruct = (0, superstruct_1.array)(api_1.KeyringAccountStruct);
|
|
60
60
|
// ----------------------------------------------------------------------------
|
|
61
61
|
// Get account
|
|
62
|
-
exports.GetAccountRequestStruct = (0,
|
|
62
|
+
exports.GetAccountRequestStruct = (0, superstruct_1.object)({
|
|
63
63
|
...CommonHeader,
|
|
64
64
|
method: (0, superstruct_1.literal)('keyring_getAccount'),
|
|
65
|
-
params: (0,
|
|
65
|
+
params: (0, superstruct_1.object)({
|
|
66
66
|
id: keyring_utils_1.UuidStruct,
|
|
67
67
|
}),
|
|
68
68
|
});
|
|
69
69
|
exports.GetAccountResponseStruct = api_1.KeyringAccountStruct;
|
|
70
70
|
// ----------------------------------------------------------------------------
|
|
71
71
|
// Create account
|
|
72
|
-
exports.CreateAccountRequestStruct = (0,
|
|
72
|
+
exports.CreateAccountRequestStruct = (0, superstruct_1.object)({
|
|
73
73
|
...CommonHeader,
|
|
74
74
|
method: (0, superstruct_1.literal)('keyring_createAccount'),
|
|
75
|
-
params: (0,
|
|
75
|
+
params: (0, superstruct_1.object)({
|
|
76
76
|
options: (0, superstruct_1.record)((0, superstruct_1.string)(), utils_1.JsonStruct),
|
|
77
77
|
}),
|
|
78
78
|
});
|
|
79
79
|
exports.CreateAccountResponseStruct = api_1.KeyringAccountStruct;
|
|
80
80
|
// ----------------------------------------------------------------------------
|
|
81
81
|
// Create accounts
|
|
82
|
-
exports.CreateAccountsRequestStruct = (0,
|
|
82
|
+
exports.CreateAccountsRequestStruct = (0, superstruct_1.object)({
|
|
83
83
|
...CommonHeader,
|
|
84
84
|
method: (0, superstruct_1.literal)('keyring_createAccounts'),
|
|
85
|
-
params: (0,
|
|
85
|
+
params: (0, superstruct_1.object)({
|
|
86
86
|
options: create_account_1.CreateAccountOptionsStruct,
|
|
87
87
|
}),
|
|
88
88
|
});
|
|
89
89
|
exports.CreateAccountsResponseStruct = (0, superstruct_1.array)(api_1.KeyringAccountStruct);
|
|
90
90
|
// ----------------------------------------------------------------------------
|
|
91
91
|
// Set selected accounts
|
|
92
|
-
exports.SetSelectedAccountsRequestStruct = (0,
|
|
92
|
+
exports.SetSelectedAccountsRequestStruct = (0, superstruct_1.object)({
|
|
93
93
|
...CommonHeader,
|
|
94
94
|
method: (0, superstruct_1.literal)('keyring_setSelectedAccounts'),
|
|
95
|
-
params: (0,
|
|
95
|
+
params: (0, superstruct_1.object)({
|
|
96
96
|
accounts: (0, superstruct_1.array)((0, superstruct_1.string)()),
|
|
97
97
|
}),
|
|
98
98
|
});
|
|
99
99
|
exports.SetSelectedAccountsResponseStruct = (0, superstruct_1.literal)(null);
|
|
100
100
|
// ----------------------------------------------------------------------------
|
|
101
101
|
// Discover accounts
|
|
102
|
-
exports.DiscoverAccountsRequestStruct = (0,
|
|
102
|
+
exports.DiscoverAccountsRequestStruct = (0, superstruct_1.object)({
|
|
103
103
|
...CommonHeader,
|
|
104
104
|
method: (0, superstruct_1.literal)('keyring_discoverAccounts'),
|
|
105
|
-
params: (0,
|
|
105
|
+
params: (0, superstruct_1.object)({
|
|
106
106
|
scopes: (0, superstruct_1.array)(api_1.CaipChainIdStruct),
|
|
107
107
|
entropySource: (0, superstruct_1.string)(),
|
|
108
108
|
groupIndex: (0, superstruct_1.number)(),
|
|
@@ -111,10 +111,10 @@ exports.DiscoverAccountsRequestStruct = (0, keyring_utils_1.object)({
|
|
|
111
111
|
exports.DiscoverAccountsResponseStruct = (0, superstruct_1.array)(api_1.DiscoveredAccountStruct);
|
|
112
112
|
// ----------------------------------------------------------------------------
|
|
113
113
|
// List account transactions
|
|
114
|
-
exports.ListAccountTransactionsRequestStruct = (0,
|
|
114
|
+
exports.ListAccountTransactionsRequestStruct = (0, superstruct_1.object)({
|
|
115
115
|
...CommonHeader,
|
|
116
116
|
method: (0, superstruct_1.literal)('keyring_listAccountTransactions'),
|
|
117
|
-
params: (0,
|
|
117
|
+
params: (0, superstruct_1.object)({
|
|
118
118
|
id: keyring_utils_1.UuidStruct,
|
|
119
119
|
pagination: api_1.PaginationStruct,
|
|
120
120
|
}),
|
|
@@ -122,20 +122,20 @@ exports.ListAccountTransactionsRequestStruct = (0, keyring_utils_1.object)({
|
|
|
122
122
|
exports.ListAccountTransactionsResponseStruct = api_1.TransactionsPageStruct;
|
|
123
123
|
// ----------------------------------------------------------------------------
|
|
124
124
|
// List account assets
|
|
125
|
-
exports.ListAccountAssetsRequestStruct = (0,
|
|
125
|
+
exports.ListAccountAssetsRequestStruct = (0, superstruct_1.object)({
|
|
126
126
|
...CommonHeader,
|
|
127
127
|
method: (0, superstruct_1.literal)('keyring_listAccountAssets'),
|
|
128
|
-
params: (0,
|
|
128
|
+
params: (0, superstruct_1.object)({
|
|
129
129
|
id: keyring_utils_1.UuidStruct,
|
|
130
130
|
}),
|
|
131
131
|
});
|
|
132
132
|
exports.ListAccountAssetsResponseStruct = (0, superstruct_1.array)(api_1.CaipAssetTypeOrIdStruct);
|
|
133
133
|
// ----------------------------------------------------------------------------
|
|
134
134
|
// Get account balances
|
|
135
|
-
exports.GetAccountBalancesRequestStruct = (0,
|
|
135
|
+
exports.GetAccountBalancesRequestStruct = (0, superstruct_1.object)({
|
|
136
136
|
...CommonHeader,
|
|
137
137
|
method: (0, superstruct_1.literal)(`${KeyringRpcMethod.GetAccountBalances}`),
|
|
138
|
-
params: (0,
|
|
138
|
+
params: (0, superstruct_1.object)({
|
|
139
139
|
id: keyring_utils_1.UuidStruct,
|
|
140
140
|
assets: (0, superstruct_1.array)(api_1.CaipAssetTypeStruct),
|
|
141
141
|
}),
|
|
@@ -143,23 +143,23 @@ exports.GetAccountBalancesRequestStruct = (0, keyring_utils_1.object)({
|
|
|
143
143
|
exports.GetAccountBalancesResponseStruct = (0, superstruct_1.record)(api_1.CaipAssetTypeStruct, api_1.BalanceStruct);
|
|
144
144
|
// ----------------------------------------------------------------------------
|
|
145
145
|
// Resolve account address
|
|
146
|
-
exports.ResolveAccountAddressRequestStruct = (0,
|
|
146
|
+
exports.ResolveAccountAddressRequestStruct = (0, superstruct_1.object)({
|
|
147
147
|
...CommonHeader,
|
|
148
148
|
method: (0, superstruct_1.literal)('keyring_resolveAccountAddress'),
|
|
149
|
-
params: (0,
|
|
149
|
+
params: (0, superstruct_1.object)({
|
|
150
150
|
scope: api_1.CaipChainIdStruct,
|
|
151
151
|
request: keyring_utils_1.JsonRpcRequestStruct,
|
|
152
152
|
}),
|
|
153
153
|
});
|
|
154
|
-
exports.ResolveAccountAddressResponseStruct = (0, superstruct_1.nullable)((0,
|
|
154
|
+
exports.ResolveAccountAddressResponseStruct = (0, superstruct_1.nullable)((0, superstruct_1.object)({
|
|
155
155
|
address: api_1.CaipAccountIdStruct,
|
|
156
156
|
}));
|
|
157
157
|
// ----------------------------------------------------------------------------
|
|
158
158
|
// Filter account chains
|
|
159
|
-
exports.FilterAccountChainsStruct = (0,
|
|
159
|
+
exports.FilterAccountChainsStruct = (0, superstruct_1.object)({
|
|
160
160
|
...CommonHeader,
|
|
161
161
|
method: (0, superstruct_1.literal)('keyring_filterAccountChains'),
|
|
162
|
-
params: (0,
|
|
162
|
+
params: (0, superstruct_1.object)({
|
|
163
163
|
id: keyring_utils_1.UuidStruct,
|
|
164
164
|
chains: (0, superstruct_1.array)((0, superstruct_1.string)()),
|
|
165
165
|
}),
|
|
@@ -167,54 +167,54 @@ exports.FilterAccountChainsStruct = (0, keyring_utils_1.object)({
|
|
|
167
167
|
exports.FilterAccountChainsResponseStruct = (0, superstruct_1.array)((0, superstruct_1.string)());
|
|
168
168
|
// ----------------------------------------------------------------------------
|
|
169
169
|
// Update account
|
|
170
|
-
exports.UpdateAccountRequestStruct = (0,
|
|
170
|
+
exports.UpdateAccountRequestStruct = (0, superstruct_1.object)({
|
|
171
171
|
...CommonHeader,
|
|
172
172
|
method: (0, superstruct_1.literal)('keyring_updateAccount'),
|
|
173
|
-
params: (0,
|
|
173
|
+
params: (0, superstruct_1.object)({
|
|
174
174
|
account: api_1.KeyringAccountStruct,
|
|
175
175
|
}),
|
|
176
176
|
});
|
|
177
177
|
exports.UpdateAccountResponseStruct = (0, superstruct_1.literal)(null);
|
|
178
178
|
// ----------------------------------------------------------------------------
|
|
179
179
|
// Delete account
|
|
180
|
-
exports.DeleteAccountRequestStruct = (0,
|
|
180
|
+
exports.DeleteAccountRequestStruct = (0, superstruct_1.object)({
|
|
181
181
|
...CommonHeader,
|
|
182
182
|
method: (0, superstruct_1.literal)('keyring_deleteAccount'),
|
|
183
|
-
params: (0,
|
|
183
|
+
params: (0, superstruct_1.object)({
|
|
184
184
|
id: keyring_utils_1.UuidStruct,
|
|
185
185
|
}),
|
|
186
186
|
});
|
|
187
187
|
exports.DeleteAccountResponseStruct = (0, superstruct_1.literal)(null);
|
|
188
188
|
// ----------------------------------------------------------------------------
|
|
189
189
|
// Export account
|
|
190
|
-
exports.ExportAccountRequestStruct = (0,
|
|
190
|
+
exports.ExportAccountRequestStruct = (0, superstruct_1.object)({
|
|
191
191
|
...CommonHeader,
|
|
192
192
|
method: (0, superstruct_1.literal)('keyring_exportAccount'),
|
|
193
|
-
params: (0,
|
|
193
|
+
params: (0, superstruct_1.object)({
|
|
194
194
|
id: keyring_utils_1.UuidStruct,
|
|
195
195
|
}),
|
|
196
196
|
});
|
|
197
197
|
exports.ExportAccountResponseStruct = api_1.KeyringAccountDataStruct;
|
|
198
198
|
// ----------------------------------------------------------------------------
|
|
199
199
|
// List requests
|
|
200
|
-
exports.ListRequestsRequestStruct = (0,
|
|
200
|
+
exports.ListRequestsRequestStruct = (0, superstruct_1.object)({
|
|
201
201
|
...CommonHeader,
|
|
202
202
|
method: (0, superstruct_1.literal)('keyring_listRequests'),
|
|
203
203
|
});
|
|
204
204
|
exports.ListRequestsResponseStruct = (0, superstruct_1.array)(api_1.KeyringRequestStruct);
|
|
205
205
|
// ----------------------------------------------------------------------------
|
|
206
206
|
// Get request
|
|
207
|
-
exports.GetRequestRequestStruct = (0,
|
|
207
|
+
exports.GetRequestRequestStruct = (0, superstruct_1.object)({
|
|
208
208
|
...CommonHeader,
|
|
209
209
|
method: (0, superstruct_1.literal)('keyring_getRequest'),
|
|
210
|
-
params: (0,
|
|
210
|
+
params: (0, superstruct_1.object)({
|
|
211
211
|
id: keyring_utils_1.UuidStruct,
|
|
212
212
|
}),
|
|
213
213
|
});
|
|
214
214
|
exports.GetRequestResponseStruct = api_1.KeyringRequestStruct;
|
|
215
215
|
// ----------------------------------------------------------------------------
|
|
216
216
|
// Submit request
|
|
217
|
-
exports.SubmitRequestRequestStruct = (0,
|
|
217
|
+
exports.SubmitRequestRequestStruct = (0, superstruct_1.object)({
|
|
218
218
|
...CommonHeader,
|
|
219
219
|
method: (0, superstruct_1.literal)('keyring_submitRequest'),
|
|
220
220
|
params: api_1.KeyringRequestStruct,
|
|
@@ -222,10 +222,10 @@ exports.SubmitRequestRequestStruct = (0, keyring_utils_1.object)({
|
|
|
222
222
|
exports.SubmitRequestResponseStruct = api_1.KeyringResponseStruct;
|
|
223
223
|
// ----------------------------------------------------------------------------
|
|
224
224
|
// Approve request
|
|
225
|
-
exports.ApproveRequestRequestStruct = (0,
|
|
225
|
+
exports.ApproveRequestRequestStruct = (0, superstruct_1.object)({
|
|
226
226
|
...CommonHeader,
|
|
227
227
|
method: (0, superstruct_1.literal)('keyring_approveRequest'),
|
|
228
|
-
params: (0,
|
|
228
|
+
params: (0, superstruct_1.object)({
|
|
229
229
|
id: keyring_utils_1.UuidStruct,
|
|
230
230
|
data: (0, superstruct_1.record)((0, superstruct_1.string)(), utils_1.JsonStruct),
|
|
231
231
|
}),
|
|
@@ -233,10 +233,10 @@ exports.ApproveRequestRequestStruct = (0, keyring_utils_1.object)({
|
|
|
233
233
|
exports.ApproveRequestResponseStruct = (0, superstruct_1.literal)(null);
|
|
234
234
|
// ----------------------------------------------------------------------------
|
|
235
235
|
// Reject request
|
|
236
|
-
exports.RejectRequestRequestStruct = (0,
|
|
236
|
+
exports.RejectRequestRequestStruct = (0, superstruct_1.object)({
|
|
237
237
|
...CommonHeader,
|
|
238
238
|
method: (0, superstruct_1.literal)('keyring_rejectRequest'),
|
|
239
|
-
params: (0,
|
|
239
|
+
params: (0, superstruct_1.object)({
|
|
240
240
|
id: keyring_utils_1.UuidStruct,
|
|
241
241
|
}),
|
|
242
242
|
});
|