File tree 3 files changed +54
-2
lines changed
3 files changed +54
-2
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,8 @@ export const dripFaucet = async (
26
26
await circleUserSdk . requestTestnetTokens ( {
27
27
address : req . body . address ,
28
28
blockchain : req . body . blockchain ,
29
- usdc : true
29
+ usdc : true ,
30
+ native : req . body . blockchain === 'AVAX-FUJI'
30
31
} ) ;
31
32
32
33
res . status ( 200 ) . send ( ) ;
Original file line number Diff line number Diff line change 14
14
// See the License for the specific language governing permissions and
15
15
// limitations under the License.
16
16
17
+ import { Blockchain } from '@circle-fin/user-controlled-wallets' ;
17
18
import { circleUserSdk } from '../services' ;
18
19
import { Request , Response , NextFunction } from 'express' ;
19
20
@@ -67,3 +68,20 @@ export const getWallet = async (
67
68
next ( error ) ;
68
69
}
69
70
} ;
71
+
72
+ export const createWallet = async (
73
+ req : Request ,
74
+ res : Response ,
75
+ next : NextFunction
76
+ ) => {
77
+ try {
78
+ const response = await circleUserSdk . createWallet ( {
79
+ blockchains : [ req . body . blockchain as Blockchain ] ,
80
+ userToken : req . headers [ 'token' ] as string
81
+ } ) ;
82
+
83
+ res . status ( 200 ) . send ( response . data ?. challengeId ) ;
84
+ } catch ( error : unknown ) {
85
+ next ( error ) ;
86
+ }
87
+ } ;
Original file line number Diff line number Diff line change @@ -21,7 +21,14 @@ import {
21
21
validate ,
22
22
walletTokenBalanceSchema
23
23
} from '../middleware' ;
24
- import { getWallet , getWalletTokenBalance , listWallets } from '../controllers' ;
24
+ import {
25
+ createWallet ,
26
+ getWallet ,
27
+ getWalletTokenBalance ,
28
+ listWallets
29
+ } from '../controllers' ;
30
+
31
+ import * as yup from 'yup' ;
25
32
26
33
const wallets = express . Router ( ) ;
27
34
@@ -122,4 +129,30 @@ wallets.get(
122
129
*/
123
130
wallets . get ( '/:id' , validate ( getWalletSchema ) , getWallet ) ;
124
131
132
+ /**
133
+ * POST - /wallets
134
+ * Creates a user controlled wallet with given blockchain.
135
+ *
136
+ * Body:
137
+ * blockchain: Blockchain - Blockchain network to create wallet on
138
+ *
139
+ * Returns:
140
+ * challengeId: string - used to initiate a challenge flow for the user to create new wallet
141
+ *
142
+ */
143
+ wallets . post (
144
+ '/' ,
145
+ validate (
146
+ yup . object ( {
147
+ body : yup
148
+ . object ( {
149
+ blockchain : yup . string ( ) . required ( )
150
+ } )
151
+ . noUnknown ( true )
152
+ . strict ( )
153
+ } )
154
+ ) ,
155
+ createWallet
156
+ ) ;
157
+
125
158
export { wallets } ;
You can’t perform that action at this time.
0 commit comments