File tree Expand file tree Collapse file tree 2 files changed +37
-37
lines changed
components/coinbase_developer_platform Expand file tree Collapse file tree 2 files changed +37
-37
lines changed Original file line number Diff line number Diff line change 11import {
2- Coinbase , Wallet , Webhook ,
2+ Coinbase , Webhook ,
33} from "@coinbase/coinbase-sdk" ;
44
55export default {
66 type : "app" ,
77 app : "coinbase_developer_platform" ,
88 propDefinitions : {
9- walletId : {
9+ walletAddress : {
1010 type : "string" ,
11- label : "Wallet ID" ,
12- description : "The ID of the wallet to use" ,
11+ label : "Address" ,
12+ description : "The address of the wallet to monitor. Example: `0x8fddcc0c5c993a1968b46787919cc34577d6dc5c`" ,
13+ } ,
14+ networkId : {
15+ type : "string" ,
16+ label : "Network ID" ,
17+ description : "The network ID of the wallet to monitor. Example: `base-mainnet`" ,
1318 async options ( ) {
14- this . configure ( ) ;
15- const { data } = await this . listWallets ( ) ;
16- return data ?. map ( ( wallet ) => ( {
17- label : `${ wallet . model . network_id } - ${ wallet . model . default_address . wallet_id } ` ,
18- value : wallet . model . default_address . wallet_id ,
19- } ) ) || [ ] ;
19+ const networks = Coinbase . networks ;
20+ return Object . values ( networks ) ;
2021 } ,
2122 } ,
2223 } ,
@@ -29,12 +30,6 @@ export default {
2930 privateKey,
3031 } ) ;
3132 } ,
32- getWallet ( walletId ) {
33- return Wallet . fetch ( walletId ) ;
34- } ,
35- listWallets ( ) {
36- return Wallet . listWallets ( ) ;
37- } ,
3833 listWebhooks ( ) {
3934 return Webhook . list ( ) ;
4035 } ,
Original file line number Diff line number Diff line change @@ -12,38 +12,43 @@ export default {
1212 dedupe : "unique" ,
1313 props : {
1414 ...common . props ,
15- walletId : {
15+ walletAddress : {
1616 propDefinition : [
1717 common . props . coinbase ,
18- "walletId" ,
18+ "walletAddress" ,
19+ ] ,
20+ } ,
21+ networkId : {
22+ propDefinition : [
23+ common . props . coinbase ,
24+ "networkId" ,
1925 ] ,
2026 } ,
2127 } ,
2228 hooks : {
2329 async activate ( ) {
2430 this . coinbase . configure ( ) ;
25- const wallet = await this . coinbase . getWallet ( this . walletId ) ;
26- const networkId = wallet . model . network_id ;
27- const addresses = [
28- wallet . model . default_address . address_id ,
29- ...wallet . addresses ,
30- ] ;
31+ try {
32+ const webhook = await this . coinbase . createWebhook ( {
33+ notificationUri : this . http . endpoint ,
34+ eventType : "wallet_activity" ,
35+ networkId : this . networkId ,
36+ eventTypeFilter : {
37+ addresses : [
38+ this . walletAddress ,
39+ ] ,
40+ wallet_id : "" ,
41+ } ,
42+ } ) ;
3143
32- const webhook = await this . coinbase . createWebhook ( {
33- notificationUri : this . http . endpoint ,
34- eventType : "wallet_activity" ,
35- networkId,
36- eventTypeFilter : {
37- addresses,
38- wallet_id : this . walletId ,
39- } ,
40- } ) ;
44+ if ( ! webhook ?. model ?. id ) {
45+ throw new ConfigurationError ( "Failed to create webhook" ) ;
46+ }
4147
42- if ( ! webhook ?. model ?. id ) {
43- throw new ConfigurationError ( "Failed to create webhook" ) ;
48+ this . _setWebhookId ( webhook . model . id ) ;
49+ } catch ( error ) {
50+ console . log ( error ) ;
4451 }
45-
46- this . _setWebhookId ( webhook . model . id ) ;
4752 } ,
4853 async deactivate ( ) {
4954 this . coinbase . configure ( ) ;
You can’t perform that action at this time.
0 commit comments