signet.js 0.0.3 → 0.0.4
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/browser/index.browser.cjs +3 -0
- package/browser/index.browser.cjs.map +1 -0
- package/browser/index.browser.js +3 -0
- package/browser/index.browser.js.map +1 -0
- package/node/index.node.cjs +3 -0
- package/node/index.node.cjs.map +1 -0
- package/node/index.node.js +3 -0
- package/node/index.node.js.map +1 -0
- package/package.json +2 -2
- package/types/index.d.cts +919 -0
- package/types/index.d.ts +919 -0
- package/.eslintrc.json +0 -55
- package/.prettierrc +0 -1
- package/babel.config.js +0 -6
- package/docs/pages/index.mdx +0 -36
- package/docs/pages/signetjs/advanced/chain-signatures-contract.mdx +0 -52
- package/docs/pages/signetjs/advanced/chain.mdx +0 -45
- package/docs/pages/signetjs/chains/bitcoin/bitcoin.mdx +0 -171
- package/docs/pages/signetjs/chains/bitcoin/btc-rpc-adapter.mdx +0 -26
- package/docs/pages/signetjs/chains/cosmos.mdx +0 -171
- package/docs/pages/signetjs/chains/evm.mdx +0 -319
- package/docs/pages/signetjs/contract-addresses.mdx +0 -27
- package/docs/pages/signetjs/index.mdx +0 -88
- package/docs/snippets/code/contract.ts +0 -21
- package/docs/snippets/code/evm/env.ts +0 -16
- package/docs/snippets/code/near/env.ts +0 -13
- package/hardhat.config.mts +0 -19
- package/src/chains/Bitcoin/BTCRpcAdapter/BTCRpcAdapter.ts +0 -11
- package/src/chains/Bitcoin/BTCRpcAdapter/Mempool/Mempool.ts +0 -96
- package/src/chains/Bitcoin/BTCRpcAdapter/Mempool/index.ts +0 -1
- package/src/chains/Bitcoin/BTCRpcAdapter/Mempool/types.ts +0 -72
- package/src/chains/Bitcoin/BTCRpcAdapter/index.ts +0 -6
- package/src/chains/Bitcoin/Bitcoin.ts +0 -287
- package/src/chains/Bitcoin/types.ts +0 -48
- package/src/chains/Bitcoin/utils.ts +0 -14
- package/src/chains/Chain.ts +0 -92
- package/src/chains/ChainSignatureContract.ts +0 -65
- package/src/chains/Cosmos/Cosmos.ts +0 -258
- package/src/chains/Cosmos/types.ts +0 -35
- package/src/chains/Cosmos/utils.ts +0 -45
- package/src/chains/EVM/EVM.test.ts +0 -238
- package/src/chains/EVM/EVM.ts +0 -334
- package/src/chains/EVM/types.ts +0 -53
- package/src/chains/EVM/utils.ts +0 -27
- package/src/chains/index.ts +0 -38
- package/src/chains/types.ts +0 -46
- package/src/index.ts +0 -2
- package/src/utils/chains/evm/ChainSignaturesContract.ts +0 -286
- package/src/utils/chains/evm/ChainSignaturesContractABI.ts +0 -359
- package/src/utils/chains/evm/errors.ts +0 -52
- package/src/utils/chains/evm/index.ts +0 -3
- package/src/utils/chains/evm/types.ts +0 -28
- package/src/utils/chains/evm/utils.ts +0 -11
- package/src/utils/chains/index.ts +0 -2
- package/src/utils/chains/near/ChainSignatureContract.ts +0 -155
- package/src/utils/chains/near/account.ts +0 -42
- package/src/utils/chains/near/constants.ts +0 -4
- package/src/utils/chains/near/index.ts +0 -3
- package/src/utils/chains/near/signAndSend/index.ts +0 -1
- package/src/utils/chains/near/signAndSend/keypair.ts +0 -178
- package/src/utils/chains/near/transactionBuilder.ts +0 -73
- package/src/utils/chains/near/types.ts +0 -77
- package/src/utils/constants.ts +0 -62
- package/src/utils/cryptography.ts +0 -131
- package/src/utils/index.ts +0 -3
- package/src/utils/publicKey.ts +0 -23
- package/tsconfig.eslint.json +0 -8
- package/tsconfig.json +0 -122
- package/tsup.config.ts +0 -55
- package/vitest.config.ts +0 -16
- package/vocs.config.ts +0 -73
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
import BN from 'bn.js'
|
|
2
|
-
import {
|
|
3
|
-
encodeAbiParameters,
|
|
4
|
-
keccak256,
|
|
5
|
-
type TransactionReceipt,
|
|
6
|
-
withRetry,
|
|
7
|
-
type PublicClient,
|
|
8
|
-
type WalletClient,
|
|
9
|
-
type Hex,
|
|
10
|
-
} from 'viem'
|
|
11
|
-
|
|
12
|
-
import { ChainSignatureContract as AbstractChainSignatureContract } from '@chains/ChainSignatureContract'
|
|
13
|
-
import type { SignArgs } from '@chains/ChainSignatureContract'
|
|
14
|
-
import type {
|
|
15
|
-
NajPublicKey,
|
|
16
|
-
RSVSignature,
|
|
17
|
-
SigNetEvmMpcSignature,
|
|
18
|
-
UncompressedPubKeySEC1,
|
|
19
|
-
} from '@chains/types'
|
|
20
|
-
import { cryptography } from '@utils'
|
|
21
|
-
import { CHAINS, KDF_CHAIN_IDS } from '@utils/constants'
|
|
22
|
-
import { najToUncompressedPubKeySEC1 } from '@utils/cryptography'
|
|
23
|
-
import { getRootPublicKey } from '@utils/publicKey'
|
|
24
|
-
|
|
25
|
-
import { abi } from './ChainSignaturesContractABI'
|
|
26
|
-
import {
|
|
27
|
-
SignatureNotFoundError,
|
|
28
|
-
SignatureContractError,
|
|
29
|
-
SigningError,
|
|
30
|
-
} from './errors'
|
|
31
|
-
import type { SignOptions, SignRequest, SignatureErrorData } from './types'
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Implementation of the ChainSignatureContract for EVM chains.
|
|
35
|
-
*
|
|
36
|
-
* When signing data, the contract emits a SignatureRequested event with a requestId.
|
|
37
|
-
* This requestId is used to track the signature request and retrieve the signature
|
|
38
|
-
* once it's available. The sign method handles this process automatically by polling
|
|
39
|
-
* for the signature using the requestId.
|
|
40
|
-
*/
|
|
41
|
-
export class ChainSignatureContract extends AbstractChainSignatureContract {
|
|
42
|
-
private readonly publicClient: PublicClient
|
|
43
|
-
private readonly walletClient: WalletClient
|
|
44
|
-
private readonly contractAddress: Hex
|
|
45
|
-
private readonly rootPublicKey: NajPublicKey
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Creates a new instance of the ChainSignatureContract for EVM chains.
|
|
49
|
-
*
|
|
50
|
-
* @param args - Configuration options for the contract
|
|
51
|
-
* @param args.publicClient - A Viem PublicClient instance for reading from the blockchain
|
|
52
|
-
* @param args.walletClient - A Viem WalletClient instance for sending transactions
|
|
53
|
-
* @param args.contractAddress - The address of the deployed ChainSignatures contract (e.g. `0x857ED3A242B59cC24144814a0DF41C397a3811E6`)
|
|
54
|
-
* @param args.rootPublicKey - Optional root public key. If not provided, it will be derived from the contract address
|
|
55
|
-
*/
|
|
56
|
-
constructor(args: {
|
|
57
|
-
publicClient: PublicClient
|
|
58
|
-
walletClient: WalletClient
|
|
59
|
-
contractAddress: Hex
|
|
60
|
-
rootPublicKey?: NajPublicKey
|
|
61
|
-
}) {
|
|
62
|
-
super()
|
|
63
|
-
this.publicClient = args.publicClient
|
|
64
|
-
this.walletClient = args.walletClient
|
|
65
|
-
this.contractAddress = args.contractAddress
|
|
66
|
-
|
|
67
|
-
this.rootPublicKey =
|
|
68
|
-
args.rootPublicKey ||
|
|
69
|
-
getRootPublicKey(this.contractAddress, CHAINS.ETHEREUM)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
async getCurrentSignatureDeposit(): Promise<BN> {
|
|
73
|
-
const deposit = (await this.publicClient.readContract({
|
|
74
|
-
address: this.contractAddress,
|
|
75
|
-
abi,
|
|
76
|
-
functionName: 'getSignatureDeposit',
|
|
77
|
-
})) as bigint
|
|
78
|
-
|
|
79
|
-
return new BN(deposit.toString())
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
async getDerivedPublicKey(args: {
|
|
83
|
-
path: string
|
|
84
|
-
predecessor: string
|
|
85
|
-
}): Promise<UncompressedPubKeySEC1> {
|
|
86
|
-
const pubKey = cryptography.deriveChildPublicKey(
|
|
87
|
-
await this.getPublicKey(),
|
|
88
|
-
args.predecessor.toLowerCase(),
|
|
89
|
-
args.path,
|
|
90
|
-
KDF_CHAIN_IDS.ETHEREUM
|
|
91
|
-
)
|
|
92
|
-
|
|
93
|
-
return pubKey
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
async getPublicKey(): Promise<UncompressedPubKeySEC1> {
|
|
97
|
-
return najToUncompressedPubKeySEC1(this.rootPublicKey)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
async getLatestKeyVersion(): Promise<number> {
|
|
101
|
-
const version = (await this.publicClient.readContract({
|
|
102
|
-
address: this.contractAddress,
|
|
103
|
-
abi,
|
|
104
|
-
functionName: 'latestKeyVersion',
|
|
105
|
-
})) as bigint
|
|
106
|
-
|
|
107
|
-
return Number(version)
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
async sign(
|
|
111
|
-
args: SignArgs,
|
|
112
|
-
options: SignOptions = {
|
|
113
|
-
sign: {
|
|
114
|
-
algo: '',
|
|
115
|
-
dest: '',
|
|
116
|
-
params: '',
|
|
117
|
-
},
|
|
118
|
-
retry: {
|
|
119
|
-
delay: 5000,
|
|
120
|
-
retryCount: 12,
|
|
121
|
-
},
|
|
122
|
-
}
|
|
123
|
-
): Promise<RSVSignature> {
|
|
124
|
-
if (!this.walletClient?.account) {
|
|
125
|
-
throw new Error('Wallet client required for signing operations')
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const request: SignRequest = {
|
|
129
|
-
payload: `0x${Buffer.from(args.payload).toString('hex')}`,
|
|
130
|
-
path: args.path,
|
|
131
|
-
keyVersion: args.key_version,
|
|
132
|
-
algo: options.sign.algo ?? '',
|
|
133
|
-
dest: options.sign.dest ?? '',
|
|
134
|
-
params: options.sign.params ?? '',
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const requestId = this.getRequestId(request)
|
|
138
|
-
|
|
139
|
-
const hash = await this.walletClient.writeContract({
|
|
140
|
-
address: this.contractAddress,
|
|
141
|
-
abi,
|
|
142
|
-
chain: this.publicClient.chain,
|
|
143
|
-
account: this.walletClient.account,
|
|
144
|
-
functionName: 'sign',
|
|
145
|
-
args: [request],
|
|
146
|
-
value: BigInt((await this.getCurrentSignatureDeposit()).toString()),
|
|
147
|
-
})
|
|
148
|
-
|
|
149
|
-
const receipt = await this.publicClient.waitForTransactionReceipt({ hash })
|
|
150
|
-
|
|
151
|
-
try {
|
|
152
|
-
const result = await withRetry(
|
|
153
|
-
async () => {
|
|
154
|
-
const result = await this.getSignatureFromEvents(requestId, receipt)
|
|
155
|
-
if (result) {
|
|
156
|
-
return result
|
|
157
|
-
} else {
|
|
158
|
-
throw new Error('Signature not found yet')
|
|
159
|
-
}
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
delay: options.retry.delay,
|
|
163
|
-
retryCount: options.retry.retryCount,
|
|
164
|
-
shouldRetry: ({ count, error }) => {
|
|
165
|
-
// TODO: Should be enabled only on debug mode
|
|
166
|
-
console.log(
|
|
167
|
-
`Retrying get signature: ${count}/${options.retry.retryCount}`
|
|
168
|
-
)
|
|
169
|
-
return error.message === 'Signature not found yet'
|
|
170
|
-
},
|
|
171
|
-
}
|
|
172
|
-
)
|
|
173
|
-
|
|
174
|
-
if (result) {
|
|
175
|
-
return result
|
|
176
|
-
} else {
|
|
177
|
-
const errorData = await this.getErrorFromEvents(requestId, receipt)
|
|
178
|
-
if (errorData) {
|
|
179
|
-
throw new SignatureContractError(errorData.error, requestId, receipt)
|
|
180
|
-
} else {
|
|
181
|
-
throw new SignatureNotFoundError(requestId, receipt)
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
} catch (error) {
|
|
185
|
-
if (
|
|
186
|
-
error instanceof SignatureNotFoundError ||
|
|
187
|
-
error instanceof SignatureContractError
|
|
188
|
-
) {
|
|
189
|
-
throw error
|
|
190
|
-
} else {
|
|
191
|
-
throw new SigningError(
|
|
192
|
-
requestId,
|
|
193
|
-
receipt,
|
|
194
|
-
error instanceof Error ? error : undefined
|
|
195
|
-
)
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
private getRequestId(request: SignRequest): `0x${string}` {
|
|
201
|
-
if (!this.walletClient?.account) {
|
|
202
|
-
throw new Error('Wallet client required for signing operations')
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
const encoded = encodeAbiParameters(
|
|
206
|
-
[
|
|
207
|
-
{ type: 'address' },
|
|
208
|
-
{ type: 'bytes' },
|
|
209
|
-
{ type: 'string' },
|
|
210
|
-
{ type: 'uint32' },
|
|
211
|
-
{ type: 'uint256' },
|
|
212
|
-
{ type: 'string' },
|
|
213
|
-
{ type: 'string' },
|
|
214
|
-
{ type: 'string' },
|
|
215
|
-
],
|
|
216
|
-
[
|
|
217
|
-
this.walletClient.account.address,
|
|
218
|
-
request.payload,
|
|
219
|
-
request.path,
|
|
220
|
-
Number(request.keyVersion),
|
|
221
|
-
this.publicClient.chain?.id ? BigInt(this.publicClient.chain.id) : 0n,
|
|
222
|
-
request.algo,
|
|
223
|
-
request.dest,
|
|
224
|
-
request.params,
|
|
225
|
-
]
|
|
226
|
-
)
|
|
227
|
-
|
|
228
|
-
return keccak256(encoded)
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
async getErrorFromEvents(
|
|
232
|
-
requestId: `0x${string}`,
|
|
233
|
-
receipt: TransactionReceipt
|
|
234
|
-
): Promise<SignatureErrorData | undefined> {
|
|
235
|
-
const errorLogs = await this.publicClient.getContractEvents({
|
|
236
|
-
address: this.contractAddress,
|
|
237
|
-
abi,
|
|
238
|
-
eventName: 'SignatureError',
|
|
239
|
-
args: {
|
|
240
|
-
requestId,
|
|
241
|
-
},
|
|
242
|
-
fromBlock: receipt.blockNumber,
|
|
243
|
-
toBlock: 'latest',
|
|
244
|
-
})
|
|
245
|
-
|
|
246
|
-
if (errorLogs.length > 0) {
|
|
247
|
-
const { args: errorData } = errorLogs[
|
|
248
|
-
errorLogs.length - 1
|
|
249
|
-
] as unknown as {
|
|
250
|
-
args: SignatureErrorData
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
return errorData
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
return undefined
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
async getSignatureFromEvents(
|
|
260
|
-
requestId: `0x${string}`,
|
|
261
|
-
receipt: TransactionReceipt
|
|
262
|
-
): Promise<RSVSignature | undefined> {
|
|
263
|
-
const logs = await this.publicClient.getContractEvents({
|
|
264
|
-
address: this.contractAddress,
|
|
265
|
-
abi,
|
|
266
|
-
eventName: 'SignatureResponded',
|
|
267
|
-
args: {
|
|
268
|
-
requestId,
|
|
269
|
-
},
|
|
270
|
-
fromBlock: receipt.blockNumber,
|
|
271
|
-
toBlock: 'latest',
|
|
272
|
-
})
|
|
273
|
-
|
|
274
|
-
if (logs.length > 0) {
|
|
275
|
-
const { args: signatureData } = logs[logs.length - 1] as unknown as {
|
|
276
|
-
args: {
|
|
277
|
-
signature: SigNetEvmMpcSignature
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
return cryptography.toRSV(signatureData.signature)
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
return undefined
|
|
285
|
-
}
|
|
286
|
-
}
|
|
@@ -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
|
-
}
|