Compare commits
No commits in common. "e0a3410f36d71a86d9e32c5e5d8e5ef10b32f7a6" and "123a79450ce41d8d9f5df7353f711c76f97e2327" have entirely different histories.
e0a3410f36
...
123a79450c
@ -6,9 +6,9 @@ import (
|
||||
"log/slog"
|
||||
"os"
|
||||
|
||||
geEvent "github.com/grassrootseconomics/eth-tracker/pkg/event"
|
||||
|
||||
"git.grassecon.net/urdt/ussd/common"
|
||||
|
||||
geEvent "github.com/grassrootseconomics/eth-tracker/pkg/event"
|
||||
)
|
||||
|
||||
// TODO: this vocabulary should be public in and provided by the eth-tracker repo
|
||||
|
@ -4,9 +4,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"strconv"
|
||||
|
||||
geEvent "github.com/grassrootseconomics/eth-tracker/pkg/event"
|
||||
|
||||
"git.defalsify.org/vise.git/db"
|
||||
"git.grassecon.net/urdt/ussd/common"
|
||||
@ -15,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
evTokenTransfer = "TOKEN_TRANSFER"
|
||||
evTransfer = "TOKEN_TRANSFER"
|
||||
// TODO: use export from urdt storage
|
||||
DATATYPE_USERSUB = 64
|
||||
)
|
||||
@ -27,8 +24,7 @@ func renderTx() {
|
||||
type eventTokenTransfer struct {
|
||||
From string
|
||||
To string
|
||||
Value int
|
||||
TxHash string
|
||||
Value string
|
||||
}
|
||||
|
||||
func updateTokenTransferList(ctx context.Context, api remote.AccountServiceInterface, store common.UserDataStore, identity lookup.Identity) error {
|
||||
@ -95,17 +91,7 @@ func updateTokenList(ctx context.Context, api remote.AccountServiceInterface, st
|
||||
// return nil
|
||||
//}
|
||||
//
|
||||
|
||||
func updateDefaultToken(ctx context.Context, store *common.UserDataStore, identity lookup.Identity, activeSym string) error {
|
||||
pfxDb := common.StoreToPrefixDb(store, []byte("vouchers"))
|
||||
tokenData, err := common.GetVoucherData(ctx, pfxDb, activeSym)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return common.UpdateVoucherData(ctx, store, identity.SessionId, tokenData)
|
||||
}
|
||||
|
||||
func updateWait(ctx context.Context, api remote.AccountServiceInterface) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -130,46 +116,18 @@ func updateToken(ctx context.Context, store *common.UserDataStore, identity look
|
||||
return err
|
||||
}
|
||||
|
||||
// err = updateTokenBalance(ctx, &api, store, sessionId)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// err = updateTokenTransferList(ctx, &api, store, sessionId)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
//
|
||||
return nil
|
||||
}
|
||||
|
||||
func asTokenTransferEvent(gev *geEvent.Event) (*eventTokenTransfer, bool) {
|
||||
var err error
|
||||
var ok bool
|
||||
var ev eventTokenTransfer
|
||||
|
||||
if gev.TxType != evTokenTransfer {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
pl := gev.Payload
|
||||
// assuming from and to are checksum addresses
|
||||
ev.From, ok = pl["from"].(string)
|
||||
if !ok {
|
||||
return nil, false
|
||||
}
|
||||
ev.To, ok = pl["to"].(string)
|
||||
if !ok {
|
||||
return nil, false
|
||||
}
|
||||
ev.TxHash, err = common.NormalizeHex(gev.TxHash)
|
||||
if err != nil {
|
||||
logg.Error("could not decode tx hash", "tx", gev.TxHash, "err", err)
|
||||
return nil, false
|
||||
}
|
||||
|
||||
value, ok := pl["value"].(string)
|
||||
if !ok {
|
||||
return nil, false
|
||||
}
|
||||
ev.Value, err = strconv.Atoi(value)
|
||||
if err != nil {
|
||||
logg.Error("could not decode value", "value", value, "err", err)
|
||||
return nil, false
|
||||
}
|
||||
return &ev, true
|
||||
}
|
||||
|
||||
func handleTokenTransfer(ctx context.Context, store *common.UserDataStore, ev *eventTokenTransfer) error {
|
||||
identity, err := lookup.IdentityFromAddress(ctx, store, ev.From)
|
||||
if err != nil {
|
||||
|
2
go.mod
2
go.mod
@ -4,7 +4,7 @@ go 1.23.2
|
||||
|
||||
require (
|
||||
git.defalsify.org/vise.git v0.2.1-0.20241031204035-b588301738ed
|
||||
git.grassecon.net/urdt/ussd v0.0.0-20241102234108-dae12ac4989e
|
||||
git.grassecon.net/urdt/ussd v0.0.0-20241102164250-3a8a5f40baa5
|
||||
github.com/grassrootseconomics/eth-tracker v1.3.0-rc
|
||||
github.com/nats-io/nats.go v1.37.0
|
||||
)
|
||||
|
4
go.sum
4
go.sum
@ -1,7 +1,7 @@
|
||||
git.defalsify.org/vise.git v0.2.1-0.20241031204035-b588301738ed h1:4TrsfbK7NKgsa7KjMPlnV/tjYTkAAXP5PWAZzUfzCdI=
|
||||
git.defalsify.org/vise.git v0.2.1-0.20241031204035-b588301738ed/go.mod h1:jyBMe1qTYUz3mmuoC9JQ/TvFeW0vTanCUcPu3H8p4Ck=
|
||||
git.grassecon.net/urdt/ussd v0.0.0-20241102234108-dae12ac4989e h1:YOEAjTrlyDRm0E63fEq8HbMp7oUCyc3vbAPOIw0xNWA=
|
||||
git.grassecon.net/urdt/ussd v0.0.0-20241102234108-dae12ac4989e/go.mod h1:ADB/wpwvI6umvYzGqpJGm/GYj8msxYGiczzWCCdXegs=
|
||||
git.grassecon.net/urdt/ussd v0.0.0-20241102164250-3a8a5f40baa5 h1:B+2YYPw8REXOuEL0PgS5Mzky253wrwWYL9mpD5CmGW4=
|
||||
git.grassecon.net/urdt/ussd v0.0.0-20241102164250-3a8a5f40baa5/go.mod h1:ADB/wpwvI6umvYzGqpJGm/GYj8msxYGiczzWCCdXegs=
|
||||
github.com/alecthomas/assert/v2 v2.2.2 h1:Z/iVC0xZfWTaFNE6bA3z07T86hd45Xe2eLt6WVy2bbk=
|
||||
github.com/alecthomas/assert/v2 v2.2.2/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ=
|
||||
github.com/alecthomas/repr v0.2.0 h1:HAzS41CIzNW5syS8Mf9UwXhNH1J9aix/BvDRf1Ml2Yk=
|
||||
|
Loading…
Reference in New Issue
Block a user