예를 들어 ethereum main net에 있는 모든 erc 1155의 transfer event를 watch한다고 하면 어떻게 해야 할까? 라는 질문에 내가 생각한 방법은

ethereum node를 운영하면서 생성되는 모든 컨트랙트를 데이터베이스에 기록한다.

새로 생성되는 contract의 경우 OwnershipTransferred 이벤트가 발생하고 여기에 

previous owner  주소가 0x0000000000000000000000000000000000000000 인경우가 새로 생성된 contract이고 이 contract가 erc 1155 를 implementing 하는지 확인하고 데이터베이스에 기록한다. 

이렇게 하면 ethereum main net에 존재하는 모든 erc 1155의 컨트랙 주소를 얻을수 있고 이들 주소의 transfer 이벤트를 watching한다면 etherum main net의 모든 erc 1155 transfer event를 트래킹할수 있다.

아마도 etherscan이나 opensea에서 이런 방법을 사용하는게 아닌가 싶다

1. https://youtu.be/9QclpA_4txI

quickswap sdk를 이용해서 midprice를 가져오는 과정이다. 기본적으로 quickswap이 uniswap을 기반으로 했기 때문에 quickswap와 uniswap은 크게 다르지 않다.

image
image
image
image
image
image
image

.

sushiswap의 sdk 사용

https://www.youtube.com/watch?v=j1FdDOrYsao

.

.

.

2. token pair contract에 접근해서 reserve양을 직접확인하고 uniswap내부에서 사용하는 가격 책정 방식을 그대로 따라 재현해서 실제 가격을 구한다.

https://youtu.be/j_wVh_Sa1rU

image
image
image

data structure playlist

https://www.youtube.com/playlist?list=PL2_aWCzGMAwI3W_JlcBbtYTwiQSsOTa6P

https://youtu.be/gXgEDyodOJU

image
image
image

tree의 경우 node가 N개 있는 경우 edge는 N-1개가 있다. 

graph는 이런 rule 이 없음

image

tree는 graph의 한 형태 이다.

image

ordered pair를 표현할때는 ( )

unordered pair를 표현할때는 { } 를 사용한다.

image
image
image
image
image
image
image

.

.

.

.

.

https://youtu.be/AfYqN3fGapc

image
image

self loop의 한 예로 한웹페이지에 있는 자기자신으로의 link를 예로 들수 있다. 링크를 클릭하면 자기자신 페이지가 리프레쉬 된다.

image
image
image
image

만약 self-loop, multiedge가 없는 경우 simple graph라고 한다.

image
image

simple graph라고 가정할때 n 개의 node는 n(n-1)의 directed edges를 가질수 있다.

image

simple graph의 경우 n개의 node는 n(n-1)/2의 edges를 가진다.

image

edges를 많이 가진 graph의 경우 dense하다고 하며

edges를 적게 가진 graph의 경우 sparse하다고 한다.

image

simple graph : self-loop , multiedges를 가지지 않는 graph

simple path : path가 반복되는 vertices(node)를 가지지 않는 path (물론 당연히 반복되는 edges 도 없게된다)

image

또 반복되는 vertices(node)를 가지지 않는 walk (물론 당연히 반복되는 edges 도 없게된다)를 흔히 path라고 하기도 한다.

image

trail의 경우 vertices(nodes)는 반복되도 되지만 edge는 반복되지 말아야 한다.

image

어느 node에서건 다른 모든 node로 갈수 있는 경우(다른 node를 거쳐서 가는것 허용됨) strongly connected graph 라고 한다.

image
image
image
image
image

https://youtu.be/v4XO_y3RErI

40분 분량 java coding with mitch

image

product는 xml안에서 사용할 변수 이름이고 보통 obj, data class obj를 담게 된다. type은 obj의 class

.

.

image

.

.

image

.

.

image

일반 함수를 사용할수 있다. (정확히 어떤 함수가 일반 함수에 해당하는지는 확인요망)

.

.

image

외부의 class를 xml내로 가져와 사용하고자 하는 경우

.

.

image

이 강의에서는 StringUtil이라는 helper class를 xml에 가져와 사용하는 것을 가정한다.

.

.

image

 xml안 변수로 사용하게될 class Product 의 내부함수를 xml에서 사용하는 것을 보여준다.

.

.

image

xml안 변수로 사용하게될 class Product 의 내부함수를 xml에서 사용하는 것을 보여준다.

.

.

image

xml내로 android view class를 import 해서 가져와 view의 속성을 변경하는 것을 보여준다.

.

.

image

클릭 이벤트 처리를 위한 interface

.

.

image

클릭이벤트를 이 강의에서는 activity가 처리한다고 가정한다.

.

.

image

클릭이벤트를 위한 interface를 implement한다.

.

.

image

클릭이벤트를 처리하는 class를 변수로 가져온다.

.

.

image

.

.

image

클릭이벤트 처리를 외부로 보낸다.

.

.

image

binding adapter를 통해 view를 외부로 보내 추가 처리를 하는 것을 보여준다. 이강의에서는 glide를 사용하는 것을 보여준다.

.

.

image

app:바인딩어댑터이름   즉 @BindingAdapter() 안에 들어간 이름

.

.

.

.

========================================================================================================================

https://medium.com/androiddevelopers/no-more-findviewbyid-457457644885

android {
   …
   dataBinding.enabled = true
}

<layout xmlns:android=“http://schemas.android.com/apk/res/android”
       xmlns:tools=“http://schemas.android.com/tools”>
   <RelativeLayout
           android:layout_width=“match_parent”
           android:layout_height=“match_parent”
           android:paddingLeft=“@dimen/activity_horizontal_margin”
           android:paddingRight=“@dimen/activity_horizontal_margin”
           android:paddingTop=“@dimen/activity_vertical_margin”
           android:paddingBottom=“@dimen/activity_vertical_margin”
           tools:context=“.MainActivity”>

       <TextView
               android:id=“@+id/hello”
               android:layout_width=“wrap_content”
               android:layout_height=“wrap_content”/>

   </RelativeLayout>
</layout>

HelloWorldBinding binding =
   DataBindingUtil.setContentView(this, R.layout.hello_world);
binding.hello.setText(“Hello World”); // you should use resources!

.

.

https://medium.com/androiddevelopers/android-data-binding-that-include-thing-1c8791dd6038

hello_world.xml<layout xmlns:android="http://schemas.android.com/apk/res/android">
   <LinearLayout
           android:layout_width="match_parent"
           android:layout_height="match_parent"
           android:orientation="vertical">

       <TextView
               android:id="@+id/hello"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"/>
       <include
               android:id="@+id/included"
               layout="@layout/included_layout"/>
   </LinearLayout>
</layout>
included_layout.xml<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
   <TextView
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:id="@+id/world"/>
</layout>
HelloWorldBinding binding =
   HelloWorldBinding.inflate(getLayoutInflater());
binding.hello.setText(“Hello”);
binding.included.world.setText(“World”);

.

.

https://medium.com/google-developers/android-data-binding-adding-some-variability-1fe001b3abcc

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
   <data>
       <variable
           name="user"
           type="com.example.myapp.model.User"/>
   </data>
   <LinearLayout
           android:orientation="vertical"
           android:layout_width="match_parent"
           android:layout_height="match_parent">
       <ImageView
               android:src="@{user.image}"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"/>
       <TextView
               android:text="@{user.firstName}"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"/>

       <TextView
               android:text="@{user.lastName}"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"/>
   </LinearLayout>
</layout>

You can see in the layout above that the Views no longer have IDs. (above)


private void setUser(User user, ViewGroup root) {
   UserInfoBinding binding =
       UserInfoBinding.inflate(getLayoutInflater(), root, true);
   binding.setUser(user);
}

——————————————————————————————-


user_name.xml
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
   <data>
       <variable
               name="user"
               type="com.example.myapp.model.User"/>
   </data>

   <LinearLayout
           android:layout_width="match_parent"
           android:layout_height="match_parent"
           android:orientation="horizontal">
       <TextView
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:text="@{user.firstName}"/>

       <TextView
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:text="@{user.lastName}"/>
   </LinearLayout>
</layout>

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
       xmlns:app="http://schemas.android.com/apk/res-auto">
   <data>
       <variable
               name="user"
               type="com.example.myapp.model.User"/>
   </data>
   <LinearLayout
           android:layout_width="match_parent"
           android:layout_height="match_parent"
           android:orientation="vertical">
       <ImageView
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:src="@{user.image}"/>
       <include
               layout="@layout/user_name"
               app:user="@{user}"/>
   </LinearLayout>
</layout>

.

.

https://medium.com/androiddevelopers/android-data-binding-express-yourself-c931d1f90dfe

The expression parser automatically tries to find the Java Bean accessor name (getXxx() or isXxx()) for your property. The same expression will work fine when your class has accessor methods. (기본적으로 xml에 @{a.bbb}가 있다고 한다면 parser가 알아서 a 클래스에서 getbbb()를 찾고 없다면 bbb()를 사용한다는 이야기 이다.)

If it can’t find a method named like getXxx(), it will also look for a method named xxx(), so you can use user.hasFriend to access method hasFriend().

Android Data Binding expression syntax also supports array access using brackets, just like Java:

android:text="@{user.friends[0].firstName}"

It also allows almost all java language expressions, including method calls, ternary operators, and math operations.

there is a null-coalescing operator ?? to shorten the simple ternary expressions:(즉 ?? 사용가능하다는 이야기)

android:text=”@{user.firstName ?? user.userName}”

which is essentially the same as:

android:text=”@{user.firstName != null ? user.firstName : user.userName}”

One really cool thing you can do with binding expressions is use resources:

android:padding=”@{@dim/textPadding + @dim/headerPadding}

You can also use string, quantity, and fraction formatting following the syntax from Resources methods getString, getQuantityString, and getFraction. You just pass the parameters as arguments to the resource:

android:text=”@{@string/nameFormat(user.firstName, user.lastName)}”

One very convenient thing is that data binding expressions always check for null values during evaluation. That means that if you have an expression like:

android:text=”@{user.firstName ?? user.userName}”

If user is null, user.firstName and user.userName will evaluate to null and the text will be set to null. No NullPointerException.

This doesn’t mean that it is impossible to get a NullPointerException. If, for example, you have an expression:

android:text=”@{com.example.StringUtils.capitalize(user.firstName)}”

And your StringUtils had:

public static String capitalize(String str) {
   return Character.toUpperCase(str.charAt(0)) + str.substring(1);
}

You’ll definitely see a NullPointerException when a null is passed to capitalize.

Importing

In the example above, the expression to capitalize the name was very long. What we really want is to be able to import types so that they can be used as a shortened expression. You can do that by importing them in the data section:

<data>
   <variable
       name="user"
       type="com.example.myapp.model.User"/>
   <import
       type="com.example.StringUtils"/>
</data>

Now our expression can be simplified to:

android:text=”@{StringUtils.capitalize(user.firstName)}”

(본래는 android:text=”@{com.example.StringUtils.capitalize(user.firstName)}” 이렇게 쓸것을 줄인결과)

Expressions are pretty much Java syntax with the few exceptions mentioned above. If you think it will work, it probably will, so just give it a go.

.

.

https://medium.com/androiddevelopers/android-data-binding-the-big-event-2697089dd0d7

data binding에서 listener를 view에 덧붙이는 방법은 아래와 같이3가지가 있다. 

1. Listener Objects

<View android:onClickListener="@{callbacks.clickListener}" .../>

간단하게 줄여서 아래와 같이 할수도 있다.

<View android:onClick="@{listeners.clickListener}" .../>
public class Callbacks {
   public View.OnClickListener clickListener;
}

2. Method References


<EditText
   android:afterTextChanged="@{callbacks::nameChanged}" .../>

public class Callbacks {
   public void nameChanged(Editable editable) {
       //...
   }
}

아래와 같이 논리구조를 추가해서 상황에 따라 다른 리스너를 이용할수도 있다.

<EditText android:afterTextChanged=
   "@{user.hasName?callbacks::nameChanged:callbacks::idChanged}"
   .../>

3. Lambda Expressions

https://developer.android.com/reference/android/text/TextWatcher#afterTextChanged(android.text.Editable)

본래 afterTextChanged는 Editable 를 parameter로 받는다. 아래서 e는 Editable이다.

<EditText
android:afterTextChanged="@{(e)->callbacks.textChanged(user, e)}"
... />
public class Callbacks {
public void textChanged(User user, Editable editable) {
if (user.hasName()) {
//...
} else {
//...
}
}
}

.

.

https://medium.com/androiddevelopers/android-data-binding-lets-flip-this-thing-dc17792d6c24

@={}


<EditText
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="@={user.firstName}"/>

아래에서는 xml에 있는 다른 view의 id를 이용 접근하는 것을 보여주고 있다.

<CheckBox
   android:id="@+id/showName"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"/> <TextView
   android:text="@{user.firstName}"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:visibility="@{showName.checked ? View.VISIBLE : View.GONE}"
   />


<CheckBox
   android:id="@+id/showName"
   android:focusableInTouchMode="@{model.allowFocusInTouchMode}"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"/> <TextView
   android:text="@{user.firstName}"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:focusableInTouchMode="@{showName.focusableInTouchMode}"
   />

<EditText
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:id="@+id/firstName"
   android:text="@={user.firstName}" /> <CheckBox
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:onCheckedChanged="@{()->handler.checked(firstName)}" />