1- import { Component } from ' react'
2- import ' ./App.css'
1+ import { Component } from " react" ;
2+ import " ./App.css" ;
33
4- import { KitEventType , SwkAppDarkTheme } from "@creit-tech/stellar-wallets-kit/types" ;
4+ import {
5+ KitEventType ,
6+ SwkAppDarkTheme ,
7+ } from "@creit-tech/stellar-wallets-kit/types" ;
58import { StellarWalletsKit } from "@creit-tech/stellar-wallets-kit/sdk" ;
6- import { activeAddress , activeModule , } from "@creit-tech/stellar-wallets-kit/state" ;
7- import { ButtonMode } from '@creit-tech/stellar-wallets-kit/components' ;
8- import { defaultModules } from '@creit-tech/stellar-wallets-kit/modules/utils' ;
9+ import {
10+ activeAddress ,
11+ activeModule ,
12+ } from "@creit-tech/stellar-wallets-kit/state" ;
13+ import { ButtonMode } from "@creit-tech/stellar-wallets-kit/components" ;
14+ import { defaultModules } from "@creit-tech/stellar-wallets-kit/modules/utils" ;
915import { TrezorModule } from "@creit-tech/stellar-wallets-kit/modules/trezor" ;
16+ import { LedgerModule } from "@creit-tech/stellar-wallets-kit/modules/ledger" ;
1017import { WalletConnectModule } from "@creit-tech/stellar-wallets-kit/modules/wallet-connect" ;
1118
12- import { Account , Networks , Operation , TransactionBuilder , } from "@stellar/stellar-sdk" ;
19+ import {
20+ Account ,
21+ Networks ,
22+ Operation ,
23+ TransactionBuilder ,
24+ } from "@stellar/stellar-sdk" ;
1325
1426StellarWalletsKit . init ( {
1527 theme : {
1628 ...SwkAppDarkTheme ,
17- primary : ' #1a1a1a' ,
18- ' primary-foreground' : ' rgba(255, 255, 255, 0.87)' ,
19- ' border-radius' : ' 8px' ,
20- shadow : ' none' ,
21- background : ' #1a1a1a' ,
22- foreground : ' rgba(255, 255, 255, 0.87)'
29+ primary : " #1a1a1a" ,
30+ " primary-foreground" : " rgba(255, 255, 255, 0.87)" ,
31+ " border-radius" : " 8px" ,
32+ shadow : " none" ,
33+ background : " #1a1a1a" ,
34+ foreground : " rgba(255, 255, 255, 0.87)" ,
2335 } ,
2436 modules : [
2537 ...defaultModules ( ) ,
38+ new LedgerModule ( ) ,
2639 new TrezorModule ( {
2740 appName : "Stellar Wallets Kit" ,
2841 appUrl : "http://localhost:5173" ,
@@ -34,8 +47,8 @@ StellarWalletsKit.init({
3447 name : "Stellar Wallets Kit" ,
3548 description : "Add support to all Stellar Wallets with a single library" ,
3649 icons : [ ] ,
37- url : ' http://localhost:5173/' ,
38- }
50+ url : " http://localhost:5173/" ,
51+ } ,
3952 } ) ,
4053 ] ,
4154} ) ;
@@ -51,25 +64,25 @@ export class App extends Component<any, any> {
5164 * IMPORTANT: In this example we are not destroying these subscriptions,
5265 * in your app you should do it when components are unmount.
5366 */
54- StellarWalletsKit . on ( KitEventType . STATE_UPDATED , event => {
67+ StellarWalletsKit . on ( KitEventType . STATE_UPDATED , ( event ) => {
5568 console . log ( `Address updated:` , event . payload . address ) ;
56- this . setState ( { address : event . payload . address } ) ;
69+ this . setState ( { address : event . payload . address } ) ;
5770 } ) ;
58- StellarWalletsKit . on ( KitEventType . WALLET_SELECTED , event => {
71+ StellarWalletsKit . on ( KitEventType . WALLET_SELECTED , ( event ) => {
5972 console . log ( `Wallet ID:` , event . payload . id ) ;
60- this . setState ( { moduleId : event . payload . id } ) ;
73+ this . setState ( { moduleId : event . payload . id } ) ;
6174 } ) ;
6275 StellarWalletsKit . on ( KitEventType . DISCONNECT , ( ) => {
63- this . setState ( { address : undefined , productName : undefined } ) ;
76+ this . setState ( { address : undefined , productName : undefined } ) ;
6477 } ) ;
65- StellarWalletsKit . createButton ( document . querySelector ( ' #button' ) ! , {
78+ StellarWalletsKit . createButton ( document . querySelector ( " #button" ) ! , {
6679 mode : ButtonMode . free ,
6780 } ) ;
6881 }
6982
7083 async authModal ( ) : Promise < void > {
7184 try {
72- const { address} = await StellarWalletsKit . authModal ( ) ;
85+ const { address } = await StellarWalletsKit . authModal ( ) ;
7386 console . log ( `Address fetched:` , address ) ;
7487 } catch ( e ) {
7588 console . error ( e ) ;
@@ -81,7 +94,7 @@ export class App extends Component<any, any> {
8194 }
8295
8396 async signTransaction ( ) : Promise < void > {
84- const { address} = await StellarWalletsKit . getAddress ( ) ;
97+ const { address } = await StellarWalletsKit . getAddress ( ) ;
8598 console . log ( "StellarWalletsKit::getAddress" , address ) ;
8699 const tx = new TransactionBuilder ( new Account ( address , "-1" ) , {
87100 networkPassphrase : Networks . PUBLIC ,
@@ -96,12 +109,28 @@ export class App extends Component<any, any> {
96109 )
97110 . build ( ) ;
98111
99- const { signedTxXdr} = await StellarWalletsKit . signTransaction ( tx . toXDR ( ) , {
112+ const { signedTxXdr } = await StellarWalletsKit . signTransaction (
113+ tx . toXDR ( ) ,
114+ {
115+ networkPassphrase : Networks . PUBLIC ,
116+ address,
117+ } ,
118+ ) ;
119+
120+ console . log ( "Signed Transaction:" , signedTxXdr ) ;
121+ }
122+
123+ async signAuthEntry ( ) : Promise < void > {
124+ const { address } = await StellarWalletsKit . getAddress ( ) ;
125+ const xdr =
126+ "AAAACXrDOZdUTjF10ma9AiQ5sizbFlCMARY/JuXLKj4QRal5Ueb3t2qeufIDkl6TAAAAAAAAAAHD5Dhm6FraoWtNw3xmsftfw43aav9gLsi5kDYD1ccr/gAAAApzdGFydF9nYW1lAAAAAAAFAAAAAy2DQRwAAAASAAAAAAAAAACO+drsns+C8ivJ7BbEvGPuuaf+RI7JYRYQh3tTDoG6yAAAABIAAAAAAAAAADzwlU9pvQCCZwaS876OkOohieXRjEidV8RoVpxgVhODAAAACgAAAAAAAAAAAAAAAAAPQkAAAAAKAAAAAAAAAAAAAAAAAA9CQAAAAAEAAAAAAAAAAQ711IO2j2xojpimQQ1dzE4A9Kskd2MeHXPKwLGFTKYYAAAACnN0YXJ0X2dhbWUAAAAAAAYAAAASAAAAAcPkOGboWtqha03DfGax+1/Djdpq/2AuyLmQNgPVxyv+AAAAAy2DQRwAAAASAAAAAAAAAACO+drsns+C8ivJ7BbEvGPuuaf+RI7JYRYQh3tTDoG6yAAAABIAAAAAAAAAADzwlU9pvQCCZwaS876OkOohieXRjEidV8RoVpxgVhODAAAACgAAAAAAAAAAAAAAAAAPQkAAAAAKAAAAAAAAAAAAAAAAAA9CQAAAAAA=" ;
127+
128+ const { signedAuthEntry } = await StellarWalletsKit . signAuthEntry ( xdr , {
100129 networkPassphrase : Networks . PUBLIC ,
101130 address,
102131 } ) ;
103132
104- console . log ( "Signed Transaction :" , signedTxXdr ) ;
133+ console . log ( "Signed Auth Entry :" , signedAuthEntry ) ;
105134 }
106135
107136 render ( ) {
@@ -111,37 +140,46 @@ export class App extends Component<any, any> {
111140 < div className = "card" >
112141 < section >
113142 < div >
114- < button onClick = { ( ) => this . authModal ( ) } >
143+ < button onClick = { ( ) => this . authModal ( ) } >
115144 Connect Wallet
116145 </ button >
117146
118- < button onClick = { ( ) => this . disconnect ( ) } >
147+ < button onClick = { ( ) => this . disconnect ( ) } >
119148 Disconnect
120149 </ button >
121150
122- < button onClick = { ( ) => this . signTransaction ( ) } >
151+ < button onClick = { ( ) => this . signTransaction ( ) } >
123152 Sign transaction
124153 </ button >
125154
126- < button onClick = { ( ) => StellarWalletsKit . profileModal ( ) } >
155+ < button onClick = { ( ) => this . signAuthEntry ( ) } >
156+ Sign auth Entry
157+ </ button >
158+
159+ < button onClick = { ( ) => StellarWalletsKit . profileModal ( ) } >
127160 Profile Modal
128161 </ button >
129162 </ div >
130163
131164 < div >
132165 < p >
133- Your selected wallet is: < br /> { this . state . moduleId }
166+ Your selected wallet is: < br /> { this . state . moduleId }
134167 </ p >
135168 < p >
136- Your account is: < br /> { this . state . address &&
137- `${ this . state . address . slice ( 0 , 4 ) } ....${ this . state . address . slice ( - 6 ) } ` }
169+ Your account is: < br /> { this . state . address &&
170+ `${ this . state . address . slice ( 0 , 4 ) } ....${
171+ this . state . address . slice ( - 6 )
172+ } `}
138173 </ p >
139174
140- < div style = { { marginBottom : ' 3rem' } } > </ div >
175+ < div style = { { marginBottom : " 3rem" } } > </ div >
141176
142177 < div >
143- < p > This is the built button, it follows the theme configured in the kit but we are using the "free" mode
144- of the button so it uses our global React defined styles :</ p >
178+ < p >
179+ This is the built button, it follows the theme configured in
180+ the kit but we are using the "free" mode of the button so it
181+ uses our global React defined styles :
182+ </ p >
145183 < div id = "button" > </ div >
146184 </ div >
147185 </ div >
@@ -152,4 +190,4 @@ export class App extends Component<any, any> {
152190 }
153191}
154192
155- export default App
193+ export default App ;
0 commit comments