@metamask/keyring-api 21.3.0 → 21.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +49 -2
- package/README.md +4 -0
- package/dist/api/account-options.cjs +44 -7
- package/dist/api/account-options.cjs.map +1 -1
- package/dist/api/account-options.d.cts +41 -3
- package/dist/api/account-options.d.cts.map +1 -1
- package/dist/api/account-options.d.mts +41 -3
- package/dist/api/account-options.d.mts.map +1 -1
- package/dist/api/account-options.mjs +43 -6
- package/dist/api/account-options.mjs.map +1 -1
- package/dist/api/account.d.cts +4 -0
- package/dist/api/account.d.cts.map +1 -1
- package/dist/api/account.d.mts +4 -0
- package/dist/api/account.d.mts.map +1 -1
- package/dist/api/keyring.cjs +0 -2
- package/dist/api/keyring.cjs.map +1 -1
- package/dist/api/keyring.d.cts +13 -0
- package/dist/api/keyring.d.cts.map +1 -1
- package/dist/api/keyring.d.mts +13 -0
- package/dist/api/keyring.d.mts.map +1 -1
- package/dist/api/keyring.mjs +0 -2
- package/dist/api/keyring.mjs.map +1 -1
- package/dist/api/v2/create-account/bip44.cjs +27 -1
- package/dist/api/v2/create-account/bip44.cjs.map +1 -1
- package/dist/api/v2/create-account/bip44.d.cts +46 -0
- package/dist/api/v2/create-account/bip44.d.cts.map +1 -1
- package/dist/api/v2/create-account/bip44.d.mts +46 -0
- package/dist/api/v2/create-account/bip44.d.mts.map +1 -1
- package/dist/api/v2/create-account/bip44.mjs +26 -0
- package/dist/api/v2/create-account/bip44.mjs.map +1 -1
- package/dist/api/v2/create-account/custom.cjs +14 -0
- package/dist/api/v2/create-account/custom.cjs.map +1 -0
- package/dist/api/v2/create-account/custom.d.cts +25 -0
- package/dist/api/v2/create-account/custom.d.cts.map +1 -0
- package/dist/api/v2/create-account/custom.d.mts +25 -0
- package/dist/api/v2/create-account/custom.d.mts.map +1 -0
- package/dist/api/v2/create-account/custom.mjs +11 -0
- package/dist/api/v2/create-account/custom.mjs.map +1 -0
- package/dist/api/v2/create-account/index.cjs +55 -0
- package/dist/api/v2/create-account/index.cjs.map +1 -1
- package/dist/api/v2/create-account/index.d.cts +55 -1
- package/dist/api/v2/create-account/index.d.cts.map +1 -1
- package/dist/api/v2/create-account/index.d.mts +55 -1
- package/dist/api/v2/create-account/index.d.mts.map +1 -1
- package/dist/api/v2/create-account/index.mjs +55 -1
- package/dist/api/v2/create-account/index.mjs.map +1 -1
- package/dist/api/v2/index.cjs +1 -0
- package/dist/api/v2/index.cjs.map +1 -1
- package/dist/api/v2/index.d.cts +1 -0
- package/dist/api/v2/index.d.cts.map +1 -1
- package/dist/api/v2/index.d.mts +1 -0
- package/dist/api/v2/index.d.mts.map +1 -1
- package/dist/api/v2/index.mjs +1 -0
- package/dist/api/v2/index.mjs.map +1 -1
- package/dist/api/v2/keyring-capabilities.cjs +17 -3
- package/dist/api/v2/keyring-capabilities.cjs.map +1 -1
- package/dist/api/v2/keyring-capabilities.d.cts +31 -9
- package/dist/api/v2/keyring-capabilities.d.cts.map +1 -1
- package/dist/api/v2/keyring-capabilities.d.mts +31 -9
- package/dist/api/v2/keyring-capabilities.d.mts.map +1 -1
- package/dist/api/v2/keyring-capabilities.mjs +18 -4
- package/dist/api/v2/keyring-capabilities.mjs.map +1 -1
- package/dist/api/v2/wrapper/index.cjs +19 -0
- package/dist/api/v2/wrapper/index.cjs.map +1 -0
- package/dist/api/v2/wrapper/index.d.cts +3 -0
- package/dist/api/v2/wrapper/index.d.cts.map +1 -0
- package/dist/api/v2/wrapper/index.d.mts +3 -0
- package/dist/api/v2/wrapper/index.d.mts.map +1 -0
- package/dist/api/v2/wrapper/index.mjs +3 -0
- package/dist/api/v2/wrapper/index.mjs.map +1 -0
- package/dist/api/v2/wrapper/keyring-account-registry.cjs +135 -0
- package/dist/api/v2/wrapper/keyring-account-registry.cjs.map +1 -0
- package/dist/api/v2/wrapper/keyring-account-registry.d.cts +88 -0
- package/dist/api/v2/wrapper/keyring-account-registry.d.cts.map +1 -0
- package/dist/api/v2/wrapper/keyring-account-registry.d.mts +88 -0
- package/dist/api/v2/wrapper/keyring-account-registry.d.mts.map +1 -0
- package/dist/api/v2/wrapper/keyring-account-registry.mjs +131 -0
- package/dist/api/v2/wrapper/keyring-account-registry.mjs.map +1 -0
- package/dist/api/v2/wrapper/keyring-wrapper.cjs +134 -0
- package/dist/api/v2/wrapper/keyring-wrapper.cjs.map +1 -0
- package/dist/api/v2/wrapper/keyring-wrapper.d.cts +154 -0
- package/dist/api/v2/wrapper/keyring-wrapper.d.cts.map +1 -0
- package/dist/api/v2/wrapper/keyring-wrapper.d.mts +154 -0
- package/dist/api/v2/wrapper/keyring-wrapper.d.mts.map +1 -0
- package/dist/api/v2/wrapper/keyring-wrapper.mjs +130 -0
- package/dist/api/v2/wrapper/keyring-wrapper.mjs.map +1 -0
- package/dist/btc/types.d.cts +16 -0
- package/dist/btc/types.d.cts.map +1 -1
- package/dist/btc/types.d.mts +16 -0
- package/dist/btc/types.d.mts.map +1 -1
- package/dist/eth/index.cjs +2 -0
- package/dist/eth/index.cjs.map +1 -1
- package/dist/eth/index.d.cts +2 -0
- package/dist/eth/index.d.cts.map +1 -1
- package/dist/eth/index.d.mts +2 -0
- package/dist/eth/index.d.mts.map +1 -1
- package/dist/eth/index.mjs +2 -0
- package/dist/eth/index.mjs.map +1 -1
- package/dist/eth/rpc/index.cjs +18 -0
- package/dist/eth/rpc/index.cjs.map +1 -0
- package/dist/eth/rpc/index.d.cts +2 -0
- package/dist/eth/rpc/index.d.cts.map +1 -0
- package/dist/eth/rpc/index.d.mts +2 -0
- package/dist/eth/rpc/index.d.mts.map +1 -0
- package/dist/eth/rpc/index.mjs +2 -0
- package/dist/eth/rpc/index.mjs.map +1 -0
- package/dist/eth/rpc/params.cjs +151 -0
- package/dist/eth/rpc/params.cjs.map +1 -0
- package/dist/eth/rpc/params.d.cts +215 -0
- package/dist/eth/rpc/params.d.cts.map +1 -0
- package/dist/eth/rpc/params.d.mts +215 -0
- package/dist/eth/rpc/params.d.mts.map +1 -0
- package/dist/eth/rpc/params.mjs +148 -0
- package/dist/eth/rpc/params.mjs.map +1 -0
- package/dist/eth/types.cjs +5 -2
- package/dist/eth/types.cjs.map +1 -1
- package/dist/eth/types.d.cts +9 -0
- package/dist/eth/types.d.cts.map +1 -1
- package/dist/eth/types.d.mts +9 -0
- package/dist/eth/types.d.mts.map +1 -1
- package/dist/eth/types.mjs +4 -1
- package/dist/eth/types.mjs.map +1 -1
- package/dist/eth/v2/eth-keyring-wrapper.cjs +165 -0
- package/dist/eth/v2/eth-keyring-wrapper.cjs.map +1 -0
- package/dist/eth/v2/eth-keyring-wrapper.d.cts +54 -0
- package/dist/eth/v2/eth-keyring-wrapper.d.cts.map +1 -0
- package/dist/eth/v2/eth-keyring-wrapper.d.mts +54 -0
- package/dist/eth/v2/eth-keyring-wrapper.d.mts.map +1 -0
- package/dist/eth/v2/eth-keyring-wrapper.mjs +161 -0
- package/dist/eth/v2/eth-keyring-wrapper.mjs.map +1 -0
- package/dist/eth/v2/index.cjs +18 -0
- package/dist/eth/v2/index.cjs.map +1 -0
- package/dist/eth/v2/index.d.cts +2 -0
- package/dist/eth/v2/index.d.cts.map +1 -0
- package/dist/eth/v2/index.d.mts +2 -0
- package/dist/eth/v2/index.d.mts.map +1 -0
- package/dist/eth/v2/index.mjs +2 -0
- package/dist/eth/v2/index.mjs.map +1 -0
- package/dist/events.cjs +0 -2
- package/dist/events.cjs.map +1 -1
- package/dist/events.d.cts +16 -0
- package/dist/events.d.cts.map +1 -1
- package/dist/events.d.mts +16 -0
- package/dist/events.d.mts.map +1 -1
- package/dist/events.mjs +0 -2
- package/dist/events.mjs.map +1 -1
- package/dist/rpc.cjs +27 -12
- package/dist/rpc.cjs.map +1 -1
- package/dist/rpc.d.cts +200 -12
- package/dist/rpc.d.cts.map +1 -1
- package/dist/rpc.d.mts +200 -12
- package/dist/rpc.d.mts.map +1 -1
- package/dist/rpc.mjs +27 -12
- package/dist/rpc.mjs.map +1 -1
- package/dist/sol/types.d.cts +4 -0
- package/dist/sol/types.d.cts.map +1 -1
- package/dist/sol/types.d.mts +4 -0
- package/dist/sol/types.d.mts.map +1 -1
- package/dist/trx/types.d.cts +4 -0
- package/dist/trx/types.d.cts.map +1 -1
- package/dist/trx/types.d.mts +4 -0
- package/dist/trx/types.d.mts.map +1 -1
- package/package.json +9 -4
package/dist/events.d.cts
CHANGED
|
@@ -26,6 +26,8 @@ export declare const AccountCreatedEventStruct: import("@metamask/superstruct").
|
|
|
26
26
|
groupIndex: number;
|
|
27
27
|
} | {
|
|
28
28
|
type: "private-key";
|
|
29
|
+
} | {
|
|
30
|
+
type: "custom";
|
|
29
31
|
};
|
|
30
32
|
exportable?: boolean;
|
|
31
33
|
};
|
|
@@ -54,6 +56,8 @@ export declare const AccountCreatedEventStruct: import("@metamask/superstruct").
|
|
|
54
56
|
groupIndex: number;
|
|
55
57
|
} | {
|
|
56
58
|
type: "private-key";
|
|
59
|
+
} | {
|
|
60
|
+
type: "custom";
|
|
57
61
|
};
|
|
58
62
|
exportable?: boolean;
|
|
59
63
|
};
|
|
@@ -87,6 +91,8 @@ export declare const AccountCreatedEventStruct: import("@metamask/superstruct").
|
|
|
87
91
|
groupIndex: number;
|
|
88
92
|
} | {
|
|
89
93
|
type: "private-key";
|
|
94
|
+
} | {
|
|
95
|
+
type: "custom";
|
|
90
96
|
};
|
|
91
97
|
exportable?: boolean;
|
|
92
98
|
};
|
|
@@ -116,6 +122,8 @@ export declare const AccountCreatedEventStruct: import("@metamask/superstruct").
|
|
|
116
122
|
groupIndex: number;
|
|
117
123
|
} | {
|
|
118
124
|
type: "private-key";
|
|
125
|
+
} | {
|
|
126
|
+
type: "custom";
|
|
119
127
|
};
|
|
120
128
|
exportable?: boolean;
|
|
121
129
|
}, null>;
|
|
@@ -162,6 +170,8 @@ export declare const AccountUpdatedEventStruct: import("@metamask/superstruct").
|
|
|
162
170
|
groupIndex: number;
|
|
163
171
|
} | {
|
|
164
172
|
type: "private-key";
|
|
173
|
+
} | {
|
|
174
|
+
type: "custom";
|
|
165
175
|
};
|
|
166
176
|
exportable?: boolean;
|
|
167
177
|
};
|
|
@@ -184,6 +194,8 @@ export declare const AccountUpdatedEventStruct: import("@metamask/superstruct").
|
|
|
184
194
|
groupIndex: number;
|
|
185
195
|
} | {
|
|
186
196
|
type: "private-key";
|
|
197
|
+
} | {
|
|
198
|
+
type: "custom";
|
|
187
199
|
};
|
|
188
200
|
exportable?: boolean;
|
|
189
201
|
};
|
|
@@ -206,6 +218,8 @@ export declare const AccountUpdatedEventStruct: import("@metamask/superstruct").
|
|
|
206
218
|
groupIndex: number;
|
|
207
219
|
} | {
|
|
208
220
|
type: "private-key";
|
|
221
|
+
} | {
|
|
222
|
+
type: "custom";
|
|
209
223
|
};
|
|
210
224
|
exportable?: boolean;
|
|
211
225
|
};
|
|
@@ -235,6 +249,8 @@ export declare const AccountUpdatedEventStruct: import("@metamask/superstruct").
|
|
|
235
249
|
groupIndex: number;
|
|
236
250
|
} | {
|
|
237
251
|
type: "private-key";
|
|
252
|
+
} | {
|
|
253
|
+
type: "custom";
|
|
238
254
|
};
|
|
239
255
|
exportable?: boolean;
|
|
240
256
|
}, null>;
|
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":"AAMA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAenD;;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;;;;;;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,CAAC,CAAC"}
|
package/dist/events.d.mts
CHANGED
|
@@ -26,6 +26,8 @@ export declare const AccountCreatedEventStruct: import("@metamask/superstruct").
|
|
|
26
26
|
groupIndex: number;
|
|
27
27
|
} | {
|
|
28
28
|
type: "private-key";
|
|
29
|
+
} | {
|
|
30
|
+
type: "custom";
|
|
29
31
|
};
|
|
30
32
|
exportable?: boolean;
|
|
31
33
|
};
|
|
@@ -54,6 +56,8 @@ export declare const AccountCreatedEventStruct: import("@metamask/superstruct").
|
|
|
54
56
|
groupIndex: number;
|
|
55
57
|
} | {
|
|
56
58
|
type: "private-key";
|
|
59
|
+
} | {
|
|
60
|
+
type: "custom";
|
|
57
61
|
};
|
|
58
62
|
exportable?: boolean;
|
|
59
63
|
};
|
|
@@ -87,6 +91,8 @@ export declare const AccountCreatedEventStruct: import("@metamask/superstruct").
|
|
|
87
91
|
groupIndex: number;
|
|
88
92
|
} | {
|
|
89
93
|
type: "private-key";
|
|
94
|
+
} | {
|
|
95
|
+
type: "custom";
|
|
90
96
|
};
|
|
91
97
|
exportable?: boolean;
|
|
92
98
|
};
|
|
@@ -116,6 +122,8 @@ export declare const AccountCreatedEventStruct: import("@metamask/superstruct").
|
|
|
116
122
|
groupIndex: number;
|
|
117
123
|
} | {
|
|
118
124
|
type: "private-key";
|
|
125
|
+
} | {
|
|
126
|
+
type: "custom";
|
|
119
127
|
};
|
|
120
128
|
exportable?: boolean;
|
|
121
129
|
}, null>;
|
|
@@ -162,6 +170,8 @@ export declare const AccountUpdatedEventStruct: import("@metamask/superstruct").
|
|
|
162
170
|
groupIndex: number;
|
|
163
171
|
} | {
|
|
164
172
|
type: "private-key";
|
|
173
|
+
} | {
|
|
174
|
+
type: "custom";
|
|
165
175
|
};
|
|
166
176
|
exportable?: boolean;
|
|
167
177
|
};
|
|
@@ -184,6 +194,8 @@ export declare const AccountUpdatedEventStruct: import("@metamask/superstruct").
|
|
|
184
194
|
groupIndex: number;
|
|
185
195
|
} | {
|
|
186
196
|
type: "private-key";
|
|
197
|
+
} | {
|
|
198
|
+
type: "custom";
|
|
187
199
|
};
|
|
188
200
|
exportable?: boolean;
|
|
189
201
|
};
|
|
@@ -206,6 +218,8 @@ export declare const AccountUpdatedEventStruct: import("@metamask/superstruct").
|
|
|
206
218
|
groupIndex: number;
|
|
207
219
|
} | {
|
|
208
220
|
type: "private-key";
|
|
221
|
+
} | {
|
|
222
|
+
type: "custom";
|
|
209
223
|
};
|
|
210
224
|
exportable?: boolean;
|
|
211
225
|
};
|
|
@@ -235,6 +249,8 @@ export declare const AccountUpdatedEventStruct: import("@metamask/superstruct").
|
|
|
235
249
|
groupIndex: number;
|
|
236
250
|
} | {
|
|
237
251
|
type: "private-key";
|
|
252
|
+
} | {
|
|
253
|
+
type: "custom";
|
|
238
254
|
};
|
|
239
255
|
exportable?: boolean;
|
|
240
256
|
}, null>;
|
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":"AAMA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAenD;;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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,CAAC;AACF,MAAM,MAAM,kCAAkC,GAC5C,2BAA2B,CAAC,QAAQ,CAAC,CAAC;AAExC;;;;;;;GAOG;AACH,eAAO,MAAM,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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.mjs
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-redundant-type-constituents */
|
|
2
|
-
// FIXME: This rule seems to be triggering a false positive on the `KeyringEvents`.
|
|
3
1
|
import { exactOptional, object, UuidStruct, AccountIdStruct } from "@metamask/keyring-utils";
|
|
4
2
|
import { array, boolean, literal, record, string } from "@metamask/superstruct";
|
|
5
3
|
import { CaipAssetTypeStruct, CaipAssetTypeOrIdStruct, JsonStruct } from "@metamask/utils";
|
package/dist/events.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.mjs","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,mFAAmF;AAEnF,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,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;;;;WAIG;QACH,mBAAmB,EAAE,aAAa,CAAC,OAAO,EAAE,CAAC;QAE7C;;;;;;;WAOG;QAC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AAM;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":["/* eslint-disable @typescript-eslint/no-redundant-type-constituents */\n// FIXME: This rule seems to be triggering a false positive on the `KeyringEvents`.\n\nimport {\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":"AAA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AAE,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 {\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"]}
|
package/dist/rpc.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RejectRequestResponseStruct = exports.RejectRequestRequestStruct = exports.ApproveRequestResponseStruct = exports.ApproveRequestRequestStruct = exports.SubmitRequestResponseStruct = exports.SubmitRequestRequestStruct = exports.GetRequestResponseStruct = exports.GetRequestRequestStruct = exports.ListRequestsResponseStruct = exports.ListRequestsRequestStruct = exports.ExportAccountResponseStruct = exports.ExportAccountRequestStruct = exports.DeleteAccountResponseStruct = exports.DeleteAccountRequestStruct = exports.UpdateAccountResponseStruct = exports.UpdateAccountRequestStruct = exports.FilterAccountChainsResponseStruct = exports.FilterAccountChainsStruct = exports.ResolveAccountAddressResponseStruct = exports.ResolveAccountAddressRequestStruct = exports.GetAccountBalancesResponseStruct = exports.GetAccountBalancesRequestStruct = exports.ListAccountAssetsResponseStruct = exports.ListAccountAssetsRequestStruct = exports.ListAccountTransactionsResponseStruct = exports.ListAccountTransactionsRequestStruct = exports.DiscoverAccountsResponseStruct = exports.DiscoverAccountsRequestStruct = exports.SetSelectedAccountsResponseStruct = exports.SetSelectedAccountsRequestStruct = exports.CreateAccountResponseStruct = exports.CreateAccountRequestStruct = exports.GetAccountResponseStruct = exports.GetAccountRequestStruct = exports.ListAccountsResponseStruct = exports.ListAccountsRequestStruct = exports.KeyringRpcMethod = void 0;
|
|
3
|
+
exports.RejectRequestResponseStruct = exports.RejectRequestRequestStruct = exports.ApproveRequestResponseStruct = exports.ApproveRequestRequestStruct = exports.SubmitRequestResponseStruct = exports.SubmitRequestRequestStruct = exports.GetRequestResponseStruct = exports.GetRequestRequestStruct = exports.ListRequestsResponseStruct = exports.ListRequestsRequestStruct = exports.ExportAccountResponseStruct = exports.ExportAccountRequestStruct = exports.DeleteAccountResponseStruct = exports.DeleteAccountRequestStruct = exports.UpdateAccountResponseStruct = exports.UpdateAccountRequestStruct = exports.FilterAccountChainsResponseStruct = exports.FilterAccountChainsStruct = exports.ResolveAccountAddressResponseStruct = exports.ResolveAccountAddressRequestStruct = exports.GetAccountBalancesResponseStruct = exports.GetAccountBalancesRequestStruct = exports.ListAccountAssetsResponseStruct = exports.ListAccountAssetsRequestStruct = exports.ListAccountTransactionsResponseStruct = exports.ListAccountTransactionsRequestStruct = exports.DiscoverAccountsResponseStruct = exports.DiscoverAccountsRequestStruct = exports.SetSelectedAccountsResponseStruct = exports.SetSelectedAccountsRequestStruct = exports.CreateAccountsResponseStruct = exports.CreateAccountsRequestStruct = exports.CreateAccountResponseStruct = exports.CreateAccountRequestStruct = exports.GetAccountResponseStruct = exports.GetAccountRequestStruct = exports.ListAccountsResponseStruct = exports.ListAccountsRequestStruct = exports.KeyringRpcMethod = void 0;
|
|
4
4
|
exports.isKeyringRpcMethod = isKeyringRpcMethod;
|
|
5
5
|
const keyring_utils_1 = require("@metamask/keyring-utils");
|
|
6
6
|
const superstruct_1 = require("@metamask/superstruct");
|
|
@@ -11,24 +11,29 @@ const api_1 = require("./api/index.cjs");
|
|
|
11
11
|
*/
|
|
12
12
|
var KeyringRpcMethod;
|
|
13
13
|
(function (KeyringRpcMethod) {
|
|
14
|
-
|
|
15
|
-
KeyringRpcMethod["GetAccount"] = "keyring_getAccount";
|
|
14
|
+
// Account management
|
|
16
15
|
KeyringRpcMethod["CreateAccount"] = "keyring_createAccount";
|
|
16
|
+
KeyringRpcMethod["CreateAccounts"] = "keyring_createAccounts";
|
|
17
|
+
KeyringRpcMethod["DeleteAccount"] = "keyring_deleteAccount";
|
|
17
18
|
KeyringRpcMethod["DiscoverAccounts"] = "keyring_discoverAccounts";
|
|
18
|
-
KeyringRpcMethod["
|
|
19
|
-
KeyringRpcMethod["ListAccountTransactions"] = "keyring_listAccountTransactions";
|
|
20
|
-
KeyringRpcMethod["GetAccountBalances"] = "keyring_getAccountBalances";
|
|
21
|
-
KeyringRpcMethod["ResolveAccountAddress"] = "keyring_resolveAccountAddress";
|
|
19
|
+
KeyringRpcMethod["ExportAccount"] = "keyring_exportAccount";
|
|
22
20
|
KeyringRpcMethod["FilterAccountChains"] = "keyring_filterAccountChains";
|
|
21
|
+
KeyringRpcMethod["GetAccount"] = "keyring_getAccount";
|
|
22
|
+
KeyringRpcMethod["ListAccounts"] = "keyring_listAccounts";
|
|
23
23
|
KeyringRpcMethod["UpdateAccount"] = "keyring_updateAccount";
|
|
24
|
-
|
|
25
|
-
KeyringRpcMethod["ExportAccount"] = "keyring_exportAccount";
|
|
26
|
-
KeyringRpcMethod["ListRequests"] = "keyring_listRequests";
|
|
27
|
-
KeyringRpcMethod["GetRequest"] = "keyring_getRequest";
|
|
28
|
-
KeyringRpcMethod["SubmitRequest"] = "keyring_submitRequest";
|
|
24
|
+
// Signing request management
|
|
29
25
|
KeyringRpcMethod["ApproveRequest"] = "keyring_approveRequest";
|
|
26
|
+
KeyringRpcMethod["GetRequest"] = "keyring_getRequest";
|
|
27
|
+
KeyringRpcMethod["ListRequests"] = "keyring_listRequests";
|
|
30
28
|
KeyringRpcMethod["RejectRequest"] = "keyring_rejectRequest";
|
|
29
|
+
KeyringRpcMethod["SubmitRequest"] = "keyring_submitRequest";
|
|
30
|
+
// Account assets and transactions
|
|
31
|
+
KeyringRpcMethod["GetAccountBalances"] = "keyring_getAccountBalances";
|
|
32
|
+
KeyringRpcMethod["ListAccountAssets"] = "keyring_listAccountAssets";
|
|
33
|
+
KeyringRpcMethod["ListAccountTransactions"] = "keyring_listAccountTransactions";
|
|
31
34
|
KeyringRpcMethod["SetSelectedAccounts"] = "keyring_setSelectedAccounts";
|
|
35
|
+
// Dapp interaction
|
|
36
|
+
KeyringRpcMethod["ResolveAccountAddress"] = "keyring_resolveAccountAddress";
|
|
32
37
|
})(KeyringRpcMethod || (exports.KeyringRpcMethod = KeyringRpcMethod = {}));
|
|
33
38
|
/**
|
|
34
39
|
* Check if a method is a keyring RPC method.
|
|
@@ -72,6 +77,16 @@ exports.CreateAccountRequestStruct = (0, keyring_utils_1.object)({
|
|
|
72
77
|
});
|
|
73
78
|
exports.CreateAccountResponseStruct = api_1.KeyringAccountStruct;
|
|
74
79
|
// ----------------------------------------------------------------------------
|
|
80
|
+
// Create accounts
|
|
81
|
+
exports.CreateAccountsRequestStruct = (0, keyring_utils_1.object)({
|
|
82
|
+
...CommonHeader,
|
|
83
|
+
method: (0, superstruct_1.literal)('keyring_createAccounts'),
|
|
84
|
+
params: (0, keyring_utils_1.object)({
|
|
85
|
+
options: api_1.CreateAccountOptionsStruct,
|
|
86
|
+
}),
|
|
87
|
+
});
|
|
88
|
+
exports.CreateAccountsResponseStruct = (0, superstruct_1.array)(api_1.KeyringAccountStruct);
|
|
89
|
+
// ----------------------------------------------------------------------------
|
|
75
90
|
// Set selected accounts
|
|
76
91
|
exports.SetSelectedAccountsRequestStruct = (0, keyring_utils_1.object)({
|
|
77
92
|
...CommonHeader,
|
package/dist/rpc.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc.cjs","sourceRoot":"","sources":["../src/rpc.ts"],"names":[],"mappings":";;;AA8DA,gDAEC;AAhED,2DAIiC;AAEjC,uDAQ+B;AAC/B,2CAA6C;AAE7C,yCAae;AAEf;;GAEG;AACH,IAAY,gBAmBX;AAnBD,WAAY,gBAAgB;IAC1B,yDAAqC,CAAA;IACrC,qDAAiC,CAAA;IACjC,2DAAuC,CAAA;IACvC,iEAA6C,CAAA;IAC7C,mEAA+C,CAAA;IAC/C,+EAA2D,CAAA;IAC3D,qEAAiD,CAAA;IACjD,2EAAuD,CAAA;IACvD,uEAAmD,CAAA;IACnD,2DAAuC,CAAA;IACvC,2DAAuC,CAAA;IACvC,2DAAuC,CAAA;IACvC,yDAAqC,CAAA;IACrC,qDAAiC,CAAA;IACjC,2DAAuC,CAAA;IACvC,6DAAyC,CAAA;IACzC,2DAAuC,CAAA;IACvC,uEAAmD,CAAA;AACrD,CAAC,EAnBW,gBAAgB,gCAAhB,gBAAgB,QAmB3B;AAED;;;;;GAKG;AACH,SAAgB,kBAAkB,CAAC,MAAc;IAC/C,OAAO,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,MAA0B,CAAC,CAAC;AAC9E,CAAC;AAED,+EAA+E;AAE/E,MAAM,YAAY,GAAG;IACnB,OAAO,EAAE,IAAA,qBAAO,EAAC,KAAK,CAAC;IACvB,EAAE,EAAE,IAAA,mBAAK,EAAC,CAAC,IAAA,oBAAM,GAAE,EAAE,IAAA,oBAAM,GAAE,EAAE,IAAA,qBAAO,EAAC,IAAI,CAAC,CAAC,CAAC;CAC/C,CAAC;AAEF,+EAA+E;AAC/E,gBAAgB;AAEH,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C/E,kBAAkB;AAEL,QAAA,2BAA2B,GAAG,IAAA,sBAAM,EAAC;IAChD,GAAG,YAAY;IACf,MAAM,EAAE,IAAA,qBAAO,EAAC,wBAAwB,CAAC;IACzC,MAAM,EAAE,IAAA,sBAAM,EAAC;QACb,EAAE,EAAE,0BAAU;QACd,IAAI,EAAE,IAAA,oBAAM,EAAC,IAAA,oBAAM,GAAE,EAAE,kBAAU,CAAC;KACnC,CAAC;CACH,CAAC,CAAC;AAIU,QAAA,4BAA4B,GAAG,IAAA,qBAAO,EAAC,IAAI,CAAC,CAAC;AAI1D,+EAA+E;AAC/E,iBAAiB;AAEJ,QAAA,0BAA0B,GAAG,IAAA,sBAAM,EAAC;IAC/C,GAAG,YAAY;IACf,MAAM,EAAE,IAAA,qBAAO,EAAC,uBAAuB,CAAC;IACxC,MAAM,EAAE,IAAA,sBAAM,EAAC;QACb,EAAE,EAAE,0BAAU;KACf,CAAC;CACH,CAAC,CAAC;AAIU,QAAA,2BAA2B,GAAG,IAAA,qBAAO,EAAC,IAAI,CAAC,CAAC","sourcesContent":["import {\n object,\n UuidStruct,\n JsonRpcRequestStruct,\n} from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport {\n array,\n literal,\n nullable,\n number,\n record,\n string,\n union,\n} from '@metamask/superstruct';\nimport { JsonStruct } from '@metamask/utils';\n\nimport {\n CaipAssetTypeStruct,\n CaipAssetTypeOrIdStruct,\n CaipChainIdStruct,\n BalanceStruct,\n KeyringAccountDataStruct,\n KeyringAccountStruct,\n KeyringRequestStruct,\n KeyringResponseStruct,\n TransactionsPageStruct,\n PaginationStruct,\n CaipAccountIdStruct,\n DiscoveredAccountStruct,\n} from './api';\n\n/**\n * Keyring RPC methods used by the API.\n */\nexport enum KeyringRpcMethod {\n ListAccounts = 'keyring_listAccounts',\n GetAccount = 'keyring_getAccount',\n CreateAccount = 'keyring_createAccount',\n DiscoverAccounts = 'keyring_discoverAccounts',\n ListAccountAssets = 'keyring_listAccountAssets',\n ListAccountTransactions = 'keyring_listAccountTransactions',\n GetAccountBalances = 'keyring_getAccountBalances',\n ResolveAccountAddress = 'keyring_resolveAccountAddress',\n FilterAccountChains = 'keyring_filterAccountChains',\n UpdateAccount = 'keyring_updateAccount',\n DeleteAccount = 'keyring_deleteAccount',\n ExportAccount = 'keyring_exportAccount',\n ListRequests = 'keyring_listRequests',\n GetRequest = 'keyring_getRequest',\n SubmitRequest = 'keyring_submitRequest',\n ApproveRequest = 'keyring_approveRequest',\n RejectRequest = 'keyring_rejectRequest',\n SetSelectedAccounts = 'keyring_setSelectedAccounts',\n}\n\n/**\n * Check if a method is a keyring RPC method.\n *\n * @param method - Method to check.\n * @returns Whether the method is a keyring RPC method.\n */\nexport function isKeyringRpcMethod(method: string): boolean {\n return Object.values(KeyringRpcMethod).includes(method as KeyringRpcMethod);\n}\n\n// ----------------------------------------------------------------------------\n\nconst CommonHeader = {\n jsonrpc: literal('2.0'),\n id: union([string(), number(), literal(null)]),\n};\n\n// ----------------------------------------------------------------------------\n// List accounts\n\nexport const ListAccountsRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_listAccounts'),\n});\n\nexport type ListAccountsRequest = Infer<typeof ListAccountsRequestStruct>;\n\nexport const ListAccountsResponseStruct = array(KeyringAccountStruct);\n\nexport type ListAccountsResponse = Infer<typeof ListAccountsResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Get account\n\nexport const GetAccountRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_getAccount'),\n params: object({\n id: UuidStruct,\n }),\n});\n\nexport type GetAccountRequest = Infer<typeof GetAccountRequestStruct>;\n\nexport const GetAccountResponseStruct = KeyringAccountStruct;\n\nexport type GetAccountResponse = Infer<typeof GetAccountResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Create account\n\nexport const CreateAccountRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_createAccount'),\n params: object({\n options: record(string(), JsonStruct),\n }),\n});\n\nexport type CreateAccountRequest = Infer<typeof CreateAccountRequestStruct>;\n\nexport const CreateAccountResponseStruct = KeyringAccountStruct;\n\nexport type CreateAccountResponse = Infer<typeof CreateAccountResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Set selected accounts\n\nexport const SetSelectedAccountsRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_setSelectedAccounts'),\n params: object({\n accounts: array(string()),\n }),\n});\n\nexport type SetSelectedAccountsRequest = Infer<\n typeof SetSelectedAccountsRequestStruct\n>;\n\nexport const SetSelectedAccountsResponseStruct = literal(null);\n\nexport type SetSelectedAccountsResponse = Infer<\n typeof SetSelectedAccountsResponseStruct\n>;\n\n// ----------------------------------------------------------------------------\n// Discover accounts\n\nexport const DiscoverAccountsRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_discoverAccounts'),\n params: object({\n scopes: array(CaipChainIdStruct),\n entropySource: string(),\n groupIndex: number(),\n }),\n});\n\nexport type DiscoverAccountsRequest = Infer<\n typeof DiscoverAccountsRequestStruct\n>;\n\nexport const DiscoverAccountsResponseStruct = array(DiscoveredAccountStruct);\n\nexport type DiscoverAccountsResponse = Infer<\n typeof DiscoverAccountsResponseStruct\n>;\n\n// ----------------------------------------------------------------------------\n// List account transactions\n\nexport const ListAccountTransactionsRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_listAccountTransactions'),\n params: object({\n id: UuidStruct,\n pagination: PaginationStruct,\n }),\n});\n\nexport type ListAccountTransactionsRequest = Infer<\n typeof ListAccountTransactionsRequestStruct\n>;\n\nexport const ListAccountTransactionsResponseStruct = TransactionsPageStruct;\n\nexport type ListAccountTransactionsResponse = Infer<\n typeof ListAccountTransactionsResponseStruct\n>;\n\n// ----------------------------------------------------------------------------\n// List account assets\n\nexport const ListAccountAssetsRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_listAccountAssets'),\n params: object({\n id: UuidStruct,\n }),\n});\n\nexport type ListAccountAssetsRequest = Infer<\n typeof ListAccountAssetsRequestStruct\n>;\n\nexport const ListAccountAssetsResponseStruct = array(CaipAssetTypeOrIdStruct);\n\nexport type ListAccountAssetsResponse = Infer<\n typeof ListAccountAssetsResponseStruct\n>;\n\n// ----------------------------------------------------------------------------\n// Get account balances\n\nexport const GetAccountBalancesRequestStruct = object({\n ...CommonHeader,\n method: literal(`${KeyringRpcMethod.GetAccountBalances}`),\n params: object({\n id: UuidStruct,\n assets: array(CaipAssetTypeStruct),\n }),\n});\n\nexport type GetAccountBalancesRequest = Infer<\n typeof GetAccountBalancesRequestStruct\n>;\n\nexport const GetAccountBalancesResponseStruct = record(\n CaipAssetTypeStruct,\n BalanceStruct,\n);\n\nexport type GetAccountBalancesResponse = Infer<\n typeof GetAccountBalancesResponseStruct\n>;\n\n// ----------------------------------------------------------------------------\n// Resolve account address\n\nexport const ResolveAccountAddressRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_resolveAccountAddress'),\n params: object({\n scope: CaipChainIdStruct,\n request: JsonRpcRequestStruct,\n }),\n});\n\nexport type ResolveAccountAddressRequest = Infer<\n typeof ResolveAccountAddressRequestStruct\n>;\n\nexport const ResolveAccountAddressResponseStruct = nullable(\n object({\n address: CaipAccountIdStruct,\n }),\n);\n\nexport type ResolveAccountAddressResponse = Infer<\n typeof ResolveAccountAddressResponseStruct\n>;\n\n// ----------------------------------------------------------------------------\n// Filter account chains\n\nexport const FilterAccountChainsStruct = object({\n ...CommonHeader,\n method: literal('keyring_filterAccountChains'),\n params: object({\n id: UuidStruct,\n chains: array(string()),\n }),\n});\n\nexport type FilterAccountChainsRequest = Infer<\n typeof FilterAccountChainsStruct\n>;\n\nexport const FilterAccountChainsResponseStruct = array(string());\n\nexport type FilterAccountChainsResponse = Infer<\n typeof FilterAccountChainsResponseStruct\n>;\n\n// ----------------------------------------------------------------------------\n// Update account\n\nexport const UpdateAccountRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_updateAccount'),\n params: object({\n account: KeyringAccountStruct,\n }),\n});\n\nexport type UpdateAccountRequest = Infer<typeof UpdateAccountRequestStruct>;\n\nexport const UpdateAccountResponseStruct = literal(null);\n\nexport type UpdateAccountResponse = Infer<typeof UpdateAccountResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Delete account\n\nexport const DeleteAccountRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_deleteAccount'),\n params: object({\n id: UuidStruct,\n }),\n});\n\nexport type DeleteAccountRequest = Infer<typeof DeleteAccountRequestStruct>;\n\nexport const DeleteAccountResponseStruct = literal(null);\n\nexport type DeleteAccountResponse = Infer<typeof DeleteAccountResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Export account\n\nexport const ExportAccountRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_exportAccount'),\n params: object({\n id: UuidStruct,\n }),\n});\n\nexport type ExportAccountRequest = Infer<typeof ExportAccountRequestStruct>;\n\nexport const ExportAccountResponseStruct = KeyringAccountDataStruct;\n\nexport type ExportAccountResponse = Infer<typeof ExportAccountResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// List requests\n\nexport const ListRequestsRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_listRequests'),\n});\n\nexport type ListRequestsRequest = Infer<typeof ListRequestsRequestStruct>;\n\nexport const ListRequestsResponseStruct = array(KeyringRequestStruct);\n\nexport type ListRequestsResponse = Infer<typeof ListRequestsResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Get request\n\nexport const GetRequestRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_getRequest'),\n params: object({\n id: UuidStruct,\n }),\n});\n\nexport type GetRequestRequest = Infer<typeof GetRequestRequestStruct>;\n\nexport const GetRequestResponseStruct = KeyringRequestStruct;\n\nexport type GetRequestResponse = Infer<typeof GetRequestResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Submit request\n\nexport const SubmitRequestRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_submitRequest'),\n params: KeyringRequestStruct,\n});\n\nexport type SubmitRequestRequest = Infer<typeof SubmitRequestRequestStruct>;\n\nexport const SubmitRequestResponseStruct = KeyringResponseStruct;\n\nexport type SubmitRequestResponse = Infer<typeof SubmitRequestResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Approve request\n\nexport const ApproveRequestRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_approveRequest'),\n params: object({\n id: UuidStruct,\n data: record(string(), JsonStruct),\n }),\n});\n\nexport type ApproveRequestRequest = Infer<typeof ApproveRequestRequestStruct>;\n\nexport const ApproveRequestResponseStruct = literal(null);\n\nexport type ApproveRequestResponse = Infer<typeof ApproveRequestResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Reject request\n\nexport const RejectRequestRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_rejectRequest'),\n params: object({\n id: UuidStruct,\n }),\n});\n\nexport type RejectRequestRequest = Infer<typeof RejectRequestRequestStruct>;\n\nexport const RejectRequestResponseStruct = literal(null);\n\nexport type RejectRequestResponse = Infer<typeof RejectRequestResponseStruct>;\n"]}
|
|
1
|
+
{"version":3,"file":"rpc.cjs","sourceRoot":"","sources":["../src/rpc.ts"],"names":[],"mappings":";;;AAuEA,gDAEC;AAzED,2DAIiC;AAEjC,uDAQ+B;AAC/B,2CAA6C;AAE7C,yCAce;AAEf;;GAEG;AACH,IAAY,gBA2BX;AA3BD,WAAY,gBAAgB;IAC1B,qBAAqB;IACrB,2DAAuC,CAAA;IACvC,6DAAyC,CAAA;IACzC,2DAAuC,CAAA;IACvC,iEAA6C,CAAA;IAC7C,2DAAuC,CAAA;IACvC,uEAAmD,CAAA;IACnD,qDAAiC,CAAA;IACjC,yDAAqC,CAAA;IACrC,2DAAuC,CAAA;IAEvC,6BAA6B;IAC7B,6DAAyC,CAAA;IACzC,qDAAiC,CAAA;IACjC,yDAAqC,CAAA;IACrC,2DAAuC,CAAA;IACvC,2DAAuC,CAAA;IAEvC,kCAAkC;IAClC,qEAAiD,CAAA;IACjD,mEAA+C,CAAA;IAC/C,+EAA2D,CAAA;IAC3D,uEAAmD,CAAA;IAEnD,mBA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AM,EAAC;IAC/C,GAAG,YAAY;IACf,MAAM,EAAE,IAAA,qBAAO,EAAC,uBAAuB,CAAC;IACxC,MAAM,EAAE,IAAA,sBAAM,EAAC;QACb,EAAE,EAAE,0BAAU;KACf,CAAC;CACH,CAAC,CAAC;AAIU,QAAA,2BAA2B,GAAG,IAAA,qBAAO,EAAC,IAAI,CAAC,CAAC","sourcesContent":["import {\n object,\n UuidStruct,\n JsonRpcRequestStruct,\n} from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport {\n array,\n literal,\n nullable,\n number,\n record,\n string,\n union,\n} from '@metamask/superstruct';\nimport { JsonStruct } from '@metamask/utils';\n\nimport {\n CaipAssetTypeStruct,\n CaipAssetTypeOrIdStruct,\n CaipChainIdStruct,\n BalanceStruct,\n KeyringAccountDataStruct,\n KeyringAccountStruct,\n KeyringRequestStruct,\n KeyringResponseStruct,\n TransactionsPageStruct,\n PaginationStruct,\n CaipAccountIdStruct,\n DiscoveredAccountStruct,\n CreateAccountOptionsStruct,\n} from './api';\n\n/**\n * Keyring RPC methods used by the API.\n */\nexport enum KeyringRpcMethod {\n // Account management\n CreateAccount = 'keyring_createAccount',\n CreateAccounts = 'keyring_createAccounts',\n DeleteAccount = 'keyring_deleteAccount',\n DiscoverAccounts = 'keyring_discoverAccounts',\n ExportAccount = 'keyring_exportAccount',\n FilterAccountChains = 'keyring_filterAccountChains',\n GetAccount = 'keyring_getAccount',\n ListAccounts = 'keyring_listAccounts',\n UpdateAccount = 'keyring_updateAccount',\n\n // Signing request management\n ApproveRequest = 'keyring_approveRequest',\n GetRequest = 'keyring_getRequest',\n ListRequests = 'keyring_listRequests',\n RejectRequest = 'keyring_rejectRequest',\n SubmitRequest = 'keyring_submitRequest',\n\n // Account assets and transactions\n GetAccountBalances = 'keyring_getAccountBalances',\n ListAccountAssets = 'keyring_listAccountAssets',\n ListAccountTransactions = 'keyring_listAccountTransactions',\n SetSelectedAccounts = 'keyring_setSelectedAccounts',\n\n // Dapp interaction\n ResolveAccountAddress = 'keyring_resolveAccountAddress',\n}\n\n/**\n * Check if a method is a keyring RPC method.\n *\n * @param method - Method to check.\n * @returns Whether the method is a keyring RPC method.\n */\nexport function isKeyringRpcMethod(method: string): boolean {\n return Object.values(KeyringRpcMethod).includes(method as KeyringRpcMethod);\n}\n\n// ----------------------------------------------------------------------------\n\nconst CommonHeader = {\n jsonrpc: literal('2.0'),\n id: union([string(), number(), literal(null)]),\n};\n\n// ----------------------------------------------------------------------------\n// List accounts\n\nexport const ListAccountsRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_listAccounts'),\n});\n\nexport type ListAccountsRequest = Infer<typeof ListAccountsRequestStruct>;\n\nexport const ListAccountsResponseStruct = array(KeyringAccountStruct);\n\nexport type ListAccountsResponse = Infer<typeof ListAccountsResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Get account\n\nexport const GetAccountRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_getAccount'),\n params: object({\n id: UuidStruct,\n }),\n});\n\nexport type GetAccountRequest = Infer<typeof GetAccountRequestStruct>;\n\nexport const GetAccountResponseStruct = KeyringAccountStruct;\n\nexport type GetAccountResponse = Infer<typeof GetAccountResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Create account\n\nexport const CreateAccountRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_createAccount'),\n params: object({\n options: record(string(), JsonStruct),\n }),\n});\n\nexport type CreateAccountRequest = Infer<typeof CreateAccountRequestStruct>;\n\nexport const CreateAccountResponseStruct = KeyringAccountStruct;\n\nexport type CreateAccountResponse = Infer<typeof CreateAccountResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Create accounts\n\nexport const CreateAccountsRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_createAccounts'),\n params: object({\n options: CreateAccountOptionsStruct,\n }),\n});\n\nexport type CreateAccountsRequest = Infer<typeof CreateAccountsRequestStruct>;\n\nexport const CreateAccountsResponseStruct = array(KeyringAccountStruct);\n\nexport type CreateAccountsResponse = Infer<typeof CreateAccountsResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Set selected accounts\n\nexport const SetSelectedAccountsRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_setSelectedAccounts'),\n params: object({\n accounts: array(string()),\n }),\n});\n\nexport type SetSelectedAccountsRequest = Infer<\n typeof SetSelectedAccountsRequestStruct\n>;\n\nexport const SetSelectedAccountsResponseStruct = literal(null);\n\nexport type SetSelectedAccountsResponse = Infer<\n typeof SetSelectedAccountsResponseStruct\n>;\n\n// ----------------------------------------------------------------------------\n// Discover accounts\n\nexport const DiscoverAccountsRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_discoverAccounts'),\n params: object({\n scopes: array(CaipChainIdStruct),\n entropySource: string(),\n groupIndex: number(),\n }),\n});\n\nexport type DiscoverAccountsRequest = Infer<\n typeof DiscoverAccountsRequestStruct\n>;\n\nexport const DiscoverAccountsResponseStruct = array(DiscoveredAccountStruct);\n\nexport type DiscoverAccountsResponse = Infer<\n typeof DiscoverAccountsResponseStruct\n>;\n\n// ----------------------------------------------------------------------------\n// List account transactions\n\nexport const ListAccountTransactionsRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_listAccountTransactions'),\n params: object({\n id: UuidStruct,\n pagination: PaginationStruct,\n }),\n});\n\nexport type ListAccountTransactionsRequest = Infer<\n typeof ListAccountTransactionsRequestStruct\n>;\n\nexport const ListAccountTransactionsResponseStruct = TransactionsPageStruct;\n\nexport type ListAccountTransactionsResponse = Infer<\n typeof ListAccountTransactionsResponseStruct\n>;\n\n// ----------------------------------------------------------------------------\n// List account assets\n\nexport const ListAccountAssetsRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_listAccountAssets'),\n params: object({\n id: UuidStruct,\n }),\n});\n\nexport type ListAccountAssetsRequest = Infer<\n typeof ListAccountAssetsRequestStruct\n>;\n\nexport const ListAccountAssetsResponseStruct = array(CaipAssetTypeOrIdStruct);\n\nexport type ListAccountAssetsResponse = Infer<\n typeof ListAccountAssetsResponseStruct\n>;\n\n// ----------------------------------------------------------------------------\n// Get account balances\n\nexport const GetAccountBalancesRequestStruct = object({\n ...CommonHeader,\n method: literal(`${KeyringRpcMethod.GetAccountBalances}`),\n params: object({\n id: UuidStruct,\n assets: array(CaipAssetTypeStruct),\n }),\n});\n\nexport type GetAccountBalancesRequest = Infer<\n typeof GetAccountBalancesRequestStruct\n>;\n\nexport const GetAccountBalancesResponseStruct = record(\n CaipAssetTypeStruct,\n BalanceStruct,\n);\n\nexport type GetAccountBalancesResponse = Infer<\n typeof GetAccountBalancesResponseStruct\n>;\n\n// ----------------------------------------------------------------------------\n// Resolve account address\n\nexport const ResolveAccountAddressRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_resolveAccountAddress'),\n params: object({\n scope: CaipChainIdStruct,\n request: JsonRpcRequestStruct,\n }),\n});\n\nexport type ResolveAccountAddressRequest = Infer<\n typeof ResolveAccountAddressRequestStruct\n>;\n\nexport const ResolveAccountAddressResponseStruct = nullable(\n object({\n address: CaipAccountIdStruct,\n }),\n);\n\nexport type ResolveAccountAddressResponse = Infer<\n typeof ResolveAccountAddressResponseStruct\n>;\n\n// ----------------------------------------------------------------------------\n// Filter account chains\n\nexport const FilterAccountChainsStruct = object({\n ...CommonHeader,\n method: literal('keyring_filterAccountChains'),\n params: object({\n id: UuidStruct,\n chains: array(string()),\n }),\n});\n\nexport type FilterAccountChainsRequest = Infer<\n typeof FilterAccountChainsStruct\n>;\n\nexport const FilterAccountChainsResponseStruct = array(string());\n\nexport type FilterAccountChainsResponse = Infer<\n typeof FilterAccountChainsResponseStruct\n>;\n\n// ----------------------------------------------------------------------------\n// Update account\n\nexport const UpdateAccountRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_updateAccount'),\n params: object({\n account: KeyringAccountStruct,\n }),\n});\n\nexport type UpdateAccountRequest = Infer<typeof UpdateAccountRequestStruct>;\n\nexport const UpdateAccountResponseStruct = literal(null);\n\nexport type UpdateAccountResponse = Infer<typeof UpdateAccountResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Delete account\n\nexport const DeleteAccountRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_deleteAccount'),\n params: object({\n id: UuidStruct,\n }),\n});\n\nexport type DeleteAccountRequest = Infer<typeof DeleteAccountRequestStruct>;\n\nexport const DeleteAccountResponseStruct = literal(null);\n\nexport type DeleteAccountResponse = Infer<typeof DeleteAccountResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Export account\n\nexport const ExportAccountRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_exportAccount'),\n params: object({\n id: UuidStruct,\n }),\n});\n\nexport type ExportAccountRequest = Infer<typeof ExportAccountRequestStruct>;\n\nexport const ExportAccountResponseStruct = KeyringAccountDataStruct;\n\nexport type ExportAccountResponse = Infer<typeof ExportAccountResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// List requests\n\nexport const ListRequestsRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_listRequests'),\n});\n\nexport type ListRequestsRequest = Infer<typeof ListRequestsRequestStruct>;\n\nexport const ListRequestsResponseStruct = array(KeyringRequestStruct);\n\nexport type ListRequestsResponse = Infer<typeof ListRequestsResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Get request\n\nexport const GetRequestRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_getRequest'),\n params: object({\n id: UuidStruct,\n }),\n});\n\nexport type GetRequestRequest = Infer<typeof GetRequestRequestStruct>;\n\nexport const GetRequestResponseStruct = KeyringRequestStruct;\n\nexport type GetRequestResponse = Infer<typeof GetRequestResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Submit request\n\nexport const SubmitRequestRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_submitRequest'),\n params: KeyringRequestStruct,\n});\n\nexport type SubmitRequestRequest = Infer<typeof SubmitRequestRequestStruct>;\n\nexport const SubmitRequestResponseStruct = KeyringResponseStruct;\n\nexport type SubmitRequestResponse = Infer<typeof SubmitRequestResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Approve request\n\nexport const ApproveRequestRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_approveRequest'),\n params: object({\n id: UuidStruct,\n data: record(string(), JsonStruct),\n }),\n});\n\nexport type ApproveRequestRequest = Infer<typeof ApproveRequestRequestStruct>;\n\nexport const ApproveRequestResponseStruct = literal(null);\n\nexport type ApproveRequestResponse = Infer<typeof ApproveRequestResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Reject request\n\nexport const RejectRequestRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_rejectRequest'),\n params: object({\n id: UuidStruct,\n }),\n});\n\nexport type RejectRequestRequest = Infer<typeof RejectRequestRequestStruct>;\n\nexport const RejectRequestResponseStruct = literal(null);\n\nexport type RejectRequestResponse = Infer<typeof RejectRequestResponseStruct>;\n"]}
|