Skip to content

Commit

Permalink
documented some of the methods used for the faucet
Browse files Browse the repository at this point in the history
  • Loading branch information
rh0delta committed Sep 24, 2024
1 parent 0693af4 commit 60996a0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/faucet/interaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export async function entropyFaucet (entropy: Entropy, options, logger: EntropyL
return sendMoneyFromRandomFaucet(entropy, options.endpoint, verifyingKeys, logger)
}

// Method that takes in the initial list of verifying keys (to avoid multiple calls to the rpc) and recursively retries each faucet until
// a successful transfer is made
async function sendMoneyFromRandomFaucet (entropy: Entropy, endpoint: string, verifyingKeys: string[], logger: EntropyLogger) {
const faucetService = new EntropyFaucet(entropy, endpoint)
const selectedAccountAddress = entropy.keyring.accounts.registration.address
Expand Down
5 changes: 4 additions & 1 deletion src/faucet/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export class EntropyFaucet extends EntropyBase {
super({ entropy, endpoint, flowContext: FLOW_CONTEXT })
}

// Method used to sign and send the transfer request (transfer request = call argument) using the custom signer
// created to overwrite how we sign the payload that is sent up chain
async faucetSignAndSend (call: any, amount: number, senderAddress: string, chosenVerifyingKey: any): Promise<any> {
const api = this.entropy.substrate
const faucetSigner = new FaucetSigner(api.registry, this.entropy, amount, chosenVerifyingKey)
Expand Down Expand Up @@ -50,8 +52,9 @@ export class EntropyFaucet extends EntropyBase {
return modifiableKeys.toJSON()
}

// To handle overloading the individual faucet, multiple faucet accounts have been generated, and here is
// where we choose one of those faucet's at random
getRandomFaucet (previousVerifyingKeys: string[] = [], allVerifyingKeys: string[] = []) {
// Choosing one of the 5 verifiying keys at random to be used as the faucet sender
if (allVerifyingKeys.length === previousVerifyingKeys.length) {
throw new Error('FaucetError: There are no more faucets to choose from')
}
Expand Down

0 comments on commit 60996a0

Please sign in to comment.