Add fetchtransactions part of token event handle
This commit is contained in:
parent
d3d42ec6a2
commit
123a79450c
@ -2,6 +2,8 @@ package event
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"git.defalsify.org/vise.git/db"
|
"git.defalsify.org/vise.git/db"
|
||||||
"git.grassecon.net/urdt/ussd/common"
|
"git.grassecon.net/urdt/ussd/common"
|
||||||
@ -15,15 +17,31 @@ const (
|
|||||||
DATATYPE_USERSUB = 64
|
DATATYPE_USERSUB = 64
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func renderTx() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
type eventTokenTransfer struct {
|
type eventTokenTransfer struct {
|
||||||
From string
|
From string
|
||||||
To string
|
To string
|
||||||
Value string
|
Value string
|
||||||
}
|
}
|
||||||
|
|
||||||
//func updateTokenTransferList(ctx context.Context, api remote.AccountServiceInterface, store common.UserDataStore, sessionId string) error {
|
func updateTokenTransferList(ctx context.Context, api remote.AccountServiceInterface, store common.UserDataStore, identity lookup.Identity) error {
|
||||||
// return nil
|
var r []string
|
||||||
//}
|
|
||||||
|
txs, err := api.FetchTransactions(ctx, identity.ChecksumAddress)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, tx := range(txs) {
|
||||||
|
r = append(r, fmt.Sprintf("%d %s %s", i, tx.DateBlock, tx.TxHash[:10]))
|
||||||
|
}
|
||||||
|
|
||||||
|
s := strings.Join(r, "\n")
|
||||||
|
return store.WriteEntry(ctx, identity.SessionId, common.DATA_TRANSACTIONS, []byte(s))
|
||||||
|
}
|
||||||
|
|
||||||
func updateTokenList(ctx context.Context, api remote.AccountServiceInterface, store *common.UserDataStore, identity lookup.Identity) error {
|
func updateTokenList(ctx context.Context, api remote.AccountServiceInterface, store *common.UserDataStore, identity lookup.Identity) error {
|
||||||
holdings, err := api.FetchVouchers(ctx, identity.ChecksumAddress)
|
holdings, err := api.FetchVouchers(ctx, identity.ChecksumAddress)
|
||||||
@ -73,9 +91,9 @@ func updateTokenList(ctx context.Context, api remote.AccountServiceInterface, st
|
|||||||
// return nil
|
// return nil
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//func updateDefaultToken(ctx context.Context, store common.UserDataStore, sessionId string, activeSym string) {
|
func updateDefaultToken(ctx context.Context, store *common.UserDataStore, identity lookup.Identity, activeSym string) error {
|
||||||
//
|
return nil
|
||||||
//}
|
}
|
||||||
|
|
||||||
func updateToken(ctx context.Context, store *common.UserDataStore, identity lookup.Identity) error {
|
func updateToken(ctx context.Context, store *common.UserDataStore, identity lookup.Identity) error {
|
||||||
var api remote.AccountService
|
var api remote.AccountService
|
||||||
@ -85,18 +103,19 @@ func updateToken(ctx context.Context, store *common.UserDataStore, identity look
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// activeSym, err := store.ReadEntry(common.DATA_ACTIVE_ADDRESS)
|
activeSym, err := store.ReadEntry(ctx, identity.SessionId, common.DATA_ACTIVE_ADDRESS)
|
||||||
// if err == nil {
|
if err == nil {
|
||||||
// return nil
|
return nil
|
||||||
// }
|
}
|
||||||
// if !db.IsNotFound(err) {
|
if !db.IsNotFound(err) {
|
||||||
// return err
|
return err
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// err = updateDefaultToken(ctx, store, sessionId, string(activeSym))
|
err = updateDefaultToken(ctx, store, identity, string(activeSym))
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// return err
|
return err
|
||||||
// }
|
}
|
||||||
|
|
||||||
// err = updateTokenBalance(ctx, &api, store, sessionId)
|
// err = updateTokenBalance(ctx, &api, store, sessionId)
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// return err
|
// return err
|
||||||
|
2
go.mod
2
go.mod
@ -4,7 +4,7 @@ go 1.23.2
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
git.defalsify.org/vise.git v0.2.1-0.20241031204035-b588301738ed
|
git.defalsify.org/vise.git v0.2.1-0.20241031204035-b588301738ed
|
||||||
git.grassecon.net/urdt/ussd v0.0.0-20241102154646-e29a24b376cf
|
git.grassecon.net/urdt/ussd v0.0.0-20241102164250-3a8a5f40baa5
|
||||||
github.com/grassrootseconomics/eth-tracker v1.3.0-rc
|
github.com/grassrootseconomics/eth-tracker v1.3.0-rc
|
||||||
github.com/nats-io/nats.go v1.37.0
|
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 h1:4TrsfbK7NKgsa7KjMPlnV/tjYTkAAXP5PWAZzUfzCdI=
|
||||||
git.defalsify.org/vise.git v0.2.1-0.20241031204035-b588301738ed/go.mod h1:jyBMe1qTYUz3mmuoC9JQ/TvFeW0vTanCUcPu3H8p4Ck=
|
git.defalsify.org/vise.git v0.2.1-0.20241031204035-b588301738ed/go.mod h1:jyBMe1qTYUz3mmuoC9JQ/TvFeW0vTanCUcPu3H8p4Ck=
|
||||||
git.grassecon.net/urdt/ussd v0.0.0-20241102154646-e29a24b376cf h1:w7uWGBu+qlXzbR2j7h/kIuXJ3dWsfjxDT07l7NccibM=
|
git.grassecon.net/urdt/ussd v0.0.0-20241102164250-3a8a5f40baa5 h1:B+2YYPw8REXOuEL0PgS5Mzky253wrwWYL9mpD5CmGW4=
|
||||||
git.grassecon.net/urdt/ussd v0.0.0-20241102154646-e29a24b376cf/go.mod h1:ADB/wpwvI6umvYzGqpJGm/GYj8msxYGiczzWCCdXegs=
|
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 h1:Z/iVC0xZfWTaFNE6bA3z07T86hd45Xe2eLt6WVy2bbk=
|
||||||
github.com/alecthomas/assert/v2 v2.2.2/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ=
|
github.com/alecthomas/assert/v2 v2.2.2/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ=
|
||||||
github.com/alecthomas/repr v0.2.0 h1:HAzS41CIzNW5syS8Mf9UwXhNH1J9aix/BvDRf1Ml2Yk=
|
github.com/alecthomas/repr v0.2.0 h1:HAzS41CIzNW5syS8Mf9UwXhNH1J9aix/BvDRf1Ml2Yk=
|
||||||
|
Loading…
Reference in New Issue
Block a user