@metamask/keyring-api 11.0.0 → 12.0.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 +21 -1
- package/dist/api/account.cjs +3 -4
- package/dist/api/account.cjs.map +1 -1
- package/dist/api/account.d.cts +1 -1
- package/dist/api/account.d.cts.map +1 -1
- package/dist/api/account.d.mts +1 -1
- package/dist/api/account.d.mts.map +1 -1
- package/dist/api/account.mjs +1 -2
- package/dist/api/account.mjs.map +1 -1
- package/dist/api/asset.cjs +82 -0
- package/dist/api/asset.cjs.map +1 -0
- package/dist/api/asset.d.cts +93 -0
- package/dist/api/asset.d.cts.map +1 -0
- package/dist/api/asset.d.mts +93 -0
- package/dist/api/asset.d.mts.map +1 -0
- package/dist/api/asset.mjs +79 -0
- package/dist/api/asset.mjs.map +1 -0
- package/dist/api/balance.cjs +3 -4
- package/dist/api/balance.cjs.map +1 -1
- package/dist/api/balance.d.cts +1 -1
- package/dist/api/balance.d.cts.map +1 -1
- package/dist/api/balance.d.mts +1 -1
- package/dist/api/balance.d.mts.map +1 -1
- package/dist/api/balance.mjs +1 -2
- package/dist/api/balance.mjs.map +1 -1
- package/dist/api/caip.cjs +3 -3
- package/dist/api/caip.cjs.map +1 -1
- package/dist/api/caip.d.cts.map +1 -1
- package/dist/api/caip.d.mts.map +1 -1
- package/dist/api/caip.mjs +1 -1
- package/dist/api/caip.mjs.map +1 -1
- package/dist/api/index.cjs +3 -0
- package/dist/api/index.cjs.map +1 -1
- package/dist/api/index.d.cts +4 -1
- package/dist/api/index.d.cts.map +1 -1
- package/dist/api/index.d.mts +4 -1
- package/dist/api/index.d.mts.map +1 -1
- package/dist/api/index.mjs +3 -0
- package/dist/api/index.mjs.map +1 -1
- package/dist/api/keyring.cjs +2 -0
- package/dist/api/keyring.cjs.map +1 -1
- package/dist/api/keyring.d.cts +14 -0
- package/dist/api/keyring.d.cts.map +1 -1
- package/dist/api/keyring.d.mts +14 -0
- package/dist/api/keyring.d.mts.map +1 -1
- package/dist/api/keyring.mjs +2 -0
- package/dist/api/keyring.mjs.map +1 -1
- package/dist/api/pagination.cjs +28 -0
- package/dist/api/pagination.cjs.map +1 -0
- package/dist/api/pagination.d.cts +59 -0
- package/dist/api/pagination.d.cts.map +1 -0
- package/dist/api/pagination.d.mts +59 -0
- package/dist/api/pagination.d.mts.map +1 -0
- package/dist/api/pagination.mjs +25 -0
- package/dist/api/pagination.mjs.map +1 -0
- package/dist/api/request.cjs +6 -7
- package/dist/api/request.cjs.map +1 -1
- package/dist/api/request.d.cts +5 -5
- package/dist/api/request.d.cts.map +1 -1
- package/dist/api/request.d.mts +5 -5
- package/dist/api/request.d.mts.map +1 -1
- package/dist/api/request.mjs +1 -2
- package/dist/api/request.mjs.map +1 -1
- package/dist/api/response.cjs +6 -6
- package/dist/api/response.cjs.map +1 -1
- package/dist/api/response.d.cts +1 -1
- package/dist/api/response.d.cts.map +1 -1
- package/dist/api/response.d.mts +1 -1
- package/dist/api/response.d.mts.map +1 -1
- package/dist/api/response.mjs +1 -1
- package/dist/api/response.mjs.map +1 -1
- package/dist/api/transaction.cjs +294 -0
- package/dist/api/transaction.cjs.map +1 -0
- package/dist/api/transaction.d.cts +773 -0
- package/dist/api/transaction.d.cts.map +1 -0
- package/dist/api/transaction.d.mts +773 -0
- package/dist/api/transaction.d.mts.map +1 -0
- package/dist/api/transaction.mjs +291 -0
- package/dist/api/transaction.mjs.map +1 -0
- package/dist/btc/types.cjs +2 -2
- package/dist/btc/types.cjs.map +1 -1
- package/dist/btc/types.d.cts +1 -1
- package/dist/btc/types.d.cts.map +1 -1
- package/dist/btc/types.d.mts +1 -1
- package/dist/btc/types.d.mts.map +1 -1
- package/dist/btc/types.mjs +2 -2
- package/dist/btc/types.mjs.map +1 -1
- package/dist/eth/erc4337/types.cjs +10 -11
- package/dist/eth/erc4337/types.cjs.map +1 -1
- package/dist/eth/erc4337/types.d.cts +4 -4
- package/dist/eth/erc4337/types.d.cts.map +1 -1
- package/dist/eth/erc4337/types.d.mts +4 -4
- package/dist/eth/erc4337/types.d.mts.map +1 -1
- package/dist/eth/erc4337/types.mjs +1 -2
- package/dist/eth/erc4337/types.mjs.map +1 -1
- package/dist/eth/types.cjs +6 -6
- package/dist/eth/types.cjs.map +1 -1
- package/dist/eth/types.d.cts +2 -2
- package/dist/eth/types.d.cts.map +1 -1
- package/dist/eth/types.d.mts +2 -2
- package/dist/eth/types.d.mts.map +1 -1
- package/dist/eth/types.mjs +1 -1
- package/dist/eth/types.mjs.map +1 -1
- package/dist/eth/utils.cjs.map +1 -1
- package/dist/eth/utils.d.cts.map +1 -1
- package/dist/eth/utils.d.mts.map +1 -1
- package/dist/eth/utils.mjs.map +1 -1
- package/dist/events.cjs +67 -1
- package/dist/events.cjs.map +1 -1
- package/dist/events.d.cts +161 -0
- package/dist/events.d.cts.map +1 -1
- package/dist/events.d.mts +161 -0
- package/dist/events.d.mts.map +1 -1
- package/dist/events.mjs +66 -0
- package/dist/events.mjs.map +1 -1
- package/dist/index.cjs +2 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -9
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +3 -9
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -8
- package/dist/index.mjs.map +1 -1
- package/dist/{internal/api.cjs → rpc.cjs} +78 -38
- package/dist/rpc.cjs.map +1 -0
- package/dist/{internal/api.d.cts → rpc.d.cts} +402 -59
- package/dist/rpc.d.cts.map +1 -0
- package/dist/{internal/api.d.mts → rpc.d.mts} +402 -59
- package/dist/rpc.d.mts.map +1 -0
- package/dist/{internal/api.mjs → rpc.mjs} +44 -5
- package/dist/rpc.mjs.map +1 -0
- package/dist/sol/types.cjs +3 -3
- package/dist/sol/types.cjs.map +1 -1
- package/dist/sol/types.d.cts +1 -1
- package/dist/sol/types.d.cts.map +1 -1
- package/dist/sol/types.d.mts +1 -1
- package/dist/sol/types.d.mts.map +1 -1
- package/dist/sol/types.mjs +1 -1
- package/dist/sol/types.mjs.map +1 -1
- package/package.json +11 -14
- package/dist/JsonRpcRequest.cjs +0 -13
- package/dist/JsonRpcRequest.cjs.map +0 -1
- package/dist/JsonRpcRequest.d.cts +0 -17
- package/dist/JsonRpcRequest.d.cts.map +0 -1
- package/dist/JsonRpcRequest.d.mts +0 -17
- package/dist/JsonRpcRequest.d.mts.map +0 -1
- package/dist/JsonRpcRequest.mjs +0 -10
- package/dist/JsonRpcRequest.mjs.map +0 -1
- package/dist/KeyringClient.cjs +0 -124
- package/dist/KeyringClient.cjs.map +0 -1
- package/dist/KeyringClient.d.cts +0 -29
- package/dist/KeyringClient.d.cts.map +0 -1
- package/dist/KeyringClient.d.mts +0 -29
- package/dist/KeyringClient.d.mts.map +0 -1
- package/dist/KeyringClient.mjs +0 -120
- package/dist/KeyringClient.mjs.map +0 -1
- package/dist/KeyringSnapRpcClient.cjs +0 -68
- package/dist/KeyringSnapRpcClient.cjs.map +0 -1
- package/dist/KeyringSnapRpcClient.d.cts +0 -40
- package/dist/KeyringSnapRpcClient.d.cts.map +0 -1
- package/dist/KeyringSnapRpcClient.d.mts +0 -40
- package/dist/KeyringSnapRpcClient.d.mts.map +0 -1
- package/dist/KeyringSnapRpcClient.mjs +0 -63
- package/dist/KeyringSnapRpcClient.mjs.map +0 -1
- package/dist/internal/api.cjs.map +0 -1
- package/dist/internal/api.d.cts.map +0 -1
- package/dist/internal/api.d.mts.map +0 -1
- package/dist/internal/api.mjs.map +0 -1
- package/dist/internal/eth/EthKeyring.cjs +0 -3
- package/dist/internal/eth/EthKeyring.cjs.map +0 -1
- package/dist/internal/eth/EthKeyring.d.cts +0 -34
- package/dist/internal/eth/EthKeyring.d.cts.map +0 -1
- package/dist/internal/eth/EthKeyring.d.mts +0 -34
- package/dist/internal/eth/EthKeyring.d.mts.map +0 -1
- package/dist/internal/eth/EthKeyring.mjs +0 -2
- package/dist/internal/eth/EthKeyring.mjs.map +0 -1
- package/dist/internal/eth/index.cjs +0 -3
- package/dist/internal/eth/index.cjs.map +0 -1
- package/dist/internal/eth/index.d.cts +0 -2
- package/dist/internal/eth/index.d.cts.map +0 -1
- package/dist/internal/eth/index.d.mts +0 -2
- package/dist/internal/eth/index.d.mts.map +0 -1
- package/dist/internal/eth/index.mjs +0 -2
- package/dist/internal/eth/index.mjs.map +0 -1
- package/dist/internal/events.cjs +0 -72
- package/dist/internal/events.cjs.map +0 -1
- package/dist/internal/events.d.cts +0 -162
- package/dist/internal/events.d.cts.map +0 -1
- package/dist/internal/events.d.mts +0 -162
- package/dist/internal/events.d.mts.map +0 -1
- package/dist/internal/events.mjs +0 -69
- package/dist/internal/events.mjs.map +0 -1
- package/dist/internal/index.cjs +0 -21
- package/dist/internal/index.cjs.map +0 -1
- package/dist/internal/index.d.cts +0 -6
- package/dist/internal/index.d.cts.map +0 -1
- package/dist/internal/index.d.mts +0 -6
- package/dist/internal/index.d.mts.map +0 -1
- package/dist/internal/index.mjs +0 -5
- package/dist/internal/index.mjs.map +0 -1
- package/dist/internal/rpc.cjs +0 -33
- package/dist/internal/rpc.cjs.map +0 -1
- package/dist/internal/rpc.d.cts +0 -26
- package/dist/internal/rpc.d.cts.map +0 -1
- package/dist/internal/rpc.d.mts +0 -26
- package/dist/internal/rpc.d.mts.map +0 -1
- package/dist/internal/rpc.mjs +0 -29
- package/dist/internal/rpc.mjs.map +0 -1
- package/dist/internal/types.cjs +0 -52
- package/dist/internal/types.cjs.map +0 -1
- package/dist/internal/types.d.cts +0 -392
- package/dist/internal/types.d.cts.map +0 -1
- package/dist/internal/types.d.mts +0 -392
- package/dist/internal/types.d.mts.map +0 -1
- package/dist/internal/types.mjs +0 -49
- package/dist/internal/types.mjs.map +0 -1
- package/dist/rpc-handler.cjs +0 -136
- package/dist/rpc-handler.cjs.map +0 -1
- package/dist/rpc-handler.d.cts +0 -30
- package/dist/rpc-handler.d.cts.map +0 -1
- package/dist/rpc-handler.d.mts +0 -30
- package/dist/rpc-handler.d.mts.map +0 -1
- package/dist/rpc-handler.mjs +0 -131
- package/dist/rpc-handler.mjs.map +0 -1
- package/dist/snap-utils.cjs +0 -20
- package/dist/snap-utils.cjs.map +0 -1
- package/dist/snap-utils.d.cts +0 -12
- package/dist/snap-utils.d.cts.map +0 -1
- package/dist/snap-utils.d.mts +0 -12
- package/dist/snap-utils.d.mts.map +0 -1
- package/dist/snap-utils.mjs +0 -17
- package/dist/snap-utils.mjs.map +0 -1
- package/dist/superstruct.cjs +0 -80
- package/dist/superstruct.cjs.map +0 -1
- package/dist/superstruct.d.cts +0 -84
- package/dist/superstruct.d.cts.map +0 -1
- package/dist/superstruct.d.mts +0 -84
- package/dist/superstruct.d.mts.map +0 -1
- package/dist/superstruct.mjs +0 -74
- package/dist/superstruct.mjs.map +0 -1
- package/dist/utils/index.cjs +0 -19
- package/dist/utils/index.cjs.map +0 -1
- package/dist/utils/index.d.cts +0 -3
- package/dist/utils/index.d.cts.map +0 -1
- package/dist/utils/index.d.mts +0 -3
- package/dist/utils/index.d.mts.map +0 -1
- package/dist/utils/index.mjs +0 -3
- package/dist/utils/index.mjs.map +0 -1
- package/dist/utils/types.cjs +0 -29
- package/dist/utils/types.cjs.map +0 -1
- package/dist/utils/types.d.cts +0 -18
- package/dist/utils/types.d.cts.map +0 -1
- package/dist/utils/types.d.mts +0 -18
- package/dist/utils/types.d.mts.map +0 -1
- package/dist/utils/types.mjs +0 -26
- package/dist/utils/types.mjs.map +0 -1
- package/dist/utils/typing.cjs +0 -20
- package/dist/utils/typing.cjs.map +0 -1
- package/dist/utils/typing.d.cts +0 -33
- package/dist/utils/typing.d.cts.map +0 -1
- package/dist/utils/typing.d.mts +0 -33
- package/dist/utils/typing.d.mts.map +0 -1
- package/dist/utils/typing.mjs +0 -17
- package/dist/utils/typing.mjs.map +0 -1
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"transaction.d.mts","sourceRoot":"","sources":["../../src/api/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,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OAAO,iBAAiB,CAAC,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IACjC;;OAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAnGH;;WAEG;;QAGH;;WAEG;;QAGH;;WAEG;;QAGH;;WAEG;;;;;;;QAQH;;;;WAIG;;QAGH;;;WAGG;;;;;QAGH;;WAEG;;;;;;;;;;;;;;;;;;;;;;;;YAnNH;;eAEG;;YAGH;;eAEG;;;;;;;;;;;QA+MH;;WAEG;;;;;;;;;;;;;;;;;;;;;;;;YAxNH;;eAEG;;YAGH;;eAEG;;;;;;;;;;;QAoNH;;WAEG;;;;;;;;;;;;;;;;;;;;;;;;YAxLH;;eAEG;;;;;YAGH;;eAEG;;;;;;;;;;;QAoLH;;;;;WAKG;;;;;;;;YApIH;;eAEG;;;;;;;YAQH;;eAEG;;;;IAoKH;;;OAGG;;EAEH,CAAC;AAEH;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,WAAW,CACxC,OAAO,sBAAsB,EAC7B,SAAS,CAAC,WAAW,CAAC,CACvB,CAAC"}
|
@@ -0,0 +1,291 @@
|
|
1
|
+
import { object, UuidStruct } from "@metamask/keyring-utils";
|
2
|
+
import { array, enums, nullable, number, string } from "@metamask/superstruct";
|
3
|
+
import { CaipChainIdStruct } from "@metamask/utils";
|
4
|
+
import { AssetStruct } from "./asset.mjs";
|
5
|
+
/**
|
6
|
+
* This struct represents a participant in a transaction.
|
7
|
+
*
|
8
|
+
* @example
|
9
|
+
* ```ts
|
10
|
+
* {
|
11
|
+
* address: '0x1234...',
|
12
|
+
* asset: {
|
13
|
+
* fungible: true,
|
14
|
+
* type: 'eip155:1/slip44:60',
|
15
|
+
* unit: 'ETH',
|
16
|
+
* amount: '0.01',
|
17
|
+
* },
|
18
|
+
* },
|
19
|
+
* ```
|
20
|
+
*
|
21
|
+
* @example
|
22
|
+
* ```ts
|
23
|
+
* {
|
24
|
+
* address: '0x1234...',
|
25
|
+
* asset: {
|
26
|
+
* fungible: false,
|
27
|
+
* id: 'eip155:1/erc721:0x06012c8cf97BEaD5deAe237070F9587f8E7A266d/771769',
|
28
|
+
* },
|
29
|
+
* },
|
30
|
+
* ```
|
31
|
+
*
|
32
|
+
* @example
|
33
|
+
* ```ts
|
34
|
+
* {
|
35
|
+
* address: '0x1234...',
|
36
|
+
* asset: null,
|
37
|
+
* },
|
38
|
+
* ```
|
39
|
+
*/
|
40
|
+
const ParticipantStruct = object({
|
41
|
+
/**
|
42
|
+
* Participant address.
|
43
|
+
*/
|
44
|
+
address: string(),
|
45
|
+
/**
|
46
|
+
* Asset being transferred.
|
47
|
+
*/
|
48
|
+
asset: nullable(AssetStruct),
|
49
|
+
});
|
50
|
+
/**
|
51
|
+
* Fee types.
|
52
|
+
*/
|
53
|
+
export var FeeType;
|
54
|
+
(function (FeeType) {
|
55
|
+
/**
|
56
|
+
* Base fee. It is the minimum fee required to include a transaction in the
|
57
|
+
* blockchain.
|
58
|
+
*
|
59
|
+
* For non-confirmed transactions, it must be the maximum base fee. For
|
60
|
+
* confirmed transactions, it must be the actual base fee paid.
|
61
|
+
*/
|
62
|
+
FeeType["Base"] = "base";
|
63
|
+
/**
|
64
|
+
* Priority fee. It is an optional fee used to prioritize the transaction.
|
65
|
+
*
|
66
|
+
* For non-confirmed transactions, it must be the maximum priority fee. For
|
67
|
+
* confirmed transactions, it must be the actual priority fee paid.
|
68
|
+
*/
|
69
|
+
FeeType["Priority"] = "priority";
|
70
|
+
})(FeeType || (FeeType = {}));
|
71
|
+
/**
|
72
|
+
* This struct represents a transaction fee.
|
73
|
+
*/
|
74
|
+
const FeeStruct = object({
|
75
|
+
/**
|
76
|
+
* Fee type {@see FeeType}.
|
77
|
+
*/
|
78
|
+
type: enums([`${FeeType.Base}`, `${FeeType.Priority}`]),
|
79
|
+
/**
|
80
|
+
* Asset used to pay for the fee.
|
81
|
+
*/
|
82
|
+
asset: AssetStruct,
|
83
|
+
});
|
84
|
+
/**
|
85
|
+
* Transaction statuses.
|
86
|
+
*/
|
87
|
+
export var TransactionStatus;
|
88
|
+
(function (TransactionStatus) {
|
89
|
+
/**
|
90
|
+
* The transaction has been submitted but is not yet in the
|
91
|
+
* blockchain. For example, it can be in the mempool.
|
92
|
+
*/
|
93
|
+
TransactionStatus["Submitted"] = "submitted";
|
94
|
+
/**
|
95
|
+
* The transaction is in the blockchain but has not been
|
96
|
+
* confirmed yet.
|
97
|
+
*/
|
98
|
+
TransactionStatus["Unconfirmed"] = "unconfirmed";
|
99
|
+
/**
|
100
|
+
* The transaction has been confirmed.
|
101
|
+
*/
|
102
|
+
TransactionStatus["Confirmed"] = "confirmed";
|
103
|
+
/**
|
104
|
+
* The transaction has failed. For example, it has been reverted.
|
105
|
+
*/
|
106
|
+
TransactionStatus["Failed"] = "failed";
|
107
|
+
})(TransactionStatus || (TransactionStatus = {}));
|
108
|
+
/**
|
109
|
+
* Transaction types.
|
110
|
+
*/
|
111
|
+
export var TransactionType;
|
112
|
+
(function (TransactionType) {
|
113
|
+
/**
|
114
|
+
* The transaction was originated by the account. If the transaction
|
115
|
+
* has a change output that goes back to the same account, it must be tagged
|
116
|
+
* as a send transaction.
|
117
|
+
*/
|
118
|
+
TransactionType["Send"] = "send";
|
119
|
+
/**
|
120
|
+
* The transaction was received by the account, but originated by
|
121
|
+
* another account.
|
122
|
+
*/
|
123
|
+
TransactionType["Receive"] = "receive";
|
124
|
+
})(TransactionType || (TransactionType = {}));
|
125
|
+
/**
|
126
|
+
* This struct represents a transaction event.
|
127
|
+
*/
|
128
|
+
export const TransactionEventStruct = object({
|
129
|
+
/**
|
130
|
+
* New status of the transaction.
|
131
|
+
*/
|
132
|
+
status: enums([
|
133
|
+
`${TransactionStatus.Submitted}`,
|
134
|
+
`${TransactionStatus.Unconfirmed}`,
|
135
|
+
`${TransactionStatus.Confirmed}`,
|
136
|
+
`${TransactionStatus.Failed}`,
|
137
|
+
]),
|
138
|
+
/**
|
139
|
+
* UNIX timestamp of when the event occurred.
|
140
|
+
*/
|
141
|
+
timestamp: nullable(number()),
|
142
|
+
});
|
143
|
+
/**
|
144
|
+
* This struct represents a blockchain transaction.
|
145
|
+
*
|
146
|
+
* @example
|
147
|
+
* ```ts
|
148
|
+
* const tx = {
|
149
|
+
* id: 'f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6',
|
150
|
+
* chain: 'bip122:000000000019d6689c085ae165831e93',
|
151
|
+
* account: 'b9beb861-9761-4b97-89ce-d992be5f34da',
|
152
|
+
* status: 'confirmed',
|
153
|
+
* timestamp: 1716367781,
|
154
|
+
* type: 'send',
|
155
|
+
* from: [
|
156
|
+
* {
|
157
|
+
* address: 'bc1qrp0yzgkf8rawkuvdlhnjfj2fnjwm0m8727kgah',
|
158
|
+
* asset: {
|
159
|
+
* fungible: true,
|
160
|
+
* type: 'bip122:000000000019d6689c085ae165831e93/slip44:0',
|
161
|
+
* unit: 'BTC',
|
162
|
+
* amount: '0.1',
|
163
|
+
* },
|
164
|
+
* },
|
165
|
+
* ],
|
166
|
+
* to: [
|
167
|
+
* {
|
168
|
+
* address: 'bc1qrp0yzgkf8rawkuvdlhnjfj2fnjwm0m8727kgah',
|
169
|
+
* asset: {
|
170
|
+
* fungible: true,
|
171
|
+
* type: 'bip122:000000000019d6689c085ae165831e93/slip44:0',
|
172
|
+
* unit: 'BTC',
|
173
|
+
* amount: '0.1',
|
174
|
+
* },
|
175
|
+
* },
|
176
|
+
* {
|
177
|
+
* address: 'bc1qwl8399fz829uqvqly9tcatgrgtwp3udnhxfq4k',
|
178
|
+
* asset: {
|
179
|
+
* fungible: true,
|
180
|
+
* type: 'bip122:000000000019d6689c085ae165831e93/slip44:0',
|
181
|
+
* unit: 'BTC',
|
182
|
+
* amount: '0.1',
|
183
|
+
* },
|
184
|
+
* },
|
185
|
+
* ],
|
186
|
+
* fees: [
|
187
|
+
* {
|
188
|
+
* type: 'priority',
|
189
|
+
* asset: {
|
190
|
+
* fungible: true,
|
191
|
+
* type: 'bip122:000000000019d6689c085ae165831e93/slip44:0',
|
192
|
+
* unit: 'BTC',
|
193
|
+
* amount: '0.1',
|
194
|
+
* },
|
195
|
+
* },
|
196
|
+
* ],
|
197
|
+
* };
|
198
|
+
* ```
|
199
|
+
*/
|
200
|
+
export const TransactionStruct = object({
|
201
|
+
/**
|
202
|
+
* Chain-specific transaction ID.
|
203
|
+
*/
|
204
|
+
id: string(),
|
205
|
+
/**
|
206
|
+
* Chain ID (CAIP-2).
|
207
|
+
*/
|
208
|
+
chain: CaipChainIdStruct,
|
209
|
+
/**
|
210
|
+
* Account ID (UUIDv4).
|
211
|
+
*/
|
212
|
+
account: UuidStruct,
|
213
|
+
/**
|
214
|
+
* Transaction status {@see TransactionStatus}.
|
215
|
+
*/
|
216
|
+
status: enums([
|
217
|
+
`${TransactionStatus.Submitted}`,
|
218
|
+
`${TransactionStatus.Unconfirmed}`,
|
219
|
+
`${TransactionStatus.Confirmed}`,
|
220
|
+
`${TransactionStatus.Failed}`,
|
221
|
+
]),
|
222
|
+
/**
|
223
|
+
* UNIX timestamp of when the transaction was added to the blockchain. The
|
224
|
+
* timestamp can be null if the transaction has not been included in the
|
225
|
+
* blockchain yet.
|
226
|
+
*/
|
227
|
+
timestamp: nullable(number()),
|
228
|
+
/**
|
229
|
+
* Transaction type {@see TransactionType}. This will be used by MetaMask to enrich the transaction
|
230
|
+
* details on the UI.
|
231
|
+
*/
|
232
|
+
type: enums([`${TransactionType.Send}`, `${TransactionType.Receive}`]),
|
233
|
+
/**
|
234
|
+
* Transaction sender addresses and amounts.
|
235
|
+
*/
|
236
|
+
from: array(ParticipantStruct),
|
237
|
+
/**
|
238
|
+
* Transaction receiver addresses and amounts.
|
239
|
+
*/
|
240
|
+
to: array(ParticipantStruct),
|
241
|
+
/**
|
242
|
+
* Total transaction fee.
|
243
|
+
*/
|
244
|
+
fees: array(FeeStruct),
|
245
|
+
/**
|
246
|
+
* List of events related to the transaction {@see TransactionEventStruct}.
|
247
|
+
*
|
248
|
+
* The events are tracked in a best-effort basis and may not be available for
|
249
|
+
* all transactions.
|
250
|
+
*/
|
251
|
+
events: array(TransactionEventStruct),
|
252
|
+
});
|
253
|
+
/**
|
254
|
+
* This struct represents a page of transactions.
|
255
|
+
*
|
256
|
+
* @example
|
257
|
+
* ```ts
|
258
|
+
* {
|
259
|
+
* data: [
|
260
|
+
* {
|
261
|
+
* // Transaction object
|
262
|
+
* }
|
263
|
+
* ],
|
264
|
+
* next: 'c3y1Q6QtqtstbxKX+oqVdEW6',
|
265
|
+
* }
|
266
|
+
* ```
|
267
|
+
*
|
268
|
+
* @example
|
269
|
+
* ```ts
|
270
|
+
* {
|
271
|
+
* data: [
|
272
|
+
* {
|
273
|
+
* // Transaction object
|
274
|
+
* }
|
275
|
+
* ],
|
276
|
+
* next: null, // No more results
|
277
|
+
* }**
|
278
|
+
* ```
|
279
|
+
*/
|
280
|
+
export const TransactionsPageStruct = object({
|
281
|
+
/**
|
282
|
+
* List of transactions.
|
283
|
+
*/
|
284
|
+
data: array(TransactionStruct),
|
285
|
+
/**
|
286
|
+
* Next cursor to iterate over the results. If null, there are no more
|
287
|
+
* results.
|
288
|
+
*/
|
289
|
+
next: nullable(string()),
|
290
|
+
});
|
291
|
+
//# sourceMappingURL=transaction.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"transaction.mjs","sourceRoot":"","sources":["../../src/api/transaction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,gCAAgC;AAE7D,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,8BAA8B;AAC/E,OAAO,EAAE,iBAAiB,EAAE,w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AE,KAAK,CAAC,iBAAiB,CAAC;IAE9B;;;OAGG;IACH,IAAI,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;CACzB,CAAC,CAAC","sourcesContent":["import type { InferEquals } from '@metamask/keyring-utils';\nimport { object, UuidStruct } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport { array, enums, nullable, number, string } from '@metamask/superstruct';\nimport { CaipChainIdStruct } from '@metamask/utils';\n\nimport { AssetStruct } from './asset';\nimport type { Paginated } from './pagination';\n\n/**\n * This struct represents a participant in a transaction.\n *\n * @example\n * ```ts\n * {\n * address: '0x1234...',\n * asset: {\n * fungible: true,\n * type: 'eip155:1/slip44:60',\n * unit: 'ETH',\n * amount: '0.01',\n * },\n * },\n * ```\n *\n * @example\n * ```ts\n * {\n * address: '0x1234...',\n * asset: {\n * fungible: false,\n * id: 'eip155:1/erc721:0x06012c8cf97BEaD5deAe237070F9587f8E7A266d/771769',\n * },\n * },\n * ```\n *\n * @example\n * ```ts\n * {\n * address: '0x1234...',\n * asset: null,\n * },\n * ```\n */\nconst ParticipantStruct = object({\n /**\n * Participant address.\n */\n address: string(),\n\n /**\n * Asset being transferred.\n */\n asset: nullable(AssetStruct),\n});\n\n/**\n * Fee types.\n */\nexport enum FeeType {\n /**\n * Base fee. It is the minimum fee required to include a transaction in the\n * blockchain.\n *\n * For non-confirmed transactions, it must be the maximum base fee. For\n * confirmed transactions, it must be the actual base fee paid.\n */\n Base = 'base',\n\n /**\n * Priority fee. It is an optional fee used to prioritize the transaction.\n *\n * For non-confirmed transactions, it must be the maximum priority fee. For\n * confirmed transactions, it must be the actual priority fee paid.\n */\n Priority = 'priority',\n}\n\n/**\n * This struct represents a transaction fee.\n */\nconst FeeStruct = object({\n /**\n * Fee type {@see FeeType}.\n */\n type: enums([`${FeeType.Base}`, `${FeeType.Priority}`]),\n\n /**\n * Asset used to pay for the fee.\n */\n asset: AssetStruct,\n});\n\n/**\n * Transaction statuses.\n */\nexport enum TransactionStatus {\n /**\n * The transaction has been submitted but is not yet in the\n * blockchain. For example, it can be in the mempool.\n */\n Submitted = 'submitted',\n\n /**\n * The transaction is in the blockchain but has not been\n * confirmed yet.\n */\n Unconfirmed = 'unconfirmed',\n\n /**\n * The transaction has been confirmed.\n */\n Confirmed = 'confirmed',\n\n /**\n * The transaction has failed. For example, it has been reverted.\n */\n Failed = 'failed',\n}\n\n/**\n * Transaction types.\n */\nexport enum TransactionType {\n /**\n * The transaction was originated by the account. If the transaction\n * has a change output that goes back to the same account, it must be tagged\n * as a send transaction.\n */\n Send = 'send',\n\n /**\n * The transaction was received by the account, but originated by\n * another account.\n */\n Receive = 'receive',\n}\n\n/**\n * This struct represents a transaction event.\n */\nexport const TransactionEventStruct = object({\n /**\n * New status of the transaction.\n */\n status: enums([\n `${TransactionStatus.Submitted}`,\n `${TransactionStatus.Unconfirmed}`,\n `${TransactionStatus.Confirmed}`,\n `${TransactionStatus.Failed}`,\n ]),\n\n /**\n * UNIX timestamp of when the event occurred.\n */\n timestamp: nullable(number()),\n});\n\n/**\n * This struct represents a blockchain transaction.\n *\n * @example\n * ```ts\n * const tx = {\n * id: 'f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6',\n * chain: 'bip122:000000000019d6689c085ae165831e93',\n * account: 'b9beb861-9761-4b97-89ce-d992be5f34da',\n * status: 'confirmed',\n * timestamp: 1716367781,\n * type: 'send',\n * from: [\n * {\n * address: 'bc1qrp0yzgkf8rawkuvdlhnjfj2fnjwm0m8727kgah',\n * asset: {\n * fungible: true,\n * type: 'bip122:000000000019d6689c085ae165831e93/slip44:0',\n * unit: 'BTC',\n * amount: '0.1',\n * },\n * },\n * ],\n * to: [\n * {\n * address: 'bc1qrp0yzgkf8rawkuvdlhnjfj2fnjwm0m8727kgah',\n * asset: {\n * fungible: true,\n * type: 'bip122:000000000019d6689c085ae165831e93/slip44:0',\n * unit: 'BTC',\n * amount: '0.1',\n * },\n * },\n * {\n * address: 'bc1qwl8399fz829uqvqly9tcatgrgtwp3udnhxfq4k',\n * asset: {\n * fungible: true,\n * type: 'bip122:000000000019d6689c085ae165831e93/slip44:0',\n * unit: 'BTC',\n * amount: '0.1',\n * },\n * },\n * ],\n * fees: [\n * {\n * type: 'priority',\n * asset: {\n * fungible: true,\n * type: 'bip122:000000000019d6689c085ae165831e93/slip44:0',\n * unit: 'BTC',\n * amount: '0.1',\n * },\n * },\n * ],\n * };\n * ```\n */\nexport const TransactionStruct = object({\n /**\n * Chain-specific transaction ID.\n */\n id: string(),\n\n /**\n * Chain ID (CAIP-2).\n */\n chain: CaipChainIdStruct,\n\n /**\n * Account ID (UUIDv4).\n */\n account: UuidStruct,\n\n /**\n * Transaction status {@see TransactionStatus}.\n */\n status: enums([\n `${TransactionStatus.Submitted}`,\n `${TransactionStatus.Unconfirmed}`,\n `${TransactionStatus.Confirmed}`,\n `${TransactionStatus.Failed}`,\n ]),\n\n /**\n * UNIX timestamp of when the transaction was added to the blockchain. The\n * timestamp can be null if the transaction has not been included in the\n * blockchain yet.\n */\n timestamp: nullable(number()),\n\n /**\n * Transaction type {@see TransactionType}. This will be used by MetaMask to enrich the transaction\n * details on the UI.\n */\n type: enums([`${TransactionType.Send}`, `${TransactionType.Receive}`]),\n\n /**\n * Transaction sender addresses and amounts.\n */\n from: array(ParticipantStruct),\n\n /**\n * Transaction receiver addresses and amounts.\n */\n to: array(ParticipantStruct),\n\n /**\n * Total transaction fee.\n */\n fees: array(FeeStruct),\n\n /**\n * List of events related to the transaction {@see TransactionEventStruct}.\n *\n * The events are tracked in a best-effort basis and may not be available for\n * all transactions.\n */\n events: array(TransactionEventStruct),\n});\n\n/**\n * Transaction object.\n *\n * See {@link TransactionStruct}.\n */\nexport type Transaction = Infer<typeof TransactionStruct>;\n\n/**\n * This struct represents a page of transactions.\n *\n * @example\n * ```ts\n * {\n * data: [\n * {\n * // Transaction object\n * }\n * ],\n * next: 'c3y1Q6QtqtstbxKX+oqVdEW6',\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * data: [\n * {\n * // Transaction object\n * }\n * ],\n * next: null, // No more results\n * }**\n * ```\n */\nexport const TransactionsPageStruct = object({\n /**\n * List of transactions.\n */\n data: array(TransactionStruct),\n\n /**\n * Next cursor to iterate over the results. If null, there are no more\n * results.\n */\n next: nullable(string()),\n});\n\n/**\n * Transactions page object.\n *\n * See {@link TransactionsPageStruct}.\n */\nexport type TransactionsPage = InferEquals<\n typeof TransactionsPageStruct,\n Paginated<Transaction>\n>;\n"]}
|
package/dist/btc/types.cjs
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.BtcP2wpkhAccountStruct = exports.BtcMethod = exports.BtcP2wpkhAddressStruct = void 0;
|
4
|
+
const keyring_utils_1 = require("@metamask/keyring-utils");
|
4
5
|
const superstruct_1 = require("@metamask/superstruct");
|
5
6
|
const bech32_1 = require("bech32");
|
6
7
|
const api_1 = require("../api/index.cjs");
|
7
|
-
const superstruct_2 = require("../superstruct.cjs");
|
8
8
|
exports.BtcP2wpkhAddressStruct = (0, superstruct_1.refine)((0, superstruct_1.string)(), 'BtcP2wpkhAddressStruct', (address) => {
|
9
9
|
try {
|
10
10
|
bech32_1.bech32.decode(address);
|
@@ -22,7 +22,7 @@ var BtcMethod;
|
|
22
22
|
// General transaction methods
|
23
23
|
BtcMethod["SendBitcoin"] = "sendBitcoin";
|
24
24
|
})(BtcMethod || (exports.BtcMethod = BtcMethod = {}));
|
25
|
-
exports.BtcP2wpkhAccountStruct = (0,
|
25
|
+
exports.BtcP2wpkhAccountStruct = (0, keyring_utils_1.object)({
|
26
26
|
...api_1.KeyringAccountStruct.schema,
|
27
27
|
/**
|
28
28
|
* Account address.
|
package/dist/btc/types.cjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../src/btc/types.ts"],"names":[],"mappings":";;;
|
1
|
+
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../src/btc/types.ts"],"names":[],"mappings":";;;AAAA,2DAAiD;AAEjD,uDAA8E;AAC9E,mCAAgC;AAEhC,0CAA8D;AAEjD,QAAA,sBAAsB,GAAG,IAAA,oBAAM,EAC1C,IAAA,oBAAM,GAAE,EACR,wBAAwB,EACxB,CAAC,OAAe,EAAE,EAAE;IAClB,IAAI,CAAC;QACH,eAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,IAAI,KAAK,CACd,oCAAqC,KAAe,CAAC,OAAO,EAAE,CAC/D,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CACF,CAAC;AAEF;;GAEG;AACH,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,8BAA8B;IAC9B,wCAA2B,CAAA;AAC7B,CAAC,EAHW,SAAS,yBAAT,SAAS,QAGpB;AAEY,QAAA,sBAAsB,GAAG,IAAA,sBAAM,EAAC;IAC3C,GAAG,0BAAoB,CAAC,MAAM;IAE9B;;OAEG;IACH,OAAO,EAAE,8BAAsB;IAE/B;;OAEG;IACH,IAAI,EAAE,IAAA,qBAAO,EAAC,GAAG,oBAAc,CAAC,MAAM,EAAE,CAAC;IAEzC;;OAEG;IACH,OAAO,EAAE,IAAA,mBAAK,EAAC,IAAA,mBAAK,EAAC,CAAC,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;CACpD,CAAC,CAAC","sourcesContent":["import { object } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport { string, array, enums, refine, literal } from '@metamask/superstruct';\nimport { bech32 } from 'bech32';\n\nimport { BtcAccountType, KeyringAccountStruct } from '../api';\n\nexport const BtcP2wpkhAddressStruct = refine(\n string(),\n 'BtcP2wpkhAddressStruct',\n (address: string) => {\n try {\n bech32.decode(address);\n } catch (error) {\n return new Error(\n `Could not decode P2WPKH address: ${(error as Error).message}`,\n );\n }\n return true;\n },\n);\n\n/**\n * Supported Bitcoin methods.\n */\nexport enum BtcMethod {\n // General transaction methods\n SendBitcoin = 'sendBitcoin',\n}\n\nexport const BtcP2wpkhAccountStruct = object({\n ...KeyringAccountStruct.schema,\n\n /**\n * Account address.\n */\n address: BtcP2wpkhAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${BtcAccountType.P2wpkh}`),\n\n /**\n * Account supported methods.\n */\n methods: array(enums([`${BtcMethod.SendBitcoin}`])),\n});\n\nexport type BtcP2wpkhAccount = Infer<typeof BtcP2wpkhAccountStruct>;\n"]}
|
package/dist/btc/types.d.cts
CHANGED
@@ -9,8 +9,8 @@ export declare enum BtcMethod {
|
|
9
9
|
export declare const BtcP2wpkhAccountStruct: import("@metamask/superstruct").Struct<{
|
10
10
|
type: "bip122:p2wpkh";
|
11
11
|
id: string;
|
12
|
-
address: string;
|
13
12
|
options: Record<string, import("@metamask/utils").Json>;
|
13
|
+
address: string;
|
14
14
|
methods: "sendBitcoin"[];
|
15
15
|
}, {
|
16
16
|
/**
|
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":"
|
1
|
+
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../src/btc/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAMnD,eAAO,MAAM,sBAAsB,sDAalC,CAAC;AAEF;;GAEG;AACH,oBAAY,SAAS;IAEnB,WAAW,gBAAgB;CAC5B;AAED,eAAO,MAAM,sBAAsB;;;;;;;IAGjC;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;;;;;EAEH,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
|
package/dist/btc/types.d.mts
CHANGED
@@ -9,8 +9,8 @@ export declare enum BtcMethod {
|
|
9
9
|
export declare const BtcP2wpkhAccountStruct: import("@metamask/superstruct").Struct<{
|
10
10
|
type: "bip122:p2wpkh";
|
11
11
|
id: string;
|
12
|
-
address: string;
|
13
12
|
options: Record<string, import("@metamask/utils").Json>;
|
13
|
+
address: string;
|
14
14
|
methods: "sendBitcoin"[];
|
15
15
|
}, {
|
16
16
|
/**
|
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":"
|
1
|
+
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../src/btc/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAMnD,eAAO,MAAM,sBAAsB,sDAalC,CAAC;AAEF;;GAEG;AACH,oBAAY,SAAS;IAEnB,WAAW,gBAAgB;CAC5B;AAED,eAAO,MAAM,sBAAsB;;;;;;;IAGjC;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;;;;;EAEH,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
|
package/dist/btc/types.mjs
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
+
import { object } from "@metamask/keyring-utils";
|
1
2
|
import { string, array, enums, refine, literal } from "@metamask/superstruct";
|
2
3
|
import { bech32 } from "bech32";
|
3
|
-
import {
|
4
|
-
import { object } from "../superstruct.mjs";
|
4
|
+
import { BtcAccountType, KeyringAccountStruct } from "../api/index.mjs";
|
5
5
|
export const BtcP2wpkhAddressStruct = refine(string(), 'BtcP2wpkhAddressStruct', (address) => {
|
6
6
|
try {
|
7
7
|
bech32.decode(address);
|
package/dist/btc/types.mjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../src/btc/types.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../src/btc/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,gCAAgC;AAEjD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,8BAA8B;AAC9E,OAAO,EAAE,MAAM,EAAE,eAAe;AAEhC,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,yBAAe;AAE9D,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAC1C,MAAM,EAAE,EACR,wBAAwB,EACxB,CAAC,OAAe,EAAE,EAAE;IAClB,IAAI,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,IAAI,KAAK,CACd,oCAAqC,KAAe,CAAC,OAAO,EAAE,CAC/D,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CACF,CAAC;AAEF;;GAEG;AACH,MAAM,CAAN,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,8BAA8B;IAC9B,wCAA2B,CAAA;AAC7B,CAAC,EAHW,SAAS,KAAT,SAAS,QAGpB;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC;IAC3C,GAAG,oBAAoB,CAAC,MAAM;IAE9B;;OAEG;IACH,OAAO,EAAE,sBAAsB;IAE/B;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC;IAEzC;;OAEG;IACH,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;CACpD,CAAC,CAAC","sourcesContent":["import { object } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport { string, array, enums, refine, literal } from '@metamask/superstruct';\nimport { bech32 } from 'bech32';\n\nimport { BtcAccountType, KeyringAccountStruct } from '../api';\n\nexport const BtcP2wpkhAddressStruct = refine(\n string(),\n 'BtcP2wpkhAddressStruct',\n (address: string) => {\n try {\n bech32.decode(address);\n } catch (error) {\n return new Error(\n `Could not decode P2WPKH address: ${(error as Error).message}`,\n );\n }\n return true;\n },\n);\n\n/**\n * Supported Bitcoin methods.\n */\nexport enum BtcMethod {\n // General transaction methods\n SendBitcoin = 'sendBitcoin',\n}\n\nexport const BtcP2wpkhAccountStruct = object({\n ...KeyringAccountStruct.schema,\n\n /**\n * Account address.\n */\n address: BtcP2wpkhAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${BtcAccountType.P2wpkh}`),\n\n /**\n * Account supported methods.\n */\n methods: array(enums([`${BtcMethod.SendBitcoin}`])),\n});\n\nexport type BtcP2wpkhAccount = Infer<typeof BtcP2wpkhAccountStruct>;\n"]}
|
@@ -1,15 +1,14 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.EthUserOperationPatchStruct = exports.EthBaseUserOperationStruct = exports.EthBaseTransactionStruct = exports.EthUserOperationStruct = void 0;
|
4
|
-
const
|
5
|
-
const utils_1 = require("../../utils/index.cjs");
|
4
|
+
const keyring_utils_1 = require("@metamask/keyring-utils");
|
6
5
|
const types_1 = require("../types.cjs");
|
7
6
|
/**
|
8
7
|
* Struct of a UserOperation as defined by ERC-4337.
|
9
8
|
*
|
10
9
|
* @see https://eips.ethereum.org/EIPS/eip-4337#definitions
|
11
10
|
*/
|
12
|
-
exports.EthUserOperationStruct = (0,
|
11
|
+
exports.EthUserOperationStruct = (0, keyring_utils_1.object)({
|
13
12
|
sender: types_1.EthAddressStruct,
|
14
13
|
nonce: types_1.EthUint256Struct,
|
15
14
|
initCode: types_1.EthBytesStruct,
|
@@ -26,7 +25,7 @@ exports.EthUserOperationStruct = (0, superstruct_1.object)({
|
|
26
25
|
* Struct containing the most basic transaction information required to
|
27
26
|
* construct a UserOperation.
|
28
27
|
*/
|
29
|
-
exports.EthBaseTransactionStruct = (0,
|
28
|
+
exports.EthBaseTransactionStruct = (0, keyring_utils_1.object)({
|
30
29
|
/**
|
31
30
|
* Address of the transaction recipient.
|
32
31
|
*/
|
@@ -40,23 +39,23 @@ exports.EthBaseTransactionStruct = (0, superstruct_1.object)({
|
|
40
39
|
*/
|
41
40
|
data: types_1.EthBytesStruct,
|
42
41
|
});
|
43
|
-
exports.EthBaseUserOperationStruct = (0,
|
42
|
+
exports.EthBaseUserOperationStruct = (0, keyring_utils_1.object)({
|
44
43
|
nonce: types_1.EthUint256Struct,
|
45
44
|
initCode: types_1.EthBytesStruct,
|
46
45
|
callData: types_1.EthBytesStruct,
|
47
|
-
gasLimits: (0,
|
46
|
+
gasLimits: (0, keyring_utils_1.exactOptional)((0, keyring_utils_1.object)({
|
48
47
|
callGasLimit: types_1.EthUint256Struct,
|
49
48
|
verificationGasLimit: types_1.EthUint256Struct,
|
50
49
|
preVerificationGas: types_1.EthUint256Struct,
|
51
50
|
})),
|
52
51
|
dummyPaymasterAndData: types_1.EthBytesStruct,
|
53
52
|
dummySignature: types_1.EthBytesStruct,
|
54
|
-
bundlerUrl:
|
53
|
+
bundlerUrl: keyring_utils_1.UrlStruct,
|
55
54
|
});
|
56
|
-
exports.EthUserOperationPatchStruct = (0,
|
55
|
+
exports.EthUserOperationPatchStruct = (0, keyring_utils_1.object)({
|
57
56
|
paymasterAndData: types_1.EthBytesStruct,
|
58
|
-
callGasLimit: (0,
|
59
|
-
verificationGasLimit: (0,
|
60
|
-
preVerificationGas: (0,
|
57
|
+
callGasLimit: (0, keyring_utils_1.exactOptional)(types_1.EthUint256Struct),
|
58
|
+
verificationGasLimit: (0, keyring_utils_1.exactOptional)(types_1.EthUint256Struct),
|
59
|
+
preVerificationGas: (0, keyring_utils_1.exactOptional)(types_1.EthUint256Struct),
|
61
60
|
});
|
62
61
|
//# sourceMappingURL=types.cjs.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../../src/eth/erc4337/types.ts"],"names":[],"mappings":";;;
|
1
|
+
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../../src/eth/erc4337/types.ts"],"names":[],"mappings":";;;AAAA,2DAA2E;AAG3E,wCAA8E;AAE9E;;;;GAIG;AACU,QAAA,sBAAsB,GAAG,IAAA,sBAAM,EAAC;IAC3C,MAAM,EAAE,wBAAgB;IACxB,KAAK,EAAE,wBAAgB;IACvB,QAAQ,EAAE,sBAAc;IACxB,QAAQ,EAAE,sBAAc;IACxB,YAAY,EAAE,wBAAgB;IAC9B,oBAAoB,EAAE,wBAAgB;IACtC,kBAAkB,EAAE,wBAAgB;IACpC,YAAY,EAAE,wBAAgB;IAC9B,oBAAoB,EAAE,wBAAgB;IACtC,gBAAgB,EAAE,sBAAc;IAChC,SAAS,EAAE,sBAAc;CAC1B,CAAC,CAAC;AAIH;;;GAGG;AACU,QAAA,wBAAwB,GAAG,IAAA,sBAAM,EAAC;IAC7C;;OAEG;IACH,EAAE,EAAE,wBAAgB;IAEpB;;OAEG;IACH,KAAK,EAAE,wBAAgB;IAEvB;;OAEG;IACH,IAAI,EAAE,sBAAc;CACrB,CAAC,CAAC;AAIU,QAAA,0BAA0B,GAAG,IAAA,sBAAM,EAAC;IAC/C,KAAK,EAAE,wBAAgB;IACvB,QAAQ,EAAE,sBAAc;IACxB,QAAQ,EAAE,sBAAc;IACxB,SAAS,EAAE,IAAA,6BAAa,EACtB,IAAA,sBAAM,EAAC;QACL,YAAY,EAAE,wBAAgB;QAC9B,oBAAoB,EAAE,wBAAgB;QACtC,kBAAkB,EAAE,wBAAgB;KACrC,CAAC,CACH;IACD,qBAAqB,EAAE,sBAAc;IACrC,cAAc,EAAE,sBAAc;IAC9B,UAAU,EAAE,yBAAS;CACtB,CAAC,CAAC;AAIU,QAAA,2BAA2B,GAAG,IAAA,sBAAM,EAAC;IAChD,gBAAgB,EAAE,sBAAc;IAChC,YAAY,EAAE,IAAA,6BAAa,EAAC,wBAAgB,CAAC;IAC7C,oBAAoB,EAAE,IAAA,6BAAa,EAAC,wBAAgB,CAAC;IACrD,kBAAkB,EAAE,IAAA,6BAAa,EAAC,wBAAgB,CAAC;CACpD,CAAC,CAAC","sourcesContent":["import { exactOptional, object, UrlStruct } from '@metamask/keyring-utils';\nimport { type Infer } from '@metamask/superstruct';\n\nimport { EthAddressStruct, EthBytesStruct, EthUint256Struct } from '../types';\n\n/**\n * Struct of a UserOperation as defined by ERC-4337.\n *\n * @see https://eips.ethereum.org/EIPS/eip-4337#definitions\n */\nexport const EthUserOperationStruct = object({\n sender: EthAddressStruct,\n nonce: EthUint256Struct,\n initCode: EthBytesStruct,\n callData: EthBytesStruct,\n callGasLimit: EthUint256Struct,\n verificationGasLimit: EthUint256Struct,\n preVerificationGas: EthUint256Struct,\n maxFeePerGas: EthUint256Struct,\n maxPriorityFeePerGas: EthUint256Struct,\n paymasterAndData: EthBytesStruct,\n signature: EthBytesStruct,\n});\n\nexport type EthUserOperation = Infer<typeof EthUserOperationStruct>;\n\n/**\n * Struct containing the most basic transaction information required to\n * construct a UserOperation.\n */\nexport const EthBaseTransactionStruct = object({\n /**\n * Address of the transaction recipient.\n */\n to: EthAddressStruct,\n\n /**\n * Amount of wei to transfer to the recipient.\n */\n value: EthUint256Struct,\n\n /**\n * Data to pass to the recipient.\n */\n data: EthBytesStruct,\n});\n\nexport type EthBaseTransaction = Infer<typeof EthBaseTransactionStruct>;\n\nexport const EthBaseUserOperationStruct = object({\n nonce: EthUint256Struct,\n initCode: EthBytesStruct,\n callData: EthBytesStruct,\n gasLimits: exactOptional(\n object({\n callGasLimit: EthUint256Struct,\n verificationGasLimit: EthUint256Struct,\n preVerificationGas: EthUint256Struct,\n }),\n ),\n dummyPaymasterAndData: EthBytesStruct,\n dummySignature: EthBytesStruct,\n bundlerUrl: UrlStruct,\n});\n\nexport type EthBaseUserOperation = Infer<typeof EthBaseUserOperationStruct>;\n\nexport const EthUserOperationPatchStruct = object({\n paymasterAndData: EthBytesStruct,\n callGasLimit: exactOptional(EthUint256Struct),\n verificationGasLimit: exactOptional(EthUint256Struct),\n preVerificationGas: exactOptional(EthUint256Struct),\n});\n\nexport type EthUserOperationPatch = Infer<typeof EthUserOperationPatchStruct>;\n"]}
|
@@ -69,7 +69,7 @@ export declare const EthBaseUserOperationStruct: import("@metamask/superstruct")
|
|
69
69
|
nonce: import("@metamask/superstruct").Struct<string, null>;
|
70
70
|
initCode: import("@metamask/superstruct").Struct<string, null>;
|
71
71
|
callData: import("@metamask/superstruct").Struct<string, null>;
|
72
|
-
gasLimits: import("@metamask/superstruct").Struct<import("
|
72
|
+
gasLimits: import("@metamask/superstruct").Struct<import("@metamask/keyring-utils").ExactOptionalTag | {
|
73
73
|
callGasLimit: string;
|
74
74
|
verificationGasLimit: string;
|
75
75
|
preVerificationGas: string;
|
@@ -90,9 +90,9 @@ export declare const EthUserOperationPatchStruct: import("@metamask/superstruct"
|
|
90
90
|
preVerificationGas?: string;
|
91
91
|
}, {
|
92
92
|
paymasterAndData: import("@metamask/superstruct").Struct<string, null>;
|
93
|
-
callGasLimit: import("@metamask/superstruct").Struct<string | import("
|
94
|
-
verificationGasLimit: import("@metamask/superstruct").Struct<string | import("
|
95
|
-
preVerificationGas: import("@metamask/superstruct").Struct<string | import("
|
93
|
+
callGasLimit: import("@metamask/superstruct").Struct<string | import("@metamask/keyring-utils").ExactOptionalTag, null>;
|
94
|
+
verificationGasLimit: import("@metamask/superstruct").Struct<string | import("@metamask/keyring-utils").ExactOptionalTag, null>;
|
95
|
+
preVerificationGas: import("@metamask/superstruct").Struct<string | import("@metamask/keyring-utils").ExactOptionalTag, null>;
|
96
96
|
}>;
|
97
97
|
export type EthUserOperationPatch = Infer<typeof EthUserOperationPatchStruct>;
|
98
98
|
//# sourceMappingURL=types.d.cts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../../src/eth/erc4337/types.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../../src/eth/erc4337/types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,KAAK,EAAE,8BAA8B;AAInD;;;;GAIG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;EAYjC,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEpE;;;GAGG;AACH,eAAO,MAAM,wBAAwB;;;;;IACnC;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;EAEH,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAExE,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAcrC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE5E,eAAO,MAAM,2BAA2B;;;;;;;;;;EAKtC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC"}
|
@@ -69,7 +69,7 @@ export declare const EthBaseUserOperationStruct: import("@metamask/superstruct")
|
|
69
69
|
nonce: import("@metamask/superstruct").Struct<string, null>;
|
70
70
|
initCode: import("@metamask/superstruct").Struct<string, null>;
|
71
71
|
callData: import("@metamask/superstruct").Struct<string, null>;
|
72
|
-
gasLimits: import("@metamask/superstruct").Struct<import("
|
72
|
+
gasLimits: import("@metamask/superstruct").Struct<import("@metamask/keyring-utils").ExactOptionalTag | {
|
73
73
|
callGasLimit: string;
|
74
74
|
verificationGasLimit: string;
|
75
75
|
preVerificationGas: string;
|
@@ -90,9 +90,9 @@ export declare const EthUserOperationPatchStruct: import("@metamask/superstruct"
|
|
90
90
|
preVerificationGas?: string;
|
91
91
|
}, {
|
92
92
|
paymasterAndData: import("@metamask/superstruct").Struct<string, null>;
|
93
|
-
callGasLimit: import("@metamask/superstruct").Struct<string | import("
|
94
|
-
verificationGasLimit: import("@metamask/superstruct").Struct<string | import("
|
95
|
-
preVerificationGas: import("@metamask/superstruct").Struct<string | import("
|
93
|
+
callGasLimit: import("@metamask/superstruct").Struct<string | import("@metamask/keyring-utils").ExactOptionalTag, null>;
|
94
|
+
verificationGasLimit: import("@metamask/superstruct").Struct<string | import("@metamask/keyring-utils").ExactOptionalTag, null>;
|
95
|
+
preVerificationGas: import("@metamask/superstruct").Struct<string | import("@metamask/keyring-utils").ExactOptionalTag, null>;
|
96
96
|
}>;
|
97
97
|
export type EthUserOperationPatch = Infer<typeof EthUserOperationPatchStruct>;
|
98
98
|
//# sourceMappingURL=types.d.mts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../../src/eth/erc4337/types.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../../src/eth/erc4337/types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,KAAK,EAAE,8BAA8B;AAInD;;;;GAIG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;EAYjC,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEpE;;;GAGG;AACH,eAAO,MAAM,wBAAwB;;;;;IACnC;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;EAEH,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAExE,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAcrC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE5E,eAAO,MAAM,2BAA2B;;;;;;;;;;EAKtC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC"}
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import { exactOptional, object } from "
|
2
|
-
import { UrlStruct } from "../../utils/index.mjs";
|
1
|
+
import { exactOptional, object, UrlStruct } from "@metamask/keyring-utils";
|
3
2
|
import { EthAddressStruct, EthBytesStruct, EthUint256Struct } from "../types.mjs";
|
4
3
|
/**
|
5
4
|
* Struct of a UserOperation as defined by ERC-4337.
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../../src/eth/erc4337/types.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../../src/eth/erc4337/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,gCAAgC;AAG3E,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,gBAAgB,EAAE,qBAAiB;AAE9E;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC;IAC3C,MAAM,EAAE,gBAAgB;IACxB,KAAK,EAAE,gBAAgB;IACvB,QAAQ,EAAE,cAAc;IACxB,QAAQ,EAAE,cAAc;IACxB,YAAY,EAAE,gBAAgB;IAC9B,oBAAoB,EAAE,gBAAgB;IACtC,kBAAkB,EAAE,gBAAgB;IACpC,YAAY,EAAE,gBAAgB;IAC9B,oBAAoB,EAAE,gBAAgB;IACtC,gBAAgB,EAAE,cAAc;IAChC,SAAS,EAAE,cAAc;CAC1B,CAAC,CAAC;AAIH;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC;IAC7C;;OAEG;IACH,EAAE,EAAE,gBAAgB;IAEpB;;OAEG;IACH,KAAK,EAAE,gBAAgB;IAEvB;;OAEG;IACH,IAAI,EAAE,cAAc;CACrB,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAC;IAC/C,KAAK,EAAE,gBAAgB;IACvB,QAAQ,EAAE,cAAc;IACxB,QAAQ,EAAE,cAAc;IACxB,SAAS,EAAE,aAAa,CACtB,MAAM,CAAC;QACL,YAAY,EAAE,gBAAgB;QAC9B,oBAAoB,EAAE,gBAAgB;QACtC,kBAAkB,EAAE,gBAAgB;KACrC,CAAC,CACH;IACD,qBAAqB,EAAE,cAAc;IACrC,cAAc,EAAE,cAAc;IAC9B,UAAU,EAAE,SAAS;CACtB,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,2BAA2B,GAAG,MAAM,CAAC;IAChD,gBAAgB,EAAE,cAAc;IAChC,YAAY,EAAE,aAAa,CAAC,gBAAgB,CAAC;IAC7C,oBAAoB,EAAE,aAAa,CAAC,gBAAgB,CAAC;IACrD,kBAAkB,EAAE,aAAa,CAAC,gBAAgB,CAAC;CACpD,CAAC,CAAC","sourcesContent":["import { exactOptional, object, UrlStruct } from '@metamask/keyring-utils';\nimport { type Infer } from '@metamask/superstruct';\n\nimport { EthAddressStruct, EthBytesStruct, EthUint256Struct } from '../types';\n\n/**\n * Struct of a UserOperation as defined by ERC-4337.\n *\n * @see https://eips.ethereum.org/EIPS/eip-4337#definitions\n */\nexport const EthUserOperationStruct = object({\n sender: EthAddressStruct,\n nonce: EthUint256Struct,\n initCode: EthBytesStruct,\n callData: EthBytesStruct,\n callGasLimit: EthUint256Struct,\n verificationGasLimit: EthUint256Struct,\n preVerificationGas: EthUint256Struct,\n maxFeePerGas: EthUint256Struct,\n maxPriorityFeePerGas: EthUint256Struct,\n paymasterAndData: EthBytesStruct,\n signature: EthBytesStruct,\n});\n\nexport type EthUserOperation = Infer<typeof EthUserOperationStruct>;\n\n/**\n * Struct containing the most basic transaction information required to\n * construct a UserOperation.\n */\nexport const EthBaseTransactionStruct = object({\n /**\n * Address of the transaction recipient.\n */\n to: EthAddressStruct,\n\n /**\n * Amount of wei to transfer to the recipient.\n */\n value: EthUint256Struct,\n\n /**\n * Data to pass to the recipient.\n */\n data: EthBytesStruct,\n});\n\nexport type EthBaseTransaction = Infer<typeof EthBaseTransactionStruct>;\n\nexport const EthBaseUserOperationStruct = object({\n nonce: EthUint256Struct,\n initCode: EthBytesStruct,\n callData: EthBytesStruct,\n gasLimits: exactOptional(\n object({\n callGasLimit: EthUint256Struct,\n verificationGasLimit: EthUint256Struct,\n preVerificationGas: EthUint256Struct,\n }),\n ),\n dummyPaymasterAndData: EthBytesStruct,\n dummySignature: EthBytesStruct,\n bundlerUrl: UrlStruct,\n});\n\nexport type EthBaseUserOperation = Infer<typeof EthBaseUserOperationStruct>;\n\nexport const EthUserOperationPatchStruct = object({\n paymasterAndData: EthBytesStruct,\n callGasLimit: exactOptional(EthUint256Struct),\n verificationGasLimit: exactOptional(EthUint256Struct),\n preVerificationGas: exactOptional(EthUint256Struct),\n});\n\nexport type EthUserOperationPatch = Infer<typeof EthUserOperationPatchStruct>;\n"]}
|
package/dist/eth/types.cjs
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.EthErc4337AccountStruct = exports.EthEoaAccountStruct = exports.EthMethod = exports.EthUint256Struct = exports.EthAddressStruct = exports.EthBytesStruct = void 0;
|
4
|
+
const keyring_utils_1 = require("@metamask/keyring-utils");
|
4
5
|
const superstruct_1 = require("@metamask/superstruct");
|
5
6
|
const api_1 = require("../api/index.cjs");
|
6
|
-
|
7
|
-
exports.
|
8
|
-
exports.
|
9
|
-
exports.EthUint256Struct = (0, superstruct_2.definePattern)('EthUint256', /^0x([1-9a-f][0-9a-f]*|0)$/iu);
|
7
|
+
exports.EthBytesStruct = (0, keyring_utils_1.definePattern)('EthBytes', /^0x[0-9a-f]*$/iu);
|
8
|
+
exports.EthAddressStruct = (0, keyring_utils_1.definePattern)('EthAddress', /^0x[0-9a-f]{40}$/iu);
|
9
|
+
exports.EthUint256Struct = (0, keyring_utils_1.definePattern)('EthUint256', /^0x([1-9a-f][0-9a-f]*|0)$/iu);
|
10
10
|
/**
|
11
11
|
* Supported Ethereum methods.
|
12
12
|
*/
|
@@ -24,7 +24,7 @@ var EthMethod;
|
|
24
24
|
EthMethod["PatchUserOperation"] = "eth_patchUserOperation";
|
25
25
|
EthMethod["SignUserOperation"] = "eth_signUserOperation";
|
26
26
|
})(EthMethod || (exports.EthMethod = EthMethod = {}));
|
27
|
-
exports.EthEoaAccountStruct = (0,
|
27
|
+
exports.EthEoaAccountStruct = (0, keyring_utils_1.object)({
|
28
28
|
...api_1.KeyringAccountStruct.schema,
|
29
29
|
/**
|
30
30
|
* Account address.
|
@@ -46,7 +46,7 @@ exports.EthEoaAccountStruct = (0, superstruct_2.object)({
|
|
46
46
|
`${EthMethod.SignTypedDataV4}`,
|
47
47
|
])),
|
48
48
|
});
|
49
|
-
exports.EthErc4337AccountStruct = (0,
|
49
|
+
exports.EthErc4337AccountStruct = (0, keyring_utils_1.object)({
|
50
50
|
...api_1.KeyringAccountStruct.schema,
|
51
51
|
/**
|
52
52
|
* Account address.
|
package/dist/eth/types.cjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../src/eth/types.ts"],"names":[],"mappings":";;;
|
1
|
+
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../src/eth/types.ts"],"names":[],"mappings":";;;AAAA,2DAAgE;AAEhE,uDAA8D;AAE9D,0CAA8D;AAEjD,QAAA,cAAc,GAAG,IAAA,6BAAa,EAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC;AAE9D,QAAA,gBAAgB,GAAG,IAAA,6BAAa,EAC3C,YAAY,EACZ,oBAAoB,CACrB,CAAC;AAEW,QAAA,gBAAgB,GAAG,IAAA,6BAAa,EAC3C,YAAY,EACZ,6BAA6B,CAC9B,CAAC;AAEF;;GAEG;AACH,IAAY,SAYX;AAZD,WAAY,SAAS;IACnB,0BAA0B;IAC1B,2CAA8B,CAAA;IAC9B,8BAAiB,CAAA;IACjB,oD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C,GAAG,SAAS,CAAC,kBAAkB,EAAE;QACjC,GAAG,SAAS,CAAC,iBAAiB,EAAE;KACjC,CAAC,CACH;CACF,CAAC,CAAC","sourcesContent":["import { object, definePattern } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport { array, enums, literal } from '@metamask/superstruct';\n\nimport { EthAccountType, KeyringAccountStruct } from '../api';\n\nexport const EthBytesStruct = definePattern('EthBytes', /^0x[0-9a-f]*$/iu);\n\nexport const EthAddressStruct = definePattern(\n 'EthAddress',\n /^0x[0-9a-f]{40}$/iu,\n);\n\nexport const EthUint256Struct = definePattern(\n 'EthUint256',\n /^0x([1-9a-f][0-9a-f]*|0)$/iu,\n);\n\n/**\n * Supported Ethereum methods.\n */\nexport enum EthMethod {\n // General signing methods\n PersonalSign = 'personal_sign',\n Sign = 'eth_sign',\n SignTransaction = 'eth_signTransaction',\n SignTypedDataV1 = 'eth_signTypedData_v1',\n SignTypedDataV3 = 'eth_signTypedData_v3',\n SignTypedDataV4 = 'eth_signTypedData_v4',\n // ERC-4337 methods\n PrepareUserOperation = 'eth_prepareUserOperation',\n PatchUserOperation = 'eth_patchUserOperation',\n SignUserOperation = 'eth_signUserOperation',\n}\n\nexport const EthEoaAccountStruct = object({\n ...KeyringAccountStruct.schema,\n\n /**\n * Account address.\n */\n address: EthAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${EthAccountType.Eoa}`),\n\n /**\n * Account supported methods.\n */\n methods: array(\n enums([\n `${EthMethod.PersonalSign}`,\n `${EthMethod.Sign}`,\n `${EthMethod.SignTransaction}`,\n `${EthMethod.SignTypedDataV1}`,\n `${EthMethod.SignTypedDataV3}`,\n `${EthMethod.SignTypedDataV4}`,\n ]),\n ),\n});\n\nexport type EthEoaAccount = Infer<typeof EthEoaAccountStruct>;\n\nexport const EthErc4337AccountStruct = object({\n ...KeyringAccountStruct.schema,\n\n /**\n * Account address.\n */\n address: EthAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${EthAccountType.Erc4337}`),\n\n /**\n * Account supported methods.\n */\n methods: array(\n enums([\n `${EthMethod.PersonalSign}`,\n `${EthMethod.Sign}`,\n `${EthMethod.SignTypedDataV1}`,\n `${EthMethod.SignTypedDataV3}`,\n `${EthMethod.SignTypedDataV4}`,\n `${EthMethod.PrepareUserOperation}`,\n `${EthMethod.PatchUserOperation}`,\n `${EthMethod.SignUserOperation}`,\n ]),\n ),\n});\n\nexport type EthErc4337Account = Infer<typeof EthErc4337AccountStruct>;\n"]}
|