To compile the contract yo need yo enter in 'wasm' and then put:
cargo build --release
A contract consists of two directories:
- App: Where lives all business logic.
- Wasm: Where the contract is built and the IDL is generated
This contract contains the signless and walletless feature, it uses the service "KeyringService" and extends the "KeyringQueryService" in "QueryService" from the keyring-service repository
-
QueryService:
This service in the contract extends the 'KeyringQueryService', which will give all the queries to obtain the keyring accounts, and the addresses of these keyring accounts.
This service contains an extra field that will contains the extended service:
// Service used for all queries pub struct QueryService { // To extend the wallet less service (and others services), yo need to create // an atribute to "store" the service keyring_query_service: KeyringQueryService }
And, you need to implement the "AsRef" trait in the extended service for the service that you use to extend it:
// You need to implement "AsRef" on the services that will extends another // service, in this case "KeyringQueryService" impl AsRef<KeyringQueryService> for QueryService { fn as_ref(&self) -> &KeyringQueryService { &self.keyring_query_service } }
-
KeyringService:
This service comes from the KeyringService repository, to use it, you just have to put it as another service in the program (This contract already implement it):
// code ... #[derive(Default)] pub struct Porgram; #[program] impl Program { #[route("KeyringService")] pub fn keyring_svc(&self) -> KeyringService { KeyringService::new() } // code ... }