@@ -51,9 +51,17 @@ export async function provisionCircleWallet({
51
51
} ) ;
52
52
53
53
if ( ! walletSetId ) {
54
- const walletSet = await circleDeveloperSdk . createWalletSet ( {
55
- name : `Engine WalletSet ${ new Date ( ) . toISOString ( ) } ` ,
56
- } ) ;
54
+ const walletSet = await circleDeveloperSdk
55
+ . createWalletSet ( {
56
+ name : `Engine WalletSet ${ new Date ( ) . toISOString ( ) } ` ,
57
+ } )
58
+ . catch ( ( e ) => {
59
+ throw new CircleWalletError (
60
+ `[Circle] Could not create walletset:\n${ JSON . stringify (
61
+ e ?. response ?. data ,
62
+ ) } `,
63
+ ) ;
64
+ } ) ;
57
65
58
66
walletSetId = walletSet . data ?. walletSet . id ;
59
67
}
@@ -63,12 +71,20 @@ export async function provisionCircleWallet({
63
71
"Did not receive walletSetId, and failed to create one automatically" ,
64
72
) ;
65
73
66
- const provisionWalletResponse = await circleDeveloperSdk . createWallets ( {
67
- accountType : "EOA" ,
68
- blockchains : [ "EVM" ] ,
69
- count : 1 ,
70
- walletSetId : walletSetId ,
71
- } ) ;
74
+ const provisionWalletResponse = await circleDeveloperSdk
75
+ . createWallets ( {
76
+ accountType : "EOA" ,
77
+ blockchains : [ "EVM" ] ,
78
+ count : 1 ,
79
+ walletSetId : walletSetId ,
80
+ } )
81
+ . catch ( ( e ) => {
82
+ throw new CircleWalletError (
83
+ `[Circle] Could not provision wallet:\n${ JSON . stringify (
84
+ e ?. response ?. data ,
85
+ ) } `,
86
+ ) ;
87
+ } ) ;
72
88
73
89
const provisionedWallet = provisionWalletResponse . data ?. wallets ?. [ 0 ] ;
74
90
@@ -119,7 +135,16 @@ export async function getCircleAccount({
119
135
entitySecret,
120
136
} ) ;
121
137
122
- const walletResponse = await circleDeveloperSdk . getWallet ( { id : walletId } ) ;
138
+ const walletResponse = await circleDeveloperSdk
139
+ . getWallet ( { id : walletId } )
140
+ . catch ( ( e ) => {
141
+ throw new CircleWalletError (
142
+ `[Circle] Could not get wallet with id:${ walletId } :\n${ JSON . stringify (
143
+ e ?. response ?. data ,
144
+ ) } `,
145
+ ) ;
146
+ } ) ;
147
+
123
148
if ( ! walletResponse ) {
124
149
throw new CircleWalletError (
125
150
`Unable to get circle wallet with id:${ walletId } ` ,
@@ -138,10 +163,18 @@ export async function getCircleAccount({
138
163
}
139
164
140
165
async function signTransaction ( tx : SerializableTransaction ) {
141
- const signature = await circleDeveloperSdk . signTransaction ( {
142
- walletId,
143
- transaction : stringify ( tx ) ,
144
- } ) ;
166
+ const signature = await circleDeveloperSdk
167
+ . signTransaction ( {
168
+ walletId,
169
+ transaction : stringify ( tx ) ,
170
+ } )
171
+ . catch ( ( e ) => {
172
+ throw new CircleWalletError (
173
+ `[Circle] Could not get transaction signature:\n${ JSON . stringify (
174
+ e ?. response ?. data ,
175
+ ) } `,
176
+ ) ;
177
+ } ) ;
145
178
146
179
if ( ! signature . data ?. signature ) {
147
180
throw new CircleWalletError ( "Unable to sign transaction" ) ;
@@ -177,10 +210,18 @@ export async function getCircleAccount({
177
210
const typedData extends TypedData | Record < string , unknown > ,
178
211
primaryType extends keyof typedData | "EIP712Domain" = keyof typedData ,
179
212
> ( _typedData : TypedDataDefinition < typedData , primaryType > ) : Promise < Hex > {
180
- const signatureResponse = await circleDeveloperSdk . signTypedData ( {
181
- data : stringify ( _typedData ) ,
182
- walletId,
183
- } ) ;
213
+ const signatureResponse = await circleDeveloperSdk
214
+ . signTypedData ( {
215
+ data : stringify ( _typedData ) ,
216
+ walletId,
217
+ } )
218
+ . catch ( ( e ) => {
219
+ throw new CircleWalletError (
220
+ `[Circle] Could not get signature:\n${ JSON . stringify (
221
+ e ?. response ?. data ,
222
+ ) } `,
223
+ ) ;
224
+ } ) ;
184
225
185
226
if ( ! signatureResponse . data ?. signature ) {
186
227
throw new CircleWalletError ( "Could not sign typed data" ) ;
@@ -201,11 +242,19 @@ export async function getCircleAccount({
201
242
messageToSign = toHex ( messageToSign ) ;
202
243
}
203
244
204
- const signatureResponse = await circleDeveloperSdk . signMessage ( {
205
- walletId,
206
- message : messageToSign ,
207
- encodedByHex : isRawMessage ,
208
- } ) ;
245
+ const signatureResponse = await circleDeveloperSdk
246
+ . signMessage ( {
247
+ walletId,
248
+ message : messageToSign ,
249
+ encodedByHex : isRawMessage ,
250
+ } )
251
+ . catch ( ( e ) => {
252
+ throw new CircleWalletError (
253
+ `[Circle] Could not get signature:\n${ JSON . stringify (
254
+ e ?. response ?. data ,
255
+ ) } `,
256
+ ) ;
257
+ } ) ;
209
258
210
259
if ( ! signatureResponse . data ?. signature )
211
260
throw new CircleWalletError ( "Could not get signature" ) ;
0 commit comments