@metamask/keyring-api 20.1.0 → 20.1.1
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 +8 -1
- package/dist/btc/types.cjs +10 -3
- package/dist/btc/types.cjs.map +1 -1
- package/dist/btc/types.d.cts +53 -13
- package/dist/btc/types.d.cts.map +1 -1
- package/dist/btc/types.d.mts +53 -13
- package/dist/btc/types.d.mts.map +1 -1
- package/dist/btc/types.mjs +10 -3
- package/dist/btc/types.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
7
7
|
|
8
8
|
## [Unreleased]
|
9
9
|
|
10
|
+
## [20.1.1]
|
11
|
+
|
12
|
+
### Added
|
13
|
+
|
14
|
+
- Add new bitcoin methods to `BtcMethod` enum ([#354](https://github.com/MetaMask/accounts/pull/354))
|
15
|
+
|
10
16
|
## [20.1.0]
|
11
17
|
|
12
18
|
### Added
|
@@ -612,7 +618,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
612
618
|
- SnapController keyring client. It is intended to be used by MetaMask to talk to the snap.
|
613
619
|
- Helper functions to create keyring handler in the snap.
|
614
620
|
|
615
|
-
[Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@20.1.
|
621
|
+
[Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@20.1.1...HEAD
|
622
|
+
[20.1.1]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@20.1.0...@metamask/keyring-api@20.1.1
|
616
623
|
[20.1.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@20.0.0...@metamask/keyring-api@20.1.0
|
617
624
|
[20.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@19.1.0...@metamask/keyring-api@20.0.0
|
618
625
|
[19.1.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@19.0.0...@metamask/keyring-api@19.1.0
|
package/dist/btc/types.cjs
CHANGED
@@ -34,8 +34,15 @@ exports.BtcP2trAddressStruct = (0, superstruct_1.refine)((0, superstruct_1.strin
|
|
34
34
|
*/
|
35
35
|
var BtcMethod;
|
36
36
|
(function (BtcMethod) {
|
37
|
-
|
38
|
-
BtcMethod["
|
37
|
+
BtcMethod["SignPsbt"] = "signPsbt";
|
38
|
+
BtcMethod["ComputeFee"] = "computeFee";
|
39
|
+
BtcMethod["FillPsbt"] = "fillPsbt";
|
40
|
+
BtcMethod["BroadcastPsbt"] = "broadcastPsbt";
|
41
|
+
BtcMethod["SendTransfer"] = "sendTransfer";
|
42
|
+
BtcMethod["GetUtxo"] = "getUtxo";
|
43
|
+
BtcMethod["ListUtxos"] = "listUtxos";
|
44
|
+
BtcMethod["PublicDescriptor"] = "publicDescriptor";
|
45
|
+
BtcMethod["SignMessage"] = "signMessage";
|
39
46
|
})(BtcMethod || (exports.BtcMethod = BtcMethod = {}));
|
40
47
|
const BtcAccountStruct = (0, keyring_utils_1.object)({
|
41
48
|
...api_1.KeyringAccountStruct.schema,
|
@@ -46,7 +53,7 @@ const BtcAccountStruct = (0, keyring_utils_1.object)({
|
|
46
53
|
/**
|
47
54
|
* Account supported methods.
|
48
55
|
*/
|
49
|
-
methods: (0, superstruct_1.array)((0, superstruct_1.enums)(
|
56
|
+
methods: (0, superstruct_1.array)((0, superstruct_1.enums)(Object.values(BtcMethod))),
|
50
57
|
});
|
51
58
|
exports.BtcP2pkhAccountStruct = (0, keyring_utils_1.object)({
|
52
59
|
...BtcAccountStruct.schema,
|
package/dist/btc/types.cjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../src/btc/types.ts"],"names":[],"mappings":";;;AAAA,2DAAiD;AAEjD,uDAO+B;AAC/B,2EAAyE;AAEzE,0CAIgB;AAEhB,MAAM,eAAe,GAAG,CACtB,OAAe,EACf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gBAAgB,CAAC,MAAM;IAE1B;;OAEG;IACH,OAAO,EAAE,8BAAsB;IAE/B;;OAEG;IACH,IAAI,EAAE,IAAA,qBAAO,EAAC,GAAG,oBAAc,CAAC,MAAM,EAAE,CAAC;CAC1C,CAAC,CAAC;AAEU,QAAA,oBAAoB,GAAG,IAAA,sBAAM,EAAC;IACzC,GAAG,gBAAgB,CAAC,MAAM;IAE1B;;OAEG;IACH,OAAO,EAAE,4BAAoB;IAE7B;;OAEG;IACH,IAAI,EAAE,IAAA,qBAAO,EAAC,GAAG,oBAAc,CAAC,IAAI,EAAE,CAAC;CACxC,CAAC,CAAC","sourcesContent":["import { object } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport {\n string,\n array,\n enums,\n refine,\n literal,\n nonempty,\n} from '@metamask/superstruct';\nimport { AddressType, getAddressInfo } from 'bitcoin-address-validation';\n\nimport {\n BtcAccountType,\n CaipChainIdStruct,\n KeyringAccountStruct,\n} from '../api';\n\nconst validateAddress = (\n address: string,\n type: AddressType,\n): boolean | Error => {\n try {\n const addressInfo = getAddressInfo(address);\n if (addressInfo.type === type) {\n return true;\n }\n return new Error(`Invalid ${type} address`);\n } catch (error) {\n return new Error(\n `Failed to decode ${type} address: ${(error as Error).message}`,\n );\n }\n};\n\nexport const BtcP2pkhAddressStruct = refine(\n string(),\n 'BtcP2pkhAddressStruct',\n (address: string) => {\n return validateAddress(address, AddressType.p2pkh);\n },\n);\n\nexport const BtcP2shAddressStruct = refine(\n string(),\n 'BtcP2shAddressStruct',\n (address: string) => {\n return validateAddress(address, AddressType.p2sh);\n },\n);\n\nexport const BtcP2wpkhAddressStruct = refine(\n string(),\n 'BtcP2wpkhAddressStruct',\n (address: string) => {\n return validateAddress(address, AddressType.p2wpkh);\n },\n);\n\nexport const BtcP2trAddressStruct = refine(\n string(),\n 'BtcP2trAddressStruct',\n (address: string) => {\n return validateAddress(address, AddressType.p2tr);\n },\n);\n\n/**\n * Supported Bitcoin methods.\n */\nexport enum BtcMethod {\n SignPsbt = 'signPsbt',\n ComputeFee = 'computeFee',\n FillPsbt = 'fillPsbt',\n BroadcastPsbt = 'broadcastPsbt',\n SendTransfer = 'sendTransfer',\n GetUtxo = 'getUtxo',\n ListUtxos = 'listUtxos',\n PublicDescriptor = 'publicDescriptor',\n SignMessage = 'signMessage',\n}\n\nconst BtcAccountStruct = object({\n ...KeyringAccountStruct.schema,\n\n /**\n * Account supported scopes (CAIP-2 chain ID).\n */\n scopes: nonempty(array(CaipChainIdStruct)),\n\n /**\n * Account supported methods.\n */\n methods: array(enums(Object.values(BtcMethod))),\n});\n\nexport const BtcP2pkhAccountStruct = object({\n ...BtcAccountStruct.schema,\n\n /**\n * Account P2PKH address.\n */\n address: BtcP2pkhAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${BtcAccountType.P2pkh}`),\n});\n\nexport const BtcP2shAccountStruct = object({\n ...BtcAccountStruct.schema,\n\n /**\n * Account P2SH address.\n */\n address: BtcP2shAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${BtcAccountType.P2sh}`),\n});\n\nexport const BtcP2wpkhAccountStruct = object({\n ...BtcAccountStruct.schema,\n\n /**\n * Account P2WPKH address.\n */\n address: BtcP2wpkhAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${BtcAccountType.P2wpkh}`),\n});\n\nexport const BtcP2trAccountStruct = object({\n ...BtcAccountStruct.schema,\n\n /**\n * Account P2TR address.\n */\n address: BtcP2trAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${BtcAccountType.P2tr}`),\n});\n\nexport type BtcP2pkhAccount = Infer<typeof BtcP2pkhAccountStruct>;\nexport type BtcP2shAccount = Infer<typeof BtcP2shAccountStruct>;\nexport type BtcP2wpkhAccount = Infer<typeof BtcP2wpkhAccountStruct>;\nexport type BtcP2trAccount = Infer<typeof BtcP2trAccountStruct>;\n"]}
|
package/dist/btc/types.d.cts
CHANGED
@@ -7,7 +7,15 @@ export declare const BtcP2trAddressStruct: import("@metamask/superstruct").Struc
|
|
7
7
|
* Supported Bitcoin methods.
|
8
8
|
*/
|
9
9
|
export declare enum BtcMethod {
|
10
|
-
|
10
|
+
SignPsbt = "signPsbt",
|
11
|
+
ComputeFee = "computeFee",
|
12
|
+
FillPsbt = "fillPsbt",
|
13
|
+
BroadcastPsbt = "broadcastPsbt",
|
14
|
+
SendTransfer = "sendTransfer",
|
15
|
+
GetUtxo = "getUtxo",
|
16
|
+
ListUtxos = "listUtxos",
|
17
|
+
PublicDescriptor = "publicDescriptor",
|
18
|
+
SignMessage = "signMessage"
|
11
19
|
}
|
12
20
|
export declare const BtcP2pkhAccountStruct: import("@metamask/superstruct").Struct<{
|
13
21
|
type: "bip122:p2pkh";
|
@@ -25,7 +33,7 @@ export declare const BtcP2pkhAccountStruct: import("@metamask/superstruct").Stru
|
|
25
33
|
};
|
26
34
|
address: string;
|
27
35
|
scopes: `${string}:${string}`[];
|
28
|
-
methods:
|
36
|
+
methods: BtcMethod[];
|
29
37
|
}, {
|
30
38
|
/**
|
31
39
|
* Account P2PKH address.
|
@@ -42,8 +50,16 @@ export declare const BtcP2pkhAccountStruct: import("@metamask/superstruct").Stru
|
|
42
50
|
/**
|
43
51
|
* Account supported methods.
|
44
52
|
*/
|
45
|
-
methods: import("@metamask/superstruct").Struct<
|
46
|
-
|
53
|
+
methods: import("@metamask/superstruct").Struct<BtcMethod[], import("@metamask/superstruct").Struct<BtcMethod, {
|
54
|
+
signPsbt: BtcMethod.SignPsbt;
|
55
|
+
computeFee: BtcMethod.ComputeFee;
|
56
|
+
fillPsbt: BtcMethod.FillPsbt;
|
57
|
+
broadcastPsbt: BtcMethod.BroadcastPsbt;
|
58
|
+
sendTransfer: BtcMethod.SendTransfer;
|
59
|
+
getUtxo: BtcMethod.GetUtxo;
|
60
|
+
listUtxos: BtcMethod.ListUtxos;
|
61
|
+
publicDescriptor: BtcMethod.PublicDescriptor;
|
62
|
+
signMessage: BtcMethod.SignMessage;
|
47
63
|
}>>;
|
48
64
|
id: import("@metamask/superstruct").Struct<string, null>;
|
49
65
|
options: import("@metamask/superstruct").Struct<Record<string, import("@metamask/utils").Json> & {
|
@@ -74,7 +90,7 @@ export declare const BtcP2shAccountStruct: import("@metamask/superstruct").Struc
|
|
74
90
|
};
|
75
91
|
address: string;
|
76
92
|
scopes: `${string}:${string}`[];
|
77
|
-
methods:
|
93
|
+
methods: BtcMethod[];
|
78
94
|
}, {
|
79
95
|
/**
|
80
96
|
* Account P2SH address.
|
@@ -91,8 +107,16 @@ export declare const BtcP2shAccountStruct: import("@metamask/superstruct").Struc
|
|
91
107
|
/**
|
92
108
|
* Account supported methods.
|
93
109
|
*/
|
94
|
-
methods: import("@metamask/superstruct").Struct<
|
95
|
-
|
110
|
+
methods: import("@metamask/superstruct").Struct<BtcMethod[], import("@metamask/superstruct").Struct<BtcMethod, {
|
111
|
+
signPsbt: BtcMethod.SignPsbt;
|
112
|
+
computeFee: BtcMethod.ComputeFee;
|
113
|
+
fillPsbt: BtcMethod.FillPsbt;
|
114
|
+
broadcastPsbt: BtcMethod.BroadcastPsbt;
|
115
|
+
sendTransfer: BtcMethod.SendTransfer;
|
116
|
+
getUtxo: BtcMethod.GetUtxo;
|
117
|
+
listUtxos: BtcMethod.ListUtxos;
|
118
|
+
publicDescriptor: BtcMethod.PublicDescriptor;
|
119
|
+
signMessage: BtcMethod.SignMessage;
|
96
120
|
}>>;
|
97
121
|
id: import("@metamask/superstruct").Struct<string, null>;
|
98
122
|
options: import("@metamask/superstruct").Struct<Record<string, import("@metamask/utils").Json> & {
|
@@ -123,7 +147,7 @@ export declare const BtcP2wpkhAccountStruct: import("@metamask/superstruct").Str
|
|
123
147
|
};
|
124
148
|
address: string;
|
125
149
|
scopes: `${string}:${string}`[];
|
126
|
-
methods:
|
150
|
+
methods: BtcMethod[];
|
127
151
|
}, {
|
128
152
|
/**
|
129
153
|
* Account P2WPKH address.
|
@@ -140,8 +164,16 @@ export declare const BtcP2wpkhAccountStruct: import("@metamask/superstruct").Str
|
|
140
164
|
/**
|
141
165
|
* Account supported methods.
|
142
166
|
*/
|
143
|
-
methods: import("@metamask/superstruct").Struct<
|
144
|
-
|
167
|
+
methods: import("@metamask/superstruct").Struct<BtcMethod[], import("@metamask/superstruct").Struct<BtcMethod, {
|
168
|
+
signPsbt: BtcMethod.SignPsbt;
|
169
|
+
computeFee: BtcMethod.ComputeFee;
|
170
|
+
fillPsbt: BtcMethod.FillPsbt;
|
171
|
+
broadcastPsbt: BtcMethod.BroadcastPsbt;
|
172
|
+
sendTransfer: BtcMethod.SendTransfer;
|
173
|
+
getUtxo: BtcMethod.GetUtxo;
|
174
|
+
listUtxos: BtcMethod.ListUtxos;
|
175
|
+
publicDescriptor: BtcMethod.PublicDescriptor;
|
176
|
+
signMessage: BtcMethod.SignMessage;
|
145
177
|
}>>;
|
146
178
|
id: import("@metamask/superstruct").Struct<string, null>;
|
147
179
|
options: import("@metamask/superstruct").Struct<Record<string, import("@metamask/utils").Json> & {
|
@@ -172,7 +204,7 @@ export declare const BtcP2trAccountStruct: import("@metamask/superstruct").Struc
|
|
172
204
|
};
|
173
205
|
address: string;
|
174
206
|
scopes: `${string}:${string}`[];
|
175
|
-
methods:
|
207
|
+
methods: BtcMethod[];
|
176
208
|
}, {
|
177
209
|
/**
|
178
210
|
* Account P2TR address.
|
@@ -189,8 +221,16 @@ export declare const BtcP2trAccountStruct: import("@metamask/superstruct").Struc
|
|
189
221
|
/**
|
190
222
|
* Account supported methods.
|
191
223
|
*/
|
192
|
-
methods: import("@metamask/superstruct").Struct<
|
193
|
-
|
224
|
+
methods: import("@metamask/superstruct").Struct<BtcMethod[], import("@metamask/superstruct").Struct<BtcMethod, {
|
225
|
+
signPsbt: BtcMethod.SignPsbt;
|
226
|
+
computeFee: BtcMethod.ComputeFee;
|
227
|
+
fillPsbt: BtcMethod.FillPsbt;
|
228
|
+
broadcastPsbt: BtcMethod.BroadcastPsbt;
|
229
|
+
sendTransfer: BtcMethod.SendTransfer;
|
230
|
+
getUtxo: BtcMethod.GetUtxo;
|
231
|
+
listUtxos: BtcMethod.ListUtxos;
|
232
|
+
publicDescriptor: BtcMethod.PublicDescriptor;
|
233
|
+
signMessage: BtcMethod.SignMessage;
|
194
234
|
}>>;
|
195
235
|
id: import("@metamask/superstruct").Struct<string, null>;
|
196
236
|
options: import("@metamask/superstruct").Struct<Record<string, import("@metamask/utils").Json> & {
|
package/dist/btc/types.d.cts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../src/btc/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAkCnD,eAAO,MAAM,qBAAqB,sDAMjC,CAAC;AAEF,eAAO,MAAM,oBAAoB,sDAMhC,CAAC;AAEF,eAAO,MAAM,sBAAsB,sDAMlC,CAAC;AAEF,eAAO,MAAM,oBAAoB,sDAMhC,CAAC;AAEF;;GAEG;AACH,oBAAY,SAAS;
|
1
|
+
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../src/btc/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAkCnD,eAAO,MAAM,qBAAqB,sDAMjC,CAAC;AAEF,eAAO,MAAM,oBAAoB,sDAMhC,CAAC;AAEF,eAAO,MAAM,sBAAsB,sDAMlC,CAAC;AAEF,eAAO,MAAM,oBAAoB,sDAMhC,CAAC;AAEF;;GAEG;AACH,oBAAY,SAAS;IACnB,QAAQ,aAAa;IACrB,UAAU,eAAe;IACzB,QAAQ,aAAa;IACrB,aAAa,kBAAkB;IAC/B,YAAY,iBAAiB;IAC7B,OAAO,YAAY;IACnB,SAAS,cAAc;IACvB,gBAAgB,qBAAqB;IACrC,WAAW,gBAAgB;CAC5B;AAgBD,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;IAGhC;;OAEG;;IAGH;;OAEG;;IArBH;;OAEG;;IAGH;;OAEG;;;;;;;;;;;;;;;;;;;;;;;;EAgBH,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;IAG/B;;OAEG;;IAGH;;OAEG;;IAnCH;;OAEG;;IAGH;;OAEG;;;;;;;;;;;;;;;;;;;;;;;;EA8BH,CAAC;AAEH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;IAGjC;;OAEG;;IAGH;;OAEG;;IAjDH;;OAEG;;IAGH;;OAEG;;;;;;;;;;;;;;;;;;;;;;;;EA4CH,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;IAG/B;;OAEG;;IAGH;;OAEG;;IA/DH;;OAEG;;IAGH;;OAEG;;;;;;;;;;;;;;;;;;;;;;;;EA0DH,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAClE,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAChE,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACpE,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
package/dist/btc/types.d.mts
CHANGED
@@ -7,7 +7,15 @@ export declare const BtcP2trAddressStruct: import("@metamask/superstruct").Struc
|
|
7
7
|
* Supported Bitcoin methods.
|
8
8
|
*/
|
9
9
|
export declare enum BtcMethod {
|
10
|
-
|
10
|
+
SignPsbt = "signPsbt",
|
11
|
+
ComputeFee = "computeFee",
|
12
|
+
FillPsbt = "fillPsbt",
|
13
|
+
BroadcastPsbt = "broadcastPsbt",
|
14
|
+
SendTransfer = "sendTransfer",
|
15
|
+
GetUtxo = "getUtxo",
|
16
|
+
ListUtxos = "listUtxos",
|
17
|
+
PublicDescriptor = "publicDescriptor",
|
18
|
+
SignMessage = "signMessage"
|
11
19
|
}
|
12
20
|
export declare const BtcP2pkhAccountStruct: import("@metamask/superstruct").Struct<{
|
13
21
|
type: "bip122:p2pkh";
|
@@ -25,7 +33,7 @@ export declare const BtcP2pkhAccountStruct: import("@metamask/superstruct").Stru
|
|
25
33
|
};
|
26
34
|
address: string;
|
27
35
|
scopes: `${string}:${string}`[];
|
28
|
-
methods:
|
36
|
+
methods: BtcMethod[];
|
29
37
|
}, {
|
30
38
|
/**
|
31
39
|
* Account P2PKH address.
|
@@ -42,8 +50,16 @@ export declare const BtcP2pkhAccountStruct: import("@metamask/superstruct").Stru
|
|
42
50
|
/**
|
43
51
|
* Account supported methods.
|
44
52
|
*/
|
45
|
-
methods: import("@metamask/superstruct").Struct<
|
46
|
-
|
53
|
+
methods: import("@metamask/superstruct").Struct<BtcMethod[], import("@metamask/superstruct").Struct<BtcMethod, {
|
54
|
+
signPsbt: BtcMethod.SignPsbt;
|
55
|
+
computeFee: BtcMethod.ComputeFee;
|
56
|
+
fillPsbt: BtcMethod.FillPsbt;
|
57
|
+
broadcastPsbt: BtcMethod.BroadcastPsbt;
|
58
|
+
sendTransfer: BtcMethod.SendTransfer;
|
59
|
+
getUtxo: BtcMethod.GetUtxo;
|
60
|
+
listUtxos: BtcMethod.ListUtxos;
|
61
|
+
publicDescriptor: BtcMethod.PublicDescriptor;
|
62
|
+
signMessage: BtcMethod.SignMessage;
|
47
63
|
}>>;
|
48
64
|
id: import("@metamask/superstruct").Struct<string, null>;
|
49
65
|
options: import("@metamask/superstruct").Struct<Record<string, import("@metamask/utils").Json> & {
|
@@ -74,7 +90,7 @@ export declare const BtcP2shAccountStruct: import("@metamask/superstruct").Struc
|
|
74
90
|
};
|
75
91
|
address: string;
|
76
92
|
scopes: `${string}:${string}`[];
|
77
|
-
methods:
|
93
|
+
methods: BtcMethod[];
|
78
94
|
}, {
|
79
95
|
/**
|
80
96
|
* Account P2SH address.
|
@@ -91,8 +107,16 @@ export declare const BtcP2shAccountStruct: import("@metamask/superstruct").Struc
|
|
91
107
|
/**
|
92
108
|
* Account supported methods.
|
93
109
|
*/
|
94
|
-
methods: import("@metamask/superstruct").Struct<
|
95
|
-
|
110
|
+
methods: import("@metamask/superstruct").Struct<BtcMethod[], import("@metamask/superstruct").Struct<BtcMethod, {
|
111
|
+
signPsbt: BtcMethod.SignPsbt;
|
112
|
+
computeFee: BtcMethod.ComputeFee;
|
113
|
+
fillPsbt: BtcMethod.FillPsbt;
|
114
|
+
broadcastPsbt: BtcMethod.BroadcastPsbt;
|
115
|
+
sendTransfer: BtcMethod.SendTransfer;
|
116
|
+
getUtxo: BtcMethod.GetUtxo;
|
117
|
+
listUtxos: BtcMethod.ListUtxos;
|
118
|
+
publicDescriptor: BtcMethod.PublicDescriptor;
|
119
|
+
signMessage: BtcMethod.SignMessage;
|
96
120
|
}>>;
|
97
121
|
id: import("@metamask/superstruct").Struct<string, null>;
|
98
122
|
options: import("@metamask/superstruct").Struct<Record<string, import("@metamask/utils").Json> & {
|
@@ -123,7 +147,7 @@ export declare const BtcP2wpkhAccountStruct: import("@metamask/superstruct").Str
|
|
123
147
|
};
|
124
148
|
address: string;
|
125
149
|
scopes: `${string}:${string}`[];
|
126
|
-
methods:
|
150
|
+
methods: BtcMethod[];
|
127
151
|
}, {
|
128
152
|
/**
|
129
153
|
* Account P2WPKH address.
|
@@ -140,8 +164,16 @@ export declare const BtcP2wpkhAccountStruct: import("@metamask/superstruct").Str
|
|
140
164
|
/**
|
141
165
|
* Account supported methods.
|
142
166
|
*/
|
143
|
-
methods: import("@metamask/superstruct").Struct<
|
144
|
-
|
167
|
+
methods: import("@metamask/superstruct").Struct<BtcMethod[], import("@metamask/superstruct").Struct<BtcMethod, {
|
168
|
+
signPsbt: BtcMethod.SignPsbt;
|
169
|
+
computeFee: BtcMethod.ComputeFee;
|
170
|
+
fillPsbt: BtcMethod.FillPsbt;
|
171
|
+
broadcastPsbt: BtcMethod.BroadcastPsbt;
|
172
|
+
sendTransfer: BtcMethod.SendTransfer;
|
173
|
+
getUtxo: BtcMethod.GetUtxo;
|
174
|
+
listUtxos: BtcMethod.ListUtxos;
|
175
|
+
publicDescriptor: BtcMethod.PublicDescriptor;
|
176
|
+
signMessage: BtcMethod.SignMessage;
|
145
177
|
}>>;
|
146
178
|
id: import("@metamask/superstruct").Struct<string, null>;
|
147
179
|
options: import("@metamask/superstruct").Struct<Record<string, import("@metamask/utils").Json> & {
|
@@ -172,7 +204,7 @@ export declare const BtcP2trAccountStruct: import("@metamask/superstruct").Struc
|
|
172
204
|
};
|
173
205
|
address: string;
|
174
206
|
scopes: `${string}:${string}`[];
|
175
|
-
methods:
|
207
|
+
methods: BtcMethod[];
|
176
208
|
}, {
|
177
209
|
/**
|
178
210
|
* Account P2TR address.
|
@@ -189,8 +221,16 @@ export declare const BtcP2trAccountStruct: import("@metamask/superstruct").Struc
|
|
189
221
|
/**
|
190
222
|
* Account supported methods.
|
191
223
|
*/
|
192
|
-
methods: import("@metamask/superstruct").Struct<
|
193
|
-
|
224
|
+
methods: import("@metamask/superstruct").Struct<BtcMethod[], import("@metamask/superstruct").Struct<BtcMethod, {
|
225
|
+
signPsbt: BtcMethod.SignPsbt;
|
226
|
+
computeFee: BtcMethod.ComputeFee;
|
227
|
+
fillPsbt: BtcMethod.FillPsbt;
|
228
|
+
broadcastPsbt: BtcMethod.BroadcastPsbt;
|
229
|
+
sendTransfer: BtcMethod.SendTransfer;
|
230
|
+
getUtxo: BtcMethod.GetUtxo;
|
231
|
+
listUtxos: BtcMethod.ListUtxos;
|
232
|
+
publicDescriptor: BtcMethod.PublicDescriptor;
|
233
|
+
signMessage: BtcMethod.SignMessage;
|
194
234
|
}>>;
|
195
235
|
id: import("@metamask/superstruct").Struct<string, null>;
|
196
236
|
options: import("@metamask/superstruct").Struct<Record<string, import("@metamask/utils").Json> & {
|
package/dist/btc/types.d.mts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../src/btc/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAkCnD,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OAEG;;;;;;;;;;;;;;;;;;;;;;;;EA0DH,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAClE,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAChE,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACpE,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
package/dist/btc/types.mjs
CHANGED
@@ -31,8 +31,15 @@ export const BtcP2trAddressStruct = refine(string(), 'BtcP2trAddressStruct', (ad
|
|
31
31
|
*/
|
32
32
|
export var BtcMethod;
|
33
33
|
(function (BtcMethod) {
|
34
|
-
|
35
|
-
BtcMethod["
|
34
|
+
BtcMethod["SignPsbt"] = "signPsbt";
|
35
|
+
BtcMethod["ComputeFee"] = "computeFee";
|
36
|
+
BtcMethod["FillPsbt"] = "fillPsbt";
|
37
|
+
BtcMethod["BroadcastPsbt"] = "broadcastPsbt";
|
38
|
+
BtcMethod["SendTransfer"] = "sendTransfer";
|
39
|
+
BtcMethod["GetUtxo"] = "getUtxo";
|
40
|
+
BtcMethod["ListUtxos"] = "listUtxos";
|
41
|
+
BtcMethod["PublicDescriptor"] = "publicDescriptor";
|
42
|
+
BtcMethod["SignMessage"] = "signMessage";
|
36
43
|
})(BtcMethod || (BtcMethod = {}));
|
37
44
|
const BtcAccountStruct = object({
|
38
45
|
...KeyringAccountStruct.schema,
|
@@ -43,7 +50,7 @@ const BtcAccountStruct = object({
|
|
43
50
|
/**
|
44
51
|
* Account supported methods.
|
45
52
|
*/
|
46
|
-
methods: array(enums(
|
53
|
+
methods: array(enums(Object.values(BtcMethod))),
|
47
54
|
});
|
48
55
|
export const BtcP2pkhAccountStruct = object({
|
49
56
|
...BtcAccountStruct.schema,
|
package/dist/btc/types.mjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{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qB,GAAG,MAAM,CAAC;IAC1C,GAAG,gBAAgB,CAAC,MAAM;IAE1B;;OAEG;IACH,OAAO,EAAE,qBAAqB;IAE9B;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC,GAAG,cAAc,CAAC,KAAK,EAAE,CAAC;CACzC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC;IACzC,GAAG,gBAAgB,CAAC,MAAM;IAE1B;;OAEG;IACH,OAAO,EAAE,oBAAoB;IAE7B;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC,GAAG,cAAc,CAAC,IAAI,EAAE,CAAC;CACxC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC;IAC3C,GAAG,gBAAgB,CAAC,MAAM;IAE1B;;OAEG;IACH,OAAO,EAAE,sBAAsB;IAE/B;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC;CAC1C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC;IACzC,GAAG,gBAAgB,CAAC,MAAM;IAE1B;;OAEG;IACH,OAAO,EAAE,oBAAoB;IAE7B;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC,GAAG,cAAc,CAAC,IAAI,EAAE,CAAC;CACxC,CAAC,CAAC","sourcesContent":["import { object } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport {\n string,\n array,\n enums,\n refine,\n literal,\n nonempty,\n} from '@metamask/superstruct';\nimport { AddressType, getAddressInfo } from 'bitcoin-address-validation';\n\nimport {\n BtcAccountType,\n CaipChainIdStruct,\n KeyringAccountStruct,\n} from '../api';\n\nconst validateAddress = (\n address: string,\n type: AddressType,\n): boolean | Error => {\n try {\n const addressInfo = getAddressInfo(address);\n if (addressInfo.type === type) {\n return true;\n }\n return new Error(`Invalid ${type} address`);\n } catch (error) {\n return new Error(\n `Failed to decode ${type} address: ${(error as Error).message}`,\n );\n }\n};\n\nexport const BtcP2pkhAddressStruct = refine(\n string(),\n 'BtcP2pkhAddressStruct',\n (address: string) => {\n return validateAddress(address, AddressType.p2pkh);\n },\n);\n\nexport const BtcP2shAddressStruct = refine(\n string(),\n 'BtcP2shAddressStruct',\n (address: string) => {\n return validateAddress(address, AddressType.p2sh);\n },\n);\n\nexport const BtcP2wpkhAddressStruct = refine(\n string(),\n 'BtcP2wpkhAddressStruct',\n (address: string) => {\n return validateAddress(address, AddressType.p2wpkh);\n },\n);\n\nexport const BtcP2trAddressStruct = refine(\n string(),\n 'BtcP2trAddressStruct',\n (address: string) => {\n return validateAddress(address, AddressType.p2tr);\n },\n);\n\n/**\n * Supported Bitcoin methods.\n */\nexport enum BtcMethod {\n SignPsbt = 'signPsbt',\n ComputeFee = 'computeFee',\n FillPsbt = 'fillPsbt',\n BroadcastPsbt = 'broadcastPsbt',\n SendTransfer = 'sendTransfer',\n GetUtxo = 'getUtxo',\n ListUtxos = 'listUtxos',\n PublicDescriptor = 'publicDescriptor',\n SignMessage = 'signMessage',\n}\n\nconst BtcAccountStruct = object({\n ...KeyringAccountStruct.schema,\n\n /**\n * Account supported scopes (CAIP-2 chain ID).\n */\n scopes: nonempty(array(CaipChainIdStruct)),\n\n /**\n * Account supported methods.\n */\n methods: array(enums(Object.values(BtcMethod))),\n});\n\nexport const BtcP2pkhAccountStruct = object({\n ...BtcAccountStruct.schema,\n\n /**\n * Account P2PKH address.\n */\n address: BtcP2pkhAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${BtcAccountType.P2pkh}`),\n});\n\nexport const BtcP2shAccountStruct = object({\n ...BtcAccountStruct.schema,\n\n /**\n * Account P2SH address.\n */\n address: BtcP2shAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${BtcAccountType.P2sh}`),\n});\n\nexport const BtcP2wpkhAccountStruct = object({\n ...BtcAccountStruct.schema,\n\n /**\n * Account P2WPKH address.\n */\n address: BtcP2wpkhAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${BtcAccountType.P2wpkh}`),\n});\n\nexport const BtcP2trAccountStruct = object({\n ...BtcAccountStruct.schema,\n\n /**\n * Account P2TR address.\n */\n address: BtcP2trAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${BtcAccountType.P2tr}`),\n});\n\nexport type BtcP2pkhAccount = Infer<typeof BtcP2pkhAccountStruct>;\nexport type BtcP2shAccount = Infer<typeof BtcP2shAccountStruct>;\nexport type BtcP2wpkhAccount = Infer<typeof BtcP2wpkhAccountStruct>;\nexport type BtcP2trAccount = Infer<typeof BtcP2trAccountStruct>;\n"]}
|