Bon j’ai fait une MR: add French mnemonic file by poka-IT · Pull Request #1689 · polkadot-js/common · GitHub
J’ai ajouté le fichier bip39 french au format exact qu’ils attendent, et ajouté l’import:
J’ai pas trouvé de branche dev donc j’ai MR sur master, ils me diront…
Si quelqu’un veut continuer à rendre cette lib multilang c’est avec plaisir, j’suis pas js à la base et j’ai pas mal de truc sur le feux ^^
En cado mon script python pour convertir la list bip39 aux format attendu par polkadotjs:
#!/usr/bin/env python3
import json
from urllib.request import urlopen
# utility
def load_json(data):
get_data = open(data)
return json.load(get_data)
# convert
mnemo_final = ''
mnemo_brut = load_json('french.json')
i=0
lenght=len(mnemo_brut)
for word in mnemo_brut:
if (i == lenght-1):
mnemo_final = mnemo_final + word
else:
mnemo_final = mnemo_final + word + '|'
i=i+1
FINAL_DOC = '''// Adapted from the bitcoinjs/bip39 source
// https://github.com/bitcoinjs/bip39/blob/1d063b6a6aee4145b34d701037cd3e67f5446ff9/ts_src/
export default '%s'.split('|');
''' % (mnemo_final)
print(FINAL_DOC)
# dump file
doc_file = open('bip39-fr.ts', "w")
doc_file.write(FINAL_DOC)
Bon je sais très bien que ça va pas être aussi simple de rendre la lib multlang mais faut bien commencer quoi
This will actually not get used as coded in this PR. The reasons being -
- The WASM bip39 execution path is the one that gets executed in 99.9% of the cases (JS is only used as a fallback when WASM is not available in the environment)
- The actual JS code here only used the
DEFAULT_WORDLIST
import (I believe CI will actually complain about the unused import here)So basically with this is won’t do anything. There is a way to do multiple languages, but it won’t be simple.
- The WASM environment needs to take a wordlist as input (the bonus is that this reduces bundle size, i.e. currently both the WASM and JS environment has a copy)
- Execution needs to use this list
- The same logic for specification should happen in the JS environment (it could be as simple as
setWordlist(...)
before execution happens)Overall, since each list adds to the bundle sizes (which is a huge ongoing problem), it will therefore need to be up to the developer using it to specify, instead of “having all available always”.
Faut les scouer un peu là
J’ai envie de créer un fork de polkadotjs-common et de le rendre juste French uniquement lol
Le temps qu’ils rendent la lib multilang.
Comme ça Ğecko mobile beta proposera des mnemonic Français uniquement.
Bon ça doit pas être si simple faut toucher à certains trucs dont j’ai aucune idée…