my wallet address is whitelisted. how i will get merkle proof for minting? - linux-mint

const leaves = whitelistAddresses.map(addr => padBuffer(addr))
const merkletree = new MerkleTree(leaves, keccak256, {sortPairs: true})
console.log('merkletree', merkletree.toString())
const rootHash = merkletree.getHexRoot()
console.log("root hash", rootHash)
I don't have whitelistAddresses...
I have only contractAddress, WalletAddress, roothash. is it posible to get merkleproof without knowing full whitelistAddresses array. or is any other way to get merkle proof without ask anybody?
I want to get merkle proof (bytes32 [])

Related

Google Contacts Fields to fill variables in email template

First of all, thank you for your time.
I have been looking for a while for a program, a script or anything that could help me automate a task that otherwise is going to take very long.
See, i'm a french computer technician working for almost exclusively doctors here in France.
The doctors receive results by email, the results are then imported to the patient's folder from the email automatically.
But in order for them to receive that information we have to communicate an email address from a special domain + the doctor's ID that is like your driver's ID.
We use google contact as an address book because it's convenient. Since whenever we make a new maintenance contract with a doctor we input everything to google contact the info is already there. Sometimes we have up to 20 doctors in the same cabinet to set.
Link to a Google Sheet Contact Sample
The fields are the following :
Structure's Name : {{contact company name}} (all the doctors share the same structure)
Strutre's Adress : {{contact full address}} (all the doctors share the same structure)
First doctor
Last Name : {{last_name}}
First Name : {{first_name}}
eMail Address : {{email_address}} (this one is tagged MSSANTE in ggC)
Doc's ID : {{custom_field}} (this is a custom field tagged RPPS in ggC)
Second doctor
Last Name : {{last_name}}
First Name : {{first_name}}
eMail Address : {{email_address}} (this one is tagged MSSANTE in ggC)
Doc's ID : {{custom_field}} (this is a custom field tagged RPPS in ggC)
So on and so on.
Then this as to be sent to many laboratories all in BCC and the customers/doctors usually in CC
I was thinking of using google sheets or google's people API somehow...
Can someone give me a strategy or some code to start ?
Again thanks to anyone who can help even a bit.
Try
function email() {
const ss = SpreadsheetApp.getActiveSpreadsheet()
const emails = ss.getSheetByName('LABS mails').getRange('C2:C').getValues().flat().filter(r => r != '').join(',')
MailApp.sendEmail({
to: emails,
subject: 'titre du mail',
htmlBody: body()
})
}
function body() {
const ss = SpreadsheetApp.getActiveSpreadsheet()
const template = ss.getSheetByName('Mail Template (Exemple)')
const docteurs = ss.getSheetByName('Doctors')
let [headers, ...data] = docteurs.getDataRange().getDisplayValues()
let debut = template.getRange('A2:A').getValues().flat().filter(r => r != '').join('<br>')
let variable = template.getRange('B2:B').getValues().flat().filter(r => r != '').join('<br>')
let fin = template.getRange('C2:C').getValues().flat().filter(r => r != '').join('<br>')
const liste = ['{CABINET}', '{NOM}', '{PRENOM}', '{EMAIL}', '{RPPS}']
const colonnes = [1,4,3,8,7]
let message = debut
data.forEach((r, row) => {
var texte = variable
for (var i = 0; i < liste.length; i++) {
texte = texte.replace(liste[i], r[+colonnes[i] - 1])
}
message += texte + '<br><br>'
})
message += fin
return (message)
}
Put the text as follows (you will need a little html tags)
The email will be

Google Form Get Last responses

I can't understand why Google Form is returning me not the last responses, but the penultimate one after I run an OnSubmit script. Let me explain better, I intend to intercept the user's responses and when sending the form to propose a link pre-filled with his last answers given that he can modify and postpone.
function getLastFormResponse(form = FormApp.getActiveForm()) {
form.getResponses()
.pop()
.getItemResponses()
.forEach((itemResponse) => {
this[itemResponse.getItem().getTitle()] = itemResponse.getResponse();
}
);
}
const formResponse = new getLastFormResponse();
const name = formResponse['NAME'];
Logger.log(name);
const surname = formResponse['SURNAME'];
Logger.log(surname);
const age = formResponse['AGE'];
Logger.log(age);
const reserved_room = formResponse['RESERVED_ROOM'];
Logger.log(reservedRoom);
var constructionLink = ('https://docs.google.com/forms/d/e/1FAIpQLScgu1FWB6-tQjpviyr9_dZetd2SKdqZZmsL_Imp30nWYqsq7g/viewform?usp=pp_url&entry.81904614='+name+'&entry.1534059913='+surname+'&entry.181893772='+age+'&entry.772338055='+reservedRoom);
Logger.log(constructionLink);
Logger.log(JSON.stringify(formResponse,null,2));
form = FormApp.getActiveForm();
form.setConfirmationMessage('Thanks for your feedback !!'+ constructionLink )
So, when the user press Submit button, a link comes out pre-filled with the "latest" information present... but, in reality, not the last (before the submit) but the penultimate ones are taken from corresponding spreadsheet ...
I would like to get the latest that he filled out.

How to assert whether a text is present in table

I am new to protractor and want to assert whether a newly added row contains the text which i have added.
Also i want to assert whether the particular text belongs to the header section.
I have tried to some extent but my code is failing.
Below is my code
var row=element.all(by.repeater('dataRow in displayedCollection'));
var col=row.all(by.tagName('td'));
col.each(function(item)
{
item.getText().then(function(text)
{
})
})
})
Below is the HTML code
Below is UI
Sergey is correct, this would be much easier using async/await but using your example here is how I would do it.
Assuming that the newly added row is always the last row in the table you can probably do it something like this:
const rows = element.all(by.repeater('dataRow in displayedCollection'));
const relevantRow = rows.last();
relevantRow.getText().then(test => {
expect(text).toContain(mySampletext);
});
If the new row is not always the last one, then the way to find it would be different. For example, if every time you added a row the table was sorted alphabetically, then you would need to filter the list of rows to find the one you are looking for, and then check that the text matches what you expect it to be.
You don't really need to get each td element unless you want to verify that the text in each column is correct. In that case you would probably do it similar to this:
const expectedText = ['someText', 'in order', 'by', 'columns'];
const rows = element.all(by.repeater('dataRow in displayedCollection'));
const relevantRow = rows.last();
const columns = relevantRow.$$('td');
let coumnTextMatches = true;
columns.each((col, index) => {
col.getText().then(text => {
columntextMatches = expectedText[index] === text;
});
});
expect(columntextMatches).toEqual(true);
This may or may not be completely accurate. I just did it off the top of my head without testing it out but it should be pretty close to something like that.
For the headers it would be similar.
get all the header elements
iterate over each one and check that the text matches what you expect

How to check elements are rendered with a specific sorting with react-testing-library?

With its user-centric approach, my understanding of RTL is that testing sorting of elements should look something like.
const foo = queryByText('foo');
const bar = queryByText('bar');
expect(foo).toBeInTheDocument();
expect(bar).toBeInTheDocument();
expect(foo).toShowBefore(bar); // THIS IS MY PSEUDOCODE
However, I couldn't find a .toShowBefore() or equivalent function in RTL.
What's the correct way to test that content is displayed in a certain order?
I don't believe React Testing Library has an idiomatic way to do this. But if you can parse your DOM, then you should be able to get the textContent of various Elements and assert on that.
const select = screen.getByTestId('select');
const children = select.children;
expect(children.item(0)?.textContent).toEqual('Interface A');
expect(children.item(1)?.textContent).toEqual('Interface B');
expect(children.item(2)?.textContent).toEqual('Interface C');
You can use compareDocumentPosition.
For example
const e1 = getByText('a');
const e2 = getByText('b');
expect(e1.compareDocumentPosition(e2)).toBe(2);
Here getByText is returned from the render function.
You could give each row a test id:
<tr data-testid='row'>...</tr>
and then expect the rows to be in order:
const rows = screen.getAllByTestId('row')
expect(within(rows[0]).queryByText('A')).toBeInTheDocument()
expect(within(rows[1]).queryByText('B')).toBeInTheDocument()
expect(within(rows[2]).queryByText('C')).toBeInTheDocument()

Dynamically formed http request

I need to send get request like this to my api:
http://test.example.com/api/activity/search?word={word}&age={age}&free={free}
and then show this activities in my page with *ngFor, but when user fill inputs, i need to dynamically insert values in unnecessary arguments of this.
What i already done:
//activity.service.ts :
searchActivities(word?: any, age?: any, free?: any) {
let w, a, f;
//contat values from forms here
w = word ? `word=${word}` : '';
a = age ? `age=${age}` : '';
f = free ? `free=${free}` : '';
return this.http.get(`http://test.example.com/api/activity/search?${w}${a}${f}`);
}
as you noticed, i miss ampersands here, and it works only with one input, for example when user wants to see all free football activities, he can't.
In my component i have this:
activities = [];
args: any[] = [null, null, null]; //array for values
//funtction attached to input's events
setArgument(index, value) {
this.args[index] = value; //fills array with values from inputs
this.activityService
// spread operator gives error in typescript for some reason, so i decided to put arguments this way
.searchActivities(this.args[0], this.args[1], this.args[2])
.subscribe((data: Response) => this.activities = data.json());
}
example of inputs:
<md-checkbox (click)="setArgument(5, !IsFree)" [(ngModel)]="IsFree" name="free">Free</md-checkbox>
<md-input-container>
<input (focusout)="setArgument(0, word)" [(ngModel)]="word" name="word" mdInput placeholder="Search word">
</md-input-container>
I hope you understood what i'm trying to do, i'm novice at programming and maybe i do it completely bad way. Please advice how can i deal with ampersands, and maybe simplify or rewrite this code somehow
A good solution to your ampersand problem would be Array.prototype.join
So you might add code similar to the following:
w = word ? `word=${word}` : '';
a = age ? `age=${age}` : '';
f = free ? `free=${free}` : '';
q = [w, a, f].filter(function(x) { return x !== '' }).join('&');
return this.http.get(`http://test.example.com/api/activity/search?${q}`);
So you create an array containing all of your query strings, filter out the ones that are empty, and the join together into a string separated with ampersand characters.