signet.js 0.0.7 → 0.0.9

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.
Files changed (183) hide show
  1. package/README.md +8 -1
  2. package/browser/index.browser.cjs +3 -0
  3. package/browser/index.browser.cjs.map +1 -0
  4. package/browser/index.browser.js +3 -0
  5. package/browser/index.browser.js.map +1 -0
  6. package/node/index.node.cjs +3 -0
  7. package/node/index.node.cjs.map +1 -0
  8. package/node/index.node.js +3 -0
  9. package/node/index.node.js.map +1 -0
  10. package/package.json +19 -18
  11. package/types/index.d.cts +1048 -0
  12. package/types/index.d.ts +1048 -0
  13. package/.eslintrc.json +0 -67
  14. package/.prettierrc +0 -1
  15. package/babel.config.js +0 -6
  16. package/docs/dist/.vocs/icons/arrow-diagonal.svg +0 -3
  17. package/docs/dist/.vocs/icons/chevron-down.svg +0 -13
  18. package/docs/dist/.vocs/icons/chevron-up.svg +0 -13
  19. package/docs/dist/.vocs/icons/link.svg +0 -3
  20. package/docs/dist/.vocs/search-index-7b499e25.json +0 -1
  21. package/docs/dist/assets/arbitrary-hash-Cd6eo8ZD.js +0 -309
  22. package/docs/dist/assets/broadcast-tx-CeTEE9yX.js +0 -8
  23. package/docs/dist/assets/btc-rpc-adapter-C-qSHpFV.js +0 -226
  24. package/docs/dist/assets/chain-adapter-interface-B9TpOgQv.js +0 -1280
  25. package/docs/dist/assets/chain-contract-interface-DEku3k45.js +0 -392
  26. package/docs/dist/assets/constructor-73n7bp3b.js +0 -161
  27. package/docs/dist/assets/constructor-Bg7nvLe0.js +0 -14
  28. package/docs/dist/assets/contract-addresses-BYlrAOs3.js +0 -200
  29. package/docs/dist/assets/derive-address-and-public-key-DExrKiGV.js +0 -14
  30. package/docs/dist/assets/finalize-message-signing-W435d71R.js +0 -20
  31. package/docs/dist/assets/finalize-transaction-signing-BIgJ2dnc.js +0 -36
  32. package/docs/dist/assets/finalize-transaction-signing-C--HJs8D.js +0 -24
  33. package/docs/dist/assets/finalize-transaction-signing-CjGmN7d9.js +0 -24
  34. package/docs/dist/assets/finalize-typed-data-signing-CEOp_GWt.js +0 -21
  35. package/docs/dist/assets/get-balance-DBC-i6KG.js +0 -13
  36. package/docs/dist/assets/get-current-signature-deposit-BXm9AzYy.js +0 -6
  37. package/docs/dist/assets/get-current-signature-deposit-nOw4j1MN.js +0 -6
  38. package/docs/dist/assets/get-derived-public-key-BXvfo2m2.js +0 -14
  39. package/docs/dist/assets/get-derived-public-key-DQ1pyiFS.js +0 -14
  40. package/docs/dist/assets/get-latest-key-version-DWlkMCre.js +0 -6
  41. package/docs/dist/assets/get-public-key-B4PFoVqu.js +0 -6
  42. package/docs/dist/assets/get-public-key-B9xkYkD_.js +0 -6
  43. package/docs/dist/assets/index-BFuwoY4w.js +0 -601
  44. package/docs/dist/assets/index-C62Mf-vy.js +0 -426
  45. package/docs/dist/assets/index-D8xhaiVb.js +0 -121
  46. package/docs/dist/assets/index-DTr0DlO0.js +0 -36
  47. package/docs/dist/assets/index-V9dXf-ik.js +0 -457
  48. package/docs/dist/assets/prepare-message-for-signing-DESTq-Hg.js +0 -16
  49. package/docs/dist/assets/prepare-transaction-for-signing-DIKTU0zj.js +0 -33
  50. package/docs/dist/assets/prepare-transaction-for-signing-DV_wkZ5g.js +0 -21
  51. package/docs/dist/assets/prepare-transaction-for-signing-LVDP0COu.js +0 -33
  52. package/docs/dist/assets/prepare-typed-data-for-signing-CWcmJvw0.js +0 -192
  53. package/docs/dist/assets/sign-CwtS5LnB.js +0 -13
  54. package/docs/dist/assets/sign-OQxf9yn7.js +0 -15
  55. package/docs/dist/assets/signet-quick-start-CQK52nVG.js +0 -350
  56. package/docs/dist/assets/sponsor-foreign-chain-gas-C9iWXM8Q.js +0 -1
  57. package/docs/dist/assets/style-CKGXuRqx.css +0 -1
  58. package/docs/dist/examples/arbitrary-hash/index.html +0 -88
  59. package/docs/dist/examples/sponsor-foreign-chain-gas/index.html +0 -21
  60. package/docs/dist/index.html +0 -56
  61. package/docs/dist/initializeTheme.iife.js +0 -1
  62. package/docs/dist/introduction/signet-quick-start/index.html +0 -109
  63. package/docs/dist/primitives/chain-adapter-interface/index.html +0 -515
  64. package/docs/dist/primitives/chain-contract-interface/index.html +0 -306
  65. package/docs/dist/primitives/contract-addresses/index.html +0 -97
  66. package/docs/dist/signet-logo.png +0 -0
  67. package/docs/dist/signetjs/chain-adapters/bitcoin/btc-rpc-adapter/index.html +0 -148
  68. package/docs/dist/signetjs/chain-adapters/bitcoin/finalize-transaction-signing/index.html +0 -41
  69. package/docs/dist/signetjs/chain-adapters/bitcoin/index.html +0 -187
  70. package/docs/dist/signetjs/chain-adapters/bitcoin/prepare-transaction-for-signing/index.html +0 -34
  71. package/docs/dist/signetjs/chain-adapters/broadcast-tx/index.html +0 -28
  72. package/docs/dist/signetjs/chain-adapters/cosmos/finalize-transaction-signing/index.html +0 -41
  73. package/docs/dist/signetjs/chain-adapters/cosmos/index.html +0 -166
  74. package/docs/dist/signetjs/chain-adapters/cosmos/prepare-transaction-for-signing/index.html +0 -43
  75. package/docs/dist/signetjs/chain-adapters/derive-address-and-public-key/index.html +0 -31
  76. package/docs/dist/signetjs/chain-adapters/evm/finalize-message-signing/index.html +0 -38
  77. package/docs/dist/signetjs/chain-adapters/evm/finalize-transaction-signing/index.html +0 -41
  78. package/docs/dist/signetjs/chain-adapters/evm/finalize-typed-data-signing/index.html +0 -39
  79. package/docs/dist/signetjs/chain-adapters/evm/index.html +0 -129
  80. package/docs/dist/signetjs/chain-adapters/evm/prepare-message-for-signing/index.html +0 -31
  81. package/docs/dist/signetjs/chain-adapters/evm/prepare-transaction-for-signing/index.html +0 -34
  82. package/docs/dist/signetjs/chain-adapters/evm/prepare-typed-data-for-signing/index.html +0 -49
  83. package/docs/dist/signetjs/chain-adapters/get-balance/index.html +0 -30
  84. package/docs/dist/signetjs/contracts/evm/constructor/index.html +0 -45
  85. package/docs/dist/signetjs/contracts/evm/get-current-signature-deposit/index.html +0 -26
  86. package/docs/dist/signetjs/contracts/evm/get-derived-public-key/index.html +0 -31
  87. package/docs/dist/signetjs/contracts/evm/get-latest-key-version/index.html +0 -26
  88. package/docs/dist/signetjs/contracts/evm/get-public-key/index.html +0 -26
  89. package/docs/dist/signetjs/contracts/evm/sign/index.html +0 -32
  90. package/docs/dist/signetjs/contracts/near/constructor/index.html +0 -34
  91. package/docs/dist/signetjs/contracts/near/get-current-signature-deposit/index.html +0 -26
  92. package/docs/dist/signetjs/contracts/near/get-derived-public-key/index.html +0 -31
  93. package/docs/dist/signetjs/contracts/near/get-public-key/index.html +0 -26
  94. package/docs/dist/signetjs/contracts/near/sign/index.html +0 -32
  95. package/docs/pages/examples/arbitrary-hash.mdx +0 -73
  96. package/docs/pages/examples/sponsor-foreign-chain-gas.mdx +0 -1
  97. package/docs/pages/index.mdx +0 -36
  98. package/docs/pages/introduction/signet-quick-start.mdx +0 -88
  99. package/docs/pages/primitives/chain-adapter-interface.mdx +0 -45
  100. package/docs/pages/primitives/chain-contract-interface.mdx +0 -52
  101. package/docs/pages/primitives/contract-addresses.mdx +0 -27
  102. package/docs/pages/signetjs/chain-adapters/bitcoin/btc-rpc-adapter.mdx +0 -26
  103. package/docs/pages/signetjs/chain-adapters/bitcoin/finalize-transaction-signing.mdx +0 -47
  104. package/docs/pages/signetjs/chain-adapters/bitcoin/index.mdx +0 -119
  105. package/docs/pages/signetjs/chain-adapters/bitcoin/prepare-transaction-for-signing.mdx +0 -30
  106. package/docs/pages/signetjs/chain-adapters/broadcast-tx.mdx +0 -23
  107. package/docs/pages/signetjs/chain-adapters/cosmos/finalize-transaction-signing.mdx +0 -53
  108. package/docs/pages/signetjs/chain-adapters/cosmos/index.mdx +0 -108
  109. package/docs/pages/signetjs/chain-adapters/cosmos/prepare-transaction-for-signing.mdx +0 -39
  110. package/docs/pages/signetjs/chain-adapters/derive-address-and-public-key.mdx +0 -28
  111. package/docs/pages/signetjs/chain-adapters/evm/finalize-message-signing.mdx +0 -33
  112. package/docs/pages/signetjs/chain-adapters/evm/finalize-transaction-signing.mdx +0 -44
  113. package/docs/pages/signetjs/chain-adapters/evm/finalize-typed-data-signing.mdx +0 -34
  114. package/docs/pages/signetjs/chain-adapters/evm/index.mdx +0 -84
  115. package/docs/pages/signetjs/chain-adapters/evm/prepare-message-for-signing.mdx +0 -26
  116. package/docs/pages/signetjs/chain-adapters/evm/prepare-transaction-for-signing.mdx +0 -30
  117. package/docs/pages/signetjs/chain-adapters/evm/prepare-typed-data-for-signing.mdx +0 -44
  118. package/docs/pages/signetjs/chain-adapters/get-balance.mdx +0 -26
  119. package/docs/pages/signetjs/contracts/evm/constructor.mdx +0 -38
  120. package/docs/pages/signetjs/contracts/evm/get-current-signature-deposit.mdx +0 -17
  121. package/docs/pages/signetjs/contracts/evm/get-derived-public-key.mdx +0 -28
  122. package/docs/pages/signetjs/contracts/evm/get-latest-key-version.mdx +0 -17
  123. package/docs/pages/signetjs/contracts/evm/get-public-key.mdx +0 -17
  124. package/docs/pages/signetjs/contracts/evm/sign.mdx +0 -36
  125. package/docs/pages/signetjs/contracts/near/constructor.mdx +0 -29
  126. package/docs/pages/signetjs/contracts/near/get-current-signature-deposit.mdx +0 -17
  127. package/docs/pages/signetjs/contracts/near/get-derived-public-key.mdx +0 -28
  128. package/docs/pages/signetjs/contracts/near/get-public-key.mdx +0 -17
  129. package/docs/pages/signetjs/contracts/near/sign.mdx +0 -32
  130. package/docs/public/signet-logo.png +0 -0
  131. package/docs/snippets/code/chains.ts +0 -42
  132. package/docs/snippets/code/contract.ts +0 -44
  133. package/docs/snippets/code/evm/contract.ts +0 -24
  134. package/docs/snippets/code/evm/env.ts +0 -16
  135. package/docs/snippets/code/near/env.ts +0 -13
  136. package/hardhat.config.mts +0 -19
  137. package/src/chain-adapters/Bitcoin/BTCRpcAdapter/BTCRpcAdapter.ts +0 -15
  138. package/src/chain-adapters/Bitcoin/BTCRpcAdapter/Mempool/Mempool.ts +0 -101
  139. package/src/chain-adapters/Bitcoin/BTCRpcAdapter/Mempool/index.ts +0 -1
  140. package/src/chain-adapters/Bitcoin/BTCRpcAdapter/Mempool/types.ts +0 -72
  141. package/src/chain-adapters/Bitcoin/BTCRpcAdapter/index.ts +0 -6
  142. package/src/chain-adapters/Bitcoin/Bitcoin.ts +0 -287
  143. package/src/chain-adapters/Bitcoin/index.ts +0 -13
  144. package/src/chain-adapters/Bitcoin/types.ts +0 -48
  145. package/src/chain-adapters/Bitcoin/utils.ts +0 -14
  146. package/src/chain-adapters/ChainAdapter.ts +0 -92
  147. package/src/chain-adapters/Cosmos/Cosmos.ts +0 -258
  148. package/src/chain-adapters/Cosmos/index.ts +0 -8
  149. package/src/chain-adapters/Cosmos/types.ts +0 -35
  150. package/src/chain-adapters/Cosmos/utils.ts +0 -45
  151. package/src/chain-adapters/EVM/EVM.test.ts +0 -238
  152. package/src/chain-adapters/EVM/EVM.ts +0 -337
  153. package/src/chain-adapters/EVM/index.ts +0 -11
  154. package/src/chain-adapters/EVM/types.ts +0 -53
  155. package/src/chain-adapters/EVM/utils.ts +0 -27
  156. package/src/chain-adapters/index.ts +0 -5
  157. package/src/constants.ts +0 -62
  158. package/src/contracts/ChainSignatureContract.ts +0 -65
  159. package/src/contracts/evm/ChainSignaturesContract.ts +0 -323
  160. package/src/contracts/evm/ChainSignaturesContractABI.ts +0 -359
  161. package/src/contracts/evm/errors.ts +0 -52
  162. package/src/contracts/evm/index.ts +0 -10
  163. package/src/contracts/evm/types.ts +0 -39
  164. package/src/contracts/evm/utils.ts +0 -41
  165. package/src/contracts/index.ts +0 -4
  166. package/src/contracts/near/ChainSignatureContract.ts +0 -196
  167. package/src/contracts/near/account.ts +0 -42
  168. package/src/contracts/near/constants.ts +0 -4
  169. package/src/contracts/near/index.ts +0 -10
  170. package/src/contracts/near/signAndSend/index.ts +0 -1
  171. package/src/contracts/near/signAndSend/keypair.ts +0 -178
  172. package/src/contracts/near/transaction.ts +0 -202
  173. package/src/contracts/near/types.ts +0 -71
  174. package/src/index.ts +0 -5
  175. package/src/types.ts +0 -46
  176. package/src/utils/cryptography.ts +0 -141
  177. package/src/utils/index.ts +0 -1
  178. package/src/utils/publicKey.ts +0 -17
  179. package/tsconfig.eslint.json +0 -8
  180. package/tsconfig.json +0 -126
  181. package/tsup.config.ts +0 -58
  182. package/vitest.config.ts +0 -19
  183. package/vocs.config.ts +0 -213
@@ -1,359 +0,0 @@
1
- export const abi = [
2
- {
3
- inputs: [
4
- { internalType: 'address', name: '_mpc_network', type: 'address' },
5
- { internalType: 'uint256', name: '_signatureDeposit', type: 'uint256' },
6
- ],
7
- stateMutability: 'nonpayable',
8
- type: 'constructor',
9
- },
10
- { inputs: [], name: 'AccessControlBadConfirmation', type: 'error' },
11
- {
12
- inputs: [
13
- { internalType: 'address', name: 'account', type: 'address' },
14
- { internalType: 'bytes32', name: 'neededRole', type: 'bytes32' },
15
- ],
16
- name: 'AccessControlUnauthorizedAccount',
17
- type: 'error',
18
- },
19
- {
20
- anonymous: false,
21
- inputs: [
22
- { indexed: true, internalType: 'bytes32', name: 'role', type: 'bytes32' },
23
- {
24
- indexed: true,
25
- internalType: 'bytes32',
26
- name: 'previousAdminRole',
27
- type: 'bytes32',
28
- },
29
- {
30
- indexed: true,
31
- internalType: 'bytes32',
32
- name: 'newAdminRole',
33
- type: 'bytes32',
34
- },
35
- ],
36
- name: 'RoleAdminChanged',
37
- type: 'event',
38
- },
39
- {
40
- anonymous: false,
41
- inputs: [
42
- { indexed: true, internalType: 'bytes32', name: 'role', type: 'bytes32' },
43
- {
44
- indexed: true,
45
- internalType: 'address',
46
- name: 'account',
47
- type: 'address',
48
- },
49
- {
50
- indexed: true,
51
- internalType: 'address',
52
- name: 'sender',
53
- type: 'address',
54
- },
55
- ],
56
- name: 'RoleGranted',
57
- type: 'event',
58
- },
59
- {
60
- anonymous: false,
61
- inputs: [
62
- { indexed: true, internalType: 'bytes32', name: 'role', type: 'bytes32' },
63
- {
64
- indexed: true,
65
- internalType: 'address',
66
- name: 'account',
67
- type: 'address',
68
- },
69
- {
70
- indexed: true,
71
- internalType: 'address',
72
- name: 'sender',
73
- type: 'address',
74
- },
75
- ],
76
- name: 'RoleRevoked',
77
- type: 'event',
78
- },
79
- {
80
- anonymous: false,
81
- inputs: [
82
- {
83
- indexed: true,
84
- internalType: 'bytes32',
85
- name: 'requestId',
86
- type: 'bytes32',
87
- },
88
- {
89
- indexed: false,
90
- internalType: 'address',
91
- name: 'responder',
92
- type: 'address',
93
- },
94
- { indexed: false, internalType: 'string', name: 'error', type: 'string' },
95
- ],
96
- name: 'SignatureError',
97
- type: 'event',
98
- },
99
- {
100
- anonymous: false,
101
- inputs: [
102
- {
103
- indexed: false,
104
- internalType: 'address',
105
- name: 'sender',
106
- type: 'address',
107
- },
108
- {
109
- indexed: false,
110
- internalType: 'bytes32',
111
- name: 'payload',
112
- type: 'bytes32',
113
- },
114
- {
115
- indexed: false,
116
- internalType: 'uint32',
117
- name: 'keyVersion',
118
- type: 'uint32',
119
- },
120
- {
121
- indexed: false,
122
- internalType: 'uint256',
123
- name: 'deposit',
124
- type: 'uint256',
125
- },
126
- {
127
- indexed: false,
128
- internalType: 'uint256',
129
- name: 'chainId',
130
- type: 'uint256',
131
- },
132
- { indexed: false, internalType: 'string', name: 'path', type: 'string' },
133
- { indexed: false, internalType: 'string', name: 'algo', type: 'string' },
134
- { indexed: false, internalType: 'string', name: 'dest', type: 'string' },
135
- {
136
- indexed: false,
137
- internalType: 'string',
138
- name: 'params',
139
- type: 'string',
140
- },
141
- ],
142
- name: 'SignatureRequested',
143
- type: 'event',
144
- },
145
- {
146
- anonymous: false,
147
- inputs: [
148
- {
149
- indexed: true,
150
- internalType: 'bytes32',
151
- name: 'requestId',
152
- type: 'bytes32',
153
- },
154
- {
155
- indexed: false,
156
- internalType: 'address',
157
- name: 'responder',
158
- type: 'address',
159
- },
160
- {
161
- components: [
162
- {
163
- components: [
164
- { internalType: 'uint256', name: 'x', type: 'uint256' },
165
- { internalType: 'uint256', name: 'y', type: 'uint256' },
166
- ],
167
- internalType: 'struct ChainSignatures.AffinePoint',
168
- name: 'bigR',
169
- type: 'tuple',
170
- },
171
- { internalType: 'uint256', name: 's', type: 'uint256' },
172
- { internalType: 'uint8', name: 'recoveryId', type: 'uint8' },
173
- ],
174
- indexed: false,
175
- internalType: 'struct ChainSignatures.Signature',
176
- name: 'signature',
177
- type: 'tuple',
178
- },
179
- ],
180
- name: 'SignatureResponded',
181
- type: 'event',
182
- },
183
- {
184
- anonymous: false,
185
- inputs: [
186
- {
187
- indexed: true,
188
- internalType: 'address',
189
- name: 'owner',
190
- type: 'address',
191
- },
192
- {
193
- indexed: false,
194
- internalType: 'uint256',
195
- name: 'amount',
196
- type: 'uint256',
197
- },
198
- ],
199
- name: 'Withdraw',
200
- type: 'event',
201
- },
202
- {
203
- inputs: [],
204
- name: 'DEFAULT_ADMIN_ROLE',
205
- outputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }],
206
- stateMutability: 'view',
207
- type: 'function',
208
- },
209
- {
210
- inputs: [{ internalType: 'bytes32', name: 'role', type: 'bytes32' }],
211
- name: 'getRoleAdmin',
212
- outputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }],
213
- stateMutability: 'view',
214
- type: 'function',
215
- },
216
- {
217
- inputs: [],
218
- name: 'getSignatureDeposit',
219
- outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
220
- stateMutability: 'view',
221
- type: 'function',
222
- },
223
- {
224
- inputs: [
225
- { internalType: 'bytes32', name: 'role', type: 'bytes32' },
226
- { internalType: 'address', name: 'account', type: 'address' },
227
- ],
228
- name: 'grantRole',
229
- outputs: [],
230
- stateMutability: 'nonpayable',
231
- type: 'function',
232
- },
233
- {
234
- inputs: [
235
- { internalType: 'bytes32', name: 'role', type: 'bytes32' },
236
- { internalType: 'address', name: 'account', type: 'address' },
237
- ],
238
- name: 'hasRole',
239
- outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
240
- stateMutability: 'view',
241
- type: 'function',
242
- },
243
- {
244
- inputs: [
245
- { internalType: 'bytes32', name: 'role', type: 'bytes32' },
246
- { internalType: 'address', name: 'callerConfirmation', type: 'address' },
247
- ],
248
- name: 'renounceRole',
249
- outputs: [],
250
- stateMutability: 'nonpayable',
251
- type: 'function',
252
- },
253
- {
254
- inputs: [
255
- {
256
- components: [
257
- { internalType: 'bytes32', name: 'requestId', type: 'bytes32' },
258
- {
259
- components: [
260
- {
261
- components: [
262
- { internalType: 'uint256', name: 'x', type: 'uint256' },
263
- { internalType: 'uint256', name: 'y', type: 'uint256' },
264
- ],
265
- internalType: 'struct ChainSignatures.AffinePoint',
266
- name: 'bigR',
267
- type: 'tuple',
268
- },
269
- { internalType: 'uint256', name: 's', type: 'uint256' },
270
- { internalType: 'uint8', name: 'recoveryId', type: 'uint8' },
271
- ],
272
- internalType: 'struct ChainSignatures.Signature',
273
- name: 'signature',
274
- type: 'tuple',
275
- },
276
- ],
277
- internalType: 'struct ChainSignatures.Response[]',
278
- name: '_responses',
279
- type: 'tuple[]',
280
- },
281
- ],
282
- name: 'respond',
283
- outputs: [],
284
- stateMutability: 'nonpayable',
285
- type: 'function',
286
- },
287
- {
288
- inputs: [
289
- {
290
- components: [
291
- { internalType: 'bytes32', name: 'requestId', type: 'bytes32' },
292
- { internalType: 'string', name: 'errorMessage', type: 'string' },
293
- ],
294
- internalType: 'struct ChainSignatures.ErrorResponse[]',
295
- name: '_errors',
296
- type: 'tuple[]',
297
- },
298
- ],
299
- name: 'respondError',
300
- outputs: [],
301
- stateMutability: 'nonpayable',
302
- type: 'function',
303
- },
304
- {
305
- inputs: [
306
- { internalType: 'bytes32', name: 'role', type: 'bytes32' },
307
- { internalType: 'address', name: 'account', type: 'address' },
308
- ],
309
- name: 'revokeRole',
310
- outputs: [],
311
- stateMutability: 'nonpayable',
312
- type: 'function',
313
- },
314
- {
315
- inputs: [{ internalType: 'uint256', name: '_amount', type: 'uint256' }],
316
- name: 'setSignatureDeposit',
317
- outputs: [],
318
- stateMutability: 'nonpayable',
319
- type: 'function',
320
- },
321
- {
322
- inputs: [
323
- {
324
- components: [
325
- { internalType: 'bytes32', name: 'payload', type: 'bytes32' },
326
- { internalType: 'string', name: 'path', type: 'string' },
327
- { internalType: 'uint32', name: 'keyVersion', type: 'uint32' },
328
- { internalType: 'string', name: 'algo', type: 'string' },
329
- { internalType: 'string', name: 'dest', type: 'string' },
330
- { internalType: 'string', name: 'params', type: 'string' },
331
- ],
332
- internalType: 'struct ChainSignatures.SignRequest',
333
- name: '_request',
334
- type: 'tuple',
335
- },
336
- ],
337
- name: 'sign',
338
- outputs: [],
339
- stateMutability: 'payable',
340
- type: 'function',
341
- },
342
- {
343
- inputs: [{ internalType: 'bytes4', name: 'interfaceId', type: 'bytes4' }],
344
- name: 'supportsInterface',
345
- outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
346
- stateMutability: 'view',
347
- type: 'function',
348
- },
349
- {
350
- inputs: [
351
- { internalType: 'uint256', name: '_amount', type: 'uint256' },
352
- { internalType: 'address', name: '_receiver', type: 'address' },
353
- ],
354
- name: 'withdraw',
355
- outputs: [],
356
- stateMutability: 'nonpayable',
357
- type: 'function',
358
- },
359
- ]
@@ -1,52 +0,0 @@
1
- import type { TransactionReceipt } from 'viem'
2
-
3
- export class ChainSignatureError extends Error {
4
- requestId: `0x${string}`
5
- receipt: TransactionReceipt
6
-
7
- constructor(
8
- message: string,
9
- requestId: `0x${string}`,
10
- receipt: TransactionReceipt
11
- ) {
12
- super(message)
13
- this.name = 'ChainSignatureError'
14
- this.requestId = requestId
15
- this.receipt = receipt
16
- }
17
- }
18
-
19
- export class SignatureNotFoundError extends ChainSignatureError {
20
- constructor(requestId: `0x${string}`, receipt: TransactionReceipt) {
21
- super('Signature not found after maximum retries', requestId, receipt)
22
- this.name = 'SignatureNotFoundError'
23
- }
24
- }
25
-
26
- export class SignatureContractError extends ChainSignatureError {
27
- errorCode: string
28
-
29
- constructor(
30
- errorCode: string,
31
- requestId: `0x${string}`,
32
- receipt: TransactionReceipt
33
- ) {
34
- super(`Signature error: ${errorCode}`, requestId, receipt)
35
- this.name = 'SignatureContractError'
36
- this.errorCode = errorCode
37
- }
38
- }
39
-
40
- export class SigningError extends ChainSignatureError {
41
- originalError?: Error
42
-
43
- constructor(
44
- requestId: `0x${string}`,
45
- receipt: TransactionReceipt,
46
- originalError?: Error
47
- ) {
48
- super('Error signing request', requestId, receipt)
49
- this.name = 'SigningError'
50
- this.originalError = originalError
51
- }
52
- }
@@ -1,10 +0,0 @@
1
- import * as ChainSignaturesContractABI from './ChainSignaturesContractABI'
2
- import * as errors from './errors'
3
- export * from './ChainSignaturesContract'
4
-
5
- const utils = {
6
- ChainSignaturesContractABI,
7
- errors,
8
- }
9
-
10
- export { utils }
@@ -1,39 +0,0 @@
1
- import type { Address, Hex } from 'viem'
2
-
3
- export interface SignOptions {
4
- sign: {
5
- algo?: string
6
- dest?: string
7
- params?: string
8
- }
9
- retry: {
10
- delay?: number
11
- retryCount?: number
12
- }
13
- }
14
-
15
- export interface SignatureErrorData {
16
- requestId: string
17
- responder: string
18
- error: string
19
- }
20
-
21
- export interface SignRequest {
22
- payload: Hex
23
- path: string
24
- keyVersion: number
25
- algo: string
26
- dest: string
27
- params: string
28
- }
29
-
30
- export interface RequestIdArgs {
31
- address: Address
32
- payload: Hex
33
- path: string
34
- keyVersion: number
35
- chainId: bigint
36
- algo: string
37
- dest: string
38
- params: string
39
- }
@@ -1,41 +0,0 @@
1
- import { encodeAbiParameters, keccak256 } from 'viem'
2
- import * as chains from 'viem/chains'
3
- import type { Chain } from 'viem/chains'
4
-
5
- import { type RequestIdArgs } from './types'
6
-
7
- export const getChain = (chainId: number): Chain => {
8
- for (const chain of Object.values(chains)) {
9
- if (chain.id === chainId) {
10
- return chain
11
- }
12
- }
13
- throw new Error('Chain not found')
14
- }
15
-
16
- export const getRequestId = (request: RequestIdArgs): `0x${string}` => {
17
- const encoded = encodeAbiParameters(
18
- [
19
- { type: 'address' },
20
- { type: 'bytes' },
21
- { type: 'string' },
22
- { type: 'uint32' },
23
- { type: 'uint256' },
24
- { type: 'string' },
25
- { type: 'string' },
26
- { type: 'string' },
27
- ],
28
- [
29
- request.address,
30
- request.payload,
31
- request.path,
32
- Number(request.keyVersion),
33
- request.chainId,
34
- request.algo,
35
- request.dest,
36
- request.params,
37
- ]
38
- )
39
-
40
- return keccak256(encoded)
41
- }
@@ -1,4 +0,0 @@
1
- export { ChainSignatureContract, type SignArgs } from './ChainSignatureContract'
2
-
3
- export * as near from './near'
4
- export * as evm from './evm'
@@ -1,196 +0,0 @@
1
- import { Contract } from '@near-js/accounts'
2
- import { KeyPair } from '@near-js/crypto'
3
- import { actionCreators } from '@near-js/transactions'
4
- import { najToUncompressedPubKeySEC1 } from '@utils/cryptography'
5
- import { getRootPublicKey } from '@utils/publicKey'
6
- import BN from 'bn.js'
7
-
8
- import { CHAINS, KDF_CHAIN_IDS } from '@constants'
9
- import { ChainSignatureContract as AbstractChainSignatureContract } from '@contracts/ChainSignatureContract'
10
- import type { SignArgs } from '@contracts/ChainSignatureContract'
11
- import { getNearAccount } from '@contracts/near/account'
12
- import { DONT_CARE_ACCOUNT_ID, NEAR_MAX_GAS } from '@contracts/near/constants'
13
- import {
14
- responseToMpcSignature,
15
- type SendTransactionOptions,
16
- sendTransactionUntil,
17
- } from '@contracts/near/transaction'
18
- import {
19
- type NearNetworkIds,
20
- type ChainSignatureContractIds,
21
- } from '@contracts/near/types'
22
- import type { RSVSignature, UncompressedPubKeySEC1, NajPublicKey } from '@types'
23
- import { cryptography } from '@utils'
24
-
25
- type NearContract = Contract & {
26
- public_key: () => Promise<NajPublicKey>
27
- experimental_signature_deposit: () => Promise<number>
28
- derived_public_key: (args: {
29
- path: string
30
- predecessor: string
31
- }) => Promise<NajPublicKey>
32
- }
33
-
34
- interface ChainSignatureContractArgs {
35
- networkId: NearNetworkIds
36
- contractId: ChainSignatureContractIds
37
- accountId?: string
38
- keypair?: KeyPair
39
- rootPublicKey?: NajPublicKey
40
- sendTransactionOptions?: SendTransactionOptions
41
- }
42
-
43
- /**
44
- * Implementation of the ChainSignatureContract for NEAR chains.
45
- *
46
- * This class provides an interface to interact with the ChainSignatures contract
47
- * deployed on NEAR. It supports both view methods (which don't require authentication)
48
- * and change methods (which require a valid NEAR account and keypair).
49
- *
50
- * @extends AbstractChainSignatureContract
51
- */
52
- export class ChainSignatureContract extends AbstractChainSignatureContract {
53
- private readonly networkId: NearNetworkIds
54
- private readonly contractId: ChainSignatureContractIds
55
- private readonly accountId: string
56
- private readonly keypair: KeyPair
57
- private readonly rootPublicKey?: NajPublicKey
58
- private readonly sendTransactionOptions?: SendTransactionOptions
59
- /**
60
- * Creates a new instance of the ChainSignatureContract for NEAR chains.
61
- *
62
- * @param args - Configuration options for the contract
63
- * @param args.networkId - The NEAR network ID (e.g. 'testnet', 'mainnet')
64
- * @param args.contractId - The contract ID of the deployed ChainSignatures contract
65
- * @param args.accountId - Optional NEAR account ID for signing transactions. Required for change methods.
66
- * @param args.keypair - Optional NEAR KeyPair for signing transactions. Required for change methods.
67
- * @param args.rootPublicKey - Optional root public key for the contract. If not provided, it will be derived from the contract ID.
68
- * @param args.sendTransactionOptions - Optional configuration for transaction sending behavior.
69
- */
70
- constructor({
71
- networkId,
72
- contractId,
73
- accountId = DONT_CARE_ACCOUNT_ID,
74
- keypair = KeyPair.fromRandom('ed25519'),
75
- rootPublicKey,
76
- sendTransactionOptions,
77
- }: ChainSignatureContractArgs) {
78
- super()
79
-
80
- this.networkId = networkId
81
- this.contractId = contractId
82
- this.accountId = accountId
83
- this.keypair = keypair
84
- this.sendTransactionOptions = sendTransactionOptions
85
-
86
- this.rootPublicKey =
87
- rootPublicKey || getRootPublicKey(this.contractId, CHAINS.NEAR)
88
- }
89
-
90
- private async getContract(): Promise<NearContract> {
91
- const account = await getNearAccount({
92
- networkId: this.networkId,
93
- accountId: this.accountId,
94
- keypair: this.keypair,
95
- })
96
-
97
- return new Contract(account, this.contractId, {
98
- viewMethods: [
99
- 'public_key',
100
- 'experimental_signature_deposit',
101
- 'derived_public_key',
102
- ],
103
- // Change methods use the sendTransactionUntil because the internal retry of the Contract class
104
- // throws on NodeJs.
105
- changeMethods: [],
106
- useLocalViewExecution: false,
107
- }) as unknown as NearContract
108
- }
109
-
110
- async getCurrentSignatureDeposit(): Promise<BN> {
111
- const contract = await this.getContract()
112
- return new BN(
113
- (await contract.experimental_signature_deposit()).toLocaleString(
114
- 'fullwide',
115
- {
116
- useGrouping: false,
117
- }
118
- )
119
- )
120
- }
121
-
122
- async getDerivedPublicKey(args: {
123
- path: string
124
- predecessor: string
125
- }): Promise<UncompressedPubKeySEC1> {
126
- if (this.rootPublicKey) {
127
- const pubKey = cryptography.deriveChildPublicKey(
128
- await this.getPublicKey(),
129
- args.predecessor.toLowerCase(),
130
- args.path,
131
- KDF_CHAIN_IDS.NEAR
132
- )
133
- return pubKey
134
- } else {
135
- // Support for legacy contract
136
- const contract = await this.getContract()
137
- const najPubKey = await contract.derived_public_key(args)
138
- return najToUncompressedPubKeySEC1(najPubKey)
139
- }
140
- }
141
-
142
- async getPublicKey(): Promise<UncompressedPubKeySEC1> {
143
- if (this.rootPublicKey) {
144
- return najToUncompressedPubKeySEC1(this.rootPublicKey)
145
- } else {
146
- // Support for legacy contract
147
- const contract = await this.getContract()
148
- const najPubKey = await contract.public_key()
149
- return najToUncompressedPubKeySEC1(najPubKey)
150
- }
151
- }
152
-
153
- async sign(
154
- args: SignArgs,
155
- options?: {
156
- nonce?: number
157
- }
158
- ): Promise<RSVSignature> {
159
- this.requireAccount()
160
-
161
- const deposit = await this.getCurrentSignatureDeposit()
162
-
163
- const result = await sendTransactionUntil({
164
- accountId: this.accountId,
165
- keypair: this.keypair,
166
- networkId: this.networkId,
167
- receiverId: this.contractId,
168
- actions: [
169
- actionCreators.functionCall(
170
- 'sign',
171
- { request: args },
172
- BigInt(NEAR_MAX_GAS.toString()),
173
- BigInt(deposit.toString())
174
- ),
175
- ],
176
- nonce: options?.nonce,
177
- options: this.sendTransactionOptions,
178
- })
179
-
180
- const signature = responseToMpcSignature({ response: result })
181
-
182
- if (!signature) {
183
- throw new Error('Transaction failed')
184
- }
185
-
186
- return signature
187
- }
188
-
189
- private requireAccount(): void {
190
- if (this.accountId === DONT_CARE_ACCOUNT_ID) {
191
- throw new Error(
192
- 'A valid account ID and keypair are required for change methods. Please instantiate a new contract with valid credentials.'
193
- )
194
- }
195
- }
196
- }