Skip to content

Commit

Permalink
⛓️ Ağ adlarını veri şekline çevir
Browse files Browse the repository at this point in the history
  • Loading branch information
KimlikDAO-bot committed Jan 22, 2024
1 parent 3400cc5 commit 3ceb829
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 47 deletions.
3 changes: 2 additions & 1 deletion al/imeceİptal/birim.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Cüzdan from "/birim/cüzdan/birim";
import TCKT from "/lib/ethereum/TCKT";
import evm from "/lib/ethereum/evm";
import dom from "/lib/util/dom";
import {ChainId} from "/lib/crosschain/chainId";

/** @const {Element} */
const GösterButonu = dom.adla("imbe");
Expand All @@ -16,7 +17,7 @@ const İptalButonu = dom.adla("imbh");
const İptalciler = dom.adla("imf");

/**
* @param {string} ağ Native tokeninde TCKT fiyatının gösterileceği ağ.
* @param {ChainId} ağ Native tokeninde TCKT fiyatının gösterileceği ağ.
*/
const fiyatGöster = () => {
/**
Expand Down
18 changes: 12 additions & 6 deletions al/ödeme/birim.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import Telefon from "/birim/telefon/birim";
import TCKT from "/lib/ethereum/TCKT";
import { whenMined } from "/lib/ethereum/transaction";
import dom from "/lib/util/dom";
import {ChainId} from "/lib/crosschain/chainId";

/** @const {!Element} */
const Kök = /** @const {!Element} */(dom.adla("od"));

/**
* @param {Element} imge
Expand Down Expand Up @@ -44,7 +48,7 @@ const paraVeMiktar = (para, miktar) => {
return (para == 3 ? "₺" : "$") + miktarMetni;

/**
* @type {AğBilgisi}
* @type {!AğBilgisi}
* @const
*/
const ağBilgisi = AğBilgileri[Cüzdan.()];
Expand All @@ -70,7 +74,9 @@ const öde = (cidSözü, adresAğırlığı, eşik) => {
/** @type {number} */
let para = 0;

/** @const {function(string)} */
/**
* @param {ChainId} yeniAğ
*/
const ağDeğişti = (yeniAğ) => {
/** @const {Element} */
const li = dom.adla("odd" + yeniAğ);
Expand Down Expand Up @@ -120,7 +126,7 @@ const öde = (cidSözü, adresAğırlığı, eşik) => {
// Eğer 'native token'da ödemiyorsak, ağ ücretini ayrıca göster
toplamKutusu.lastElementChild.style.display = para == 0 ? "none" : "inline-block";

/** @const {string} */
/** @const {ChainId} */
const = Cüzdan.();
/** @const {string} */
const adres = /** @type {string} */(Cüzdan.adres());
Expand Down Expand Up @@ -175,9 +181,9 @@ const öde = (cidSözü, adresAğırlığı, eşik) => {
const birazBekle = (cevap) => new Promise(
(/** @type {function(T):void} */ resolve) => setTimeout(() => resolve(cevap), 100))

dom.adla("od").classList.remove("disabled");
Kök.classList.remove("disabled");
dom.adla("oda").onclick = () => {
/** @const {string} */
/** @const {ChainId} */
const = Cüzdan.();
/** @const {!eth.Provider} */
const provider = /** @type {!eth.Provider} */(Cüzdan.bağlantı().provider);
Expand Down Expand Up @@ -215,4 +221,4 @@ const öde = (cidSözü, adresAğırlığı, eşik) => {
};
}

export { öde };
export { öde, Kök };
3 changes: 1 addition & 2 deletions ana/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ build/ana/sayfa-%.js: ana/sayfa.js \
birim/kaydol/*.js \
birim/telefon/birim.js \
birim/tckt/birim.js \
lib/crosschain/unlockable.d.js \
lib/crosschain/provider.js lib/crosschain/signer.js \
lib/crosschain/*.js \
lib/did/*.d.js \
lib/ethereum/*.d.js \
lib/ethereum/provider.js lib/ethereum/TCKTLite.js \
Expand Down
6 changes: 4 additions & 2 deletions birim/ağlar/birim.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import dom from "/lib/util/dom";
import { ChainId } from "/lib/crosschain/chainId";

/**
* @interface
Expand All @@ -25,8 +26,9 @@ AğBilgisi.prototype.tokenEki;
AğBilgisi.prototype.rpcUrl;

/**
* @const {!Object<string, !AğBilgisi>}
*/
* @const
* @type {!Object<ChainId, !AğBilgisi>}
*/
const AğBilgileri = {
"0x1": {
ad: "Ethereum",
Expand Down
27 changes: 14 additions & 13 deletions birim/cüzdan/birim.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { CoreBağlantısı, MetaMaskBağlantısı, RabbyBağlantısı } from "./evmBağlantısı";
import { AğBilgileri } from "/birim/ağlar/birim";
import { ChainId } from "/lib/crosschain/chainId";
import { Provider } from "/lib/crosschain/provider";
import TCKT from "/lib/ethereum/TCKTLite";
import ipfs from "/lib/node/ipfs";
Expand Down Expand Up @@ -32,8 +33,8 @@ const BoşBağlantı = /** @type {!Provider} */({
/**
* @override
*
* @param {string} chain
* @param {function(string)} chainChanged
* @param {ChainId} chain
* @param {function(ChainId)} chainChanged
* @param {function(!Array<string>)} addressChanged
* @param {boolean=} onlyIfApproved
* @return {!Promise<void>}
Expand All @@ -49,7 +50,7 @@ const BoşBağlantı = /** @type {!Provider} */({
/**
* @override
*
* @param {string} ağ
* @param {ChainId} ağ
* @return {!Promise<void>}
*/
switchChain() {
Expand Down Expand Up @@ -86,7 +87,7 @@ const Menü = dom.adla("cub");
const AdresDeğişince = [];
/** @const {!Array<function()>} */
const Kopunca = [];
/** @const {!Array<function(string)>} */
/** @const {!Array<function(ChainId)>} */
const AğDeğişince = [];
/** @const {!Array<function(?string, Promise<!eth.ERC721Unlockable>)>} */
const TcktDeğişince = [];
Expand All @@ -96,15 +97,15 @@ const BağlantıDeğişince = [];
let Bağlı = BoşBağlantı;
/** @type {?string} */
let Adres = null;
/** @type {string} */
let = "0xa4b1";
/** @type {ChainId} */
let = /** @type {ChainId} */(VARSAYILAN_AĞ);
/** @type {?string} */
let BağlaMetni;
/** @type {?string} */
let TcktYokResmi;

/**
* @return {string} Seçili ağ
* @return {ChainId} Seçili ağ
*/
const = () => ;

Expand Down Expand Up @@ -137,7 +138,7 @@ const hızlıArabirimAdı = (adres) => adres.slice(0, 6) + "..." + adres.slice(-
const nihaiArabirimAdı = (hesap) => new Promise((_) => null);

/**
* @param {string} yeniAğ harf dizisi olarak yeni ağ adı.
* @param {ChainId} yeniAğ harf dizisi olarak yeni ağ adı.
*/
const ağDeğişti = (yeniAğ) => {
if (!(yeniAğ in AğBilgileri)) {
Expand All @@ -163,7 +164,7 @@ const tcktDeğişti = () => {
/** @const {Element} */
const tcktResmi = dom.adla("cutc");

/** @const {string} */
/** @const {ChainId} */
const = ;
/** @const {!eth.Provider} */
const provider = /** @type {!eth.Provider} */(Bağlı.provider);
Expand Down Expand Up @@ -229,7 +230,7 @@ const adresDeğişti = (adresler) => {
}

/**
* @param {function(string)} f Ağ değişince yeni ağın adıyla çağırılacak
* @param {function(ChainId)} f Ağ değişince yeni ağın adıyla çağırılacak
* fonksiyon.
*/
const ağDeğişince = (f) => AğDeğişince.push(f);
Expand Down Expand Up @@ -260,7 +261,7 @@ const tcktDeğişince = (f) => {
const bağlantıDeğişince = (f) => BağlantıDeğişince.push(f);

/**
* @param {string} ağ
* @param {ChainId} ağ
*/
const ağSeçildi = () => Bağlı.switchChain()

Expand Down Expand Up @@ -355,8 +356,8 @@ const kur = () => {
let li = event.target;
for (; li.nodeName != 'LI'; li = li.parentElement)
if (li.nodeName == 'BODY') return;
/** @const {string} */
const = li.id.slice(3);
/** @const {ChainId} */
const = /** @type {ChainId} */(li.id.slice(3));
ağSeçildi();
}

Expand Down
25 changes: 13 additions & 12 deletions birim/cüzdan/evmBağlantısı.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { AğBilgileri, AğBilgisi } from "/birim/ağlar/birim";
import { ChainId } from "/lib/crosschain/chainId";
import { Provider } from "/lib/crosschain/provider";
import { hex } from "/lib/util/çevir";

/**
* @param {!eth.Provider} provider
* @param {string} ağ
* @param {ChainId} ağ
* @return {!Promise<void>}
*/
const ağSeç = (provider, ) => provider.request(/** @type {!eth.Request} */({
Expand Down Expand Up @@ -42,8 +43,8 @@ const kopar = (provider) => provider.removeAllListeners();

/**
* @param {!eth.UiProvider} provider
* @param {string} ağ
* @param {function(string)} ağDeğişti
* @param {ChainId} ağ
* @param {function(ChainId)} ağDeğişti
* @param {function(!Array<string>)} adresDeğişti
* @param {boolean=} izinliyse
* @return {!Promise<void>}
Expand Down Expand Up @@ -120,8 +121,8 @@ const CoreBağlantısı = /** @type {!Provider} */({
/**
* @override
*
* @param {string} chain
* @param {function(string)} chainChanged
* @param {ChainId} chain
* @param {function(ChainId)} chainChanged
* @param {function(!Array<string>)} addressChanged
* @param {boolean=} onlyIfApproved
* @return {!Promise<void>}
Expand All @@ -137,7 +138,7 @@ const CoreBağlantısı = /** @type {!Provider} */({
/**
* @override
*
* @param {string} chain
* @param {ChainId} chain
*/
switchChain: (chain) => ağSeç(CoreBağlantısı.provider, chain),

Expand Down Expand Up @@ -173,8 +174,8 @@ const MetaMaskBağlantısı = /** @type {!Provider} */({
/**
* @override
*
* @param {string} chain
* @param {function(string)} chainChanged
* @param {ChainId} chain
* @param {function(ChainId)} chainChanged
* @param {function(!Array<string>)} addressChanged
* @param {boolean=} onlyIfApproved
* @return {!Promise<void>}
Expand All @@ -190,7 +191,7 @@ const MetaMaskBağlantısı = /** @type {!Provider} */({
/**
* @override
*
* @param {string} chain
* @param {ChainId} chain
*/
switchChain: (chain) => ağSeç(MetaMaskBağlantısı.provider, chain),

Expand Down Expand Up @@ -235,8 +236,8 @@ const RabbyBağlantısı = /** @type {!Provider} */({
/**
* @override
*
* @param {string} chain
* @param {function(string)} chainChanged
* @param {ChainId} chain
* @param {function(ChainId)} chainChanged
* @param {function(!Array<string>)} addressChanged
* @param {boolean=} onlyIfApproved
* @return {!Promise<void>}
Expand All @@ -252,7 +253,7 @@ const RabbyBağlantısı = /** @type {!Provider} */({
/**
* @override
*
* @param {string} chain
* @param {ChainId} chain
*/
switchChain: (chain) => ağSeç(RabbyBağlantısı.provider, chain),

Expand Down
3 changes: 1 addition & 2 deletions iptal/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ build/iptal/sayfa-%.js: iptal/sayfa.js \
birim/ağlar/*.js \
birim/cüzdan/*.js \
birim/dil/birim.js \
lib/crosschain/unlockable.d.js \
lib/crosschain/provider.js lib/crosschain/signer.js \
lib/crosschain/*.js \
lib/crypto/sha3.js \
lib/crypto/secp256k1.js lib/crypto/modular.js \
lib/ethereum/*.d.js \
Expand Down
2 changes: 1 addition & 1 deletion lib
3 changes: 1 addition & 2 deletions oyla/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ build/oyla/sayfa-%.js: oyla/sayfa.js \
birim/ağlar/*.js \
birim/cüzdan/*.js \
birim/dil/birim.js \
lib/crosschain/unlockable.d.js \
lib/crosschain/provider.js lib/crosschain/signer.js \
lib/crosschain/*.js \
lib/crypto/sha3.js \
lib/crypto/secp256k1.js lib/crypto/modular.js \
lib/ethereum/*.d.js \
Expand Down
5 changes: 3 additions & 2 deletions oyla/sayfa.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import "/birim/dil/birim";
import { Provider } from "/lib/crosschain/provider";
import TCKT from "/lib/ethereum/TCKT";
import dom from "/lib/util/dom";
import {ChainId } from "/lib/crosschain/chainId";

let SeçilmişÖneriId;

Expand All @@ -31,7 +32,7 @@ dom.adla("oyyb").onclick = () => {
}

/**
* @param {string} yeniAğ Ağ değişince UI'da gösterir
* @param {ChainId} yeniAğ Ağ değişince UI'da gösterir
*/
const fiyatDeğişikliğiFormuHazırla = (yeniAğ) => {
/** @const {Element} */
Expand Down Expand Up @@ -152,7 +153,7 @@ const toplulukÖnergesiHazırla = () => {
/**
* @param {{
* title: string,
* chain: string,
* chain: ChainId,
* address: string,
* calldata: string,
* remainingTime: number,
Expand Down
11 changes: 7 additions & 4 deletions tcktm/pencere/birim.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Cüzdan from "/birim/cüzdan/birim";
import TCKT from "/lib/ethereum/TCKT";
import evm from "/lib/ethereum/evm";
import dom from "/lib/util/dom";
import { ChainId } from "/lib/crosschain/chainId";

/** @const {!Element} */
const Mask = /** @const {!Element} */(dom.adla("inbd"));
Expand Down Expand Up @@ -44,14 +45,16 @@ const imeceİptalKutusuGöster = () => {
dom.adla("iniio").onclick = () => {
const weight = +agirlikGirdisi.value;
address = evm.adresDüzelt(adresGirdisi.value).slice(2).toLowerCase();
TCKT.addRevoker(
Cüzdan.(),
TCKT.addRevoker(Cüzdan.(),
/** @type {string} */(Cüzdan.adres()), weight, address);
}
}

const eşikKutusuGöster = () => {
/** @const {string} */
/**
* @const
* @type {ChainId}
*/
const = Cüzdan.();
/** @const {string} */
const adres = /** @type {string} */(Cüzdan.adres());
Expand Down Expand Up @@ -86,7 +89,7 @@ const silKutusuGöster = (iptelEdince) => {
dom.göster(SilKutusu);
dom.adla("insyr").onclick = kutuKapat;
dom.adla("insyo").onclick = () => {
/** @const {string} */
/** @const {ChainId} */
const = Cüzdan.();
/** @const {string} */
const adres = /** @type {string} */(Cüzdan.adres());
Expand Down

0 comments on commit 3ceb829

Please sign in to comment.