Compare commits
14 Commits
master
...
add-pool-s
Author | SHA1 | Date | |
---|---|---|---|
5a9fdbd580 | |||
310f15d59d | |||
3bfc0169ee | |||
5d8daf56bc | |||
6532dd89f4 | |||
22cf59f82a | |||
b574db1c89 | |||
419a020346 | |||
57287183bd | |||
3e08d19975 | |||
626538f38e | |||
1eb51bf8f3 | |||
2f706c1c0f | |||
9a1d3c0176 |
8
go.mod
8
go.mod
@ -3,15 +3,14 @@ module git.grassecon.net/grassrootseconomics/sarafu-vise
|
||||
go 1.23.4
|
||||
|
||||
require (
|
||||
git.defalsify.org/vise.git v0.3.2-0.20250528124150-03bf7bfc1b66
|
||||
git.defalsify.org/vise.git v0.3.2-0.20250507135825-a170e8a79da0
|
||||
git.grassecon.net/grassrootseconomics/common v0.9.0-beta.1.0.20250417111317-2953f4c2f32e
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250624090744-339ba854c997
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250606194235-b5ccaea57560
|
||||
git.grassecon.net/grassrootseconomics/visedriver v0.9.0-beta.2.0.20250408094335-e2d1f65bb306
|
||||
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250129070628-5a539172c694
|
||||
github.com/alecthomas/assert/v2 v2.2.2
|
||||
github.com/gofrs/uuid v4.4.0+incompatible
|
||||
github.com/grassrootseconomics/ethutils v1.3.1
|
||||
github.com/grassrootseconomics/ussd-data-service v1.6.0-beta
|
||||
github.com/grassrootseconomics/ussd-data-service v1.4.7-beta
|
||||
github.com/jackc/pgx/v5 v5.7.1
|
||||
github.com/peteole/testdata-loader v0.3.0
|
||||
github.com/stretchr/testify v1.9.0
|
||||
@ -41,6 +40,7 @@ require (
|
||||
github.com/go-ole/go-ole v1.3.0 // indirect
|
||||
github.com/gorilla/websocket v1.5.0 // indirect
|
||||
github.com/grassrootseconomics/eth-custodial v1.3.0-beta // indirect
|
||||
github.com/grassrootseconomics/ethutils v1.3.1 // indirect
|
||||
github.com/graygnuorg/go-gdbm v0.0.0-20220711140707-71387d66dce4 // indirect
|
||||
github.com/hexops/gotextdiff v1.0.3 // indirect
|
||||
github.com/holiman/uint256 v1.3.1 // indirect
|
||||
|
123
go.sum
123
go.sum
@ -1,29 +1,39 @@
|
||||
git.defalsify.org/vise.git v0.3.2-0.20250528124150-03bf7bfc1b66 h1:hmtb2Q3lHxq+SXqG+Gn43pKhTRYx+sw5j1LpgBfXN1o=
|
||||
git.defalsify.org/vise.git v0.3.2-0.20250528124150-03bf7bfc1b66/go.mod h1:jyBMe1qTYUz3mmuoC9JQ/TvFeW0vTanCUcPu3H8p4Ck=
|
||||
git.defalsify.org/vise.git v0.3.2-0.20250425131748-8b84f59792ce h1:Uke2jQ4wG97gQKnTzxPyBGyhosrU1IWnRNFHtKVrmrk=
|
||||
git.defalsify.org/vise.git v0.3.2-0.20250425131748-8b84f59792ce/go.mod h1:jyBMe1qTYUz3mmuoC9JQ/TvFeW0vTanCUcPu3H8p4Ck=
|
||||
git.defalsify.org/vise.git v0.3.2-0.20250507135825-a170e8a79da0 h1:ByRD+b39zVOjOzOf3I1z2L6MSiMZCZT8y0P8MMAAorY=
|
||||
git.defalsify.org/vise.git v0.3.2-0.20250507135825-a170e8a79da0/go.mod h1:flN+Gu+0BX0F6trZc5VpJcO4e6mj/+HUw0Z/UqVTFhk=
|
||||
git.defalsify.org/vise.git v0.3.2-0.20250507172020-cb22240f1cb9 h1:4kjbYw25MHZe9fqSbujPzpFXrYutFfVipvLrcWYnYks=
|
||||
git.defalsify.org/vise.git v0.3.2-0.20250507172020-cb22240f1cb9/go.mod h1:jyBMe1qTYUz3mmuoC9JQ/TvFeW0vTanCUcPu3H8p4Ck=
|
||||
git.grassecon.net/grassrootseconomics/common v0.9.0-beta.1.0.20250417111317-2953f4c2f32e h1:DcC9qkNl9ny3hxQmsMK6W81+5R/j4ZwYUbvewMI/rlc=
|
||||
git.grassecon.net/grassrootseconomics/common v0.9.0-beta.1.0.20250417111317-2953f4c2f32e/go.mod h1:wgQJZGIS6QuNLHqDhcsvehsbn5PvgV7aziRebMnJi60=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250623063234-c1797e7a32b5 h1:VnRe01kHkZUBK/QjE7iV6gElSqSwQnAkWV3yCHtuYrI=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250623063234-c1797e7a32b5/go.mod h1:H97hR+VOnZvR5BiGVb0ScCPwH/IoKBOlKM+yrQNVpq0=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250623070026-d945964b0b46 h1:0+XkSRe7XSHa9WHXKpGPuC0myDszjchr4syH006lQ28=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250623070026-d945964b0b46/go.mod h1:y/vsN8UO0wSxZk3gv0y5df4RPKMJI6TIxjVcVCPF8T8=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250623075057-7b42d509e6d4 h1:W+8CC7x5eCPylkGy2TEoOpfJuiIlqzEzyYTzCLlY/u8=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250623075057-7b42d509e6d4/go.mod h1:y/vsN8UO0wSxZk3gv0y5df4RPKMJI6TIxjVcVCPF8T8=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250624074830-5aa032400c12 h1:vD8biQmN36eouuE+TdxgXQjKisRf5cTGu/tMPv3afs0=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250624074830-5aa032400c12/go.mod h1:y/vsN8UO0wSxZk3gv0y5df4RPKMJI6TIxjVcVCPF8T8=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250624090744-339ba854c997 h1:8bCKyYoV4YiVBvCZlRclc3aQlBYpWhgtM35mvniDFD8=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250624090744-339ba854c997/go.mod h1:y/vsN8UO0wSxZk3gv0y5df4RPKMJI6TIxjVcVCPF8T8=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250428082711-5d221b8d565f h1:OAHCP3YR1C5h1WFnnEnLs5kn6jTxQHQYWYtQaMZJIMY=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250428082711-5d221b8d565f/go.mod h1:gOn89ipaDcDvmQXRMQYKUqcw/sJcwVOPVt2eC6Geip8=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250516094326-3b85167ad84a h1:QNh0NaKtGbSeRPlTVKEAnqc0R5rnVrpDMrCHD/EaU5U=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250516094326-3b85167ad84a/go.mod h1:K/TPgZ4OhPHBQq2X0ab3JZs4YjiexzSURZcfHLs9Pf4=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250517113706-ee434dba6980 h1:FQUwTDFWduY7gCMi1U2OiFlsuAHLojWUw2hvZ4cGC2s=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250517113706-ee434dba6980/go.mod h1:K/TPgZ4OhPHBQq2X0ab3JZs4YjiexzSURZcfHLs9Pf4=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250517114512-050998ff82b1 h1:0hvILlGkZnXO8o7nZth4xu77vAS4zVQ6Ae0rb5x/Idg=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250517114512-050998ff82b1/go.mod h1:K/TPgZ4OhPHBQq2X0ab3JZs4YjiexzSURZcfHLs9Pf4=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250520125035-81fbc2574c30 h1:iZVmR/4xSoxahtkMBXs/z1HUSSnr+x1m+9AxXIgTvb0=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250520125035-81fbc2574c30/go.mod h1:R7+mt27mhm4/LCutAHHv87pOsLxXEPO93KXnhP8H6W0=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250521124206-343d30a2f27c h1:c2cA5hcYnLgs7kR4fF5tp42W6VQClTukbfKoaeskZu0=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250521124206-343d30a2f27c/go.mod h1:R7+mt27mhm4/LCutAHHv87pOsLxXEPO93KXnhP8H6W0=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250521141246-6c3719e3b652 h1:MmUQRL6Fjq/jlL53h+cUbJ7WwQ+q/yNy/zT05c7bgNg=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250521141246-6c3719e3b652/go.mod h1:wKHPy1mpOCr9ahkRltwm1yi9qH/3m9xb8hMCX5C0L1o=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250522123108-24224e553de5 h1:7gVnkpybzg5lC7C8Rl4dejTbmBVpu5xfMMfda+d498U=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250522123108-24224e553de5/go.mod h1:wKHPy1mpOCr9ahkRltwm1yi9qH/3m9xb8hMCX5C0L1o=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250605174108-bf830e92dea2 h1:8cxGb7lSoNGJxjauIRGskp//EqisuOOZPoPj4oDwswE=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250605174108-bf830e92dea2/go.mod h1:wKHPy1mpOCr9ahkRltwm1yi9qH/3m9xb8hMCX5C0L1o=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250606194235-b5ccaea57560 h1:14QVGEgLdl1LyVS/mJFDVRGXHsH5IgmloNPKfk26K6M=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250606194235-b5ccaea57560/go.mod h1:wKHPy1mpOCr9ahkRltwm1yi9qH/3m9xb8hMCX5C0L1o=
|
||||
git.grassecon.net/grassrootseconomics/visedriver v0.9.0-beta.2.0.20250408094335-e2d1f65bb306 h1:Jo+yWysWw/N5BJQtAyEMN8ePVvAyPHv+JG4lQti+1N4=
|
||||
git.grassecon.net/grassrootseconomics/visedriver v0.9.0-beta.2.0.20250408094335-e2d1f65bb306/go.mod h1:FdLwYtzsjOIcDiW4uDgDYnB4Wdzq12uJUe0QHSSPbSo=
|
||||
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250129070628-5a539172c694 h1:DjJlBSz0S13acft5XZDWk7ZYnzElym0xLMYEVgyNJ+E=
|
||||
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250129070628-5a539172c694/go.mod h1:DpibtYpnT3nG4Kn556hRAkdu4+CtiI/6MbnQHal51mQ=
|
||||
github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ=
|
||||
github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
|
||||
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
|
||||
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
|
||||
github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA=
|
||||
github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8=
|
||||
github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjCM7NQbSmF7WI=
|
||||
github.com/VictoriaMetrics/fastcache v1.12.2/go.mod h1:AmC+Nzz1+3G2eCPapF6UcsnkThDcMsQicp4xDukwJYI=
|
||||
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/participle/v2 v2.0.0 h1:Fgrq+MbuSsJwIkw3fEj9h75vDP0Er5JzepJ0/HNHv0g=
|
||||
@ -32,28 +42,10 @@ github.com/alecthomas/repr v0.2.0 h1:HAzS41CIzNW5syS8Mf9UwXhNH1J9aix/BvDRf1Ml2Yk
|
||||
github.com/alecthomas/repr v0.2.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
|
||||
github.com/barbashov/iso639-3 v0.0.0-20211020172741-1f4ffb2d8d1c h1:H9Nm+I7Cg/YVPpEV1RzU3Wq2pjamPc/UtHDgItcb7lE=
|
||||
github.com/barbashov/iso639-3 v0.0.0-20211020172741-1f4ffb2d8d1c/go.mod h1:rGod7o6KPeJ+hyBpHfhi4v7blx9sf+QsHsA7KAsdN6U=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/bits-and-blooms/bitset v1.14.3 h1:Gd2c8lSNf9pKXom5JtD7AaKO8o7fGQ2LtFj1436qilA=
|
||||
github.com/bits-and-blooms/bitset v1.14.3/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ=
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
|
||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U=
|
||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/cockroachdb/errors v1.11.3 h1:5bA+k2Y6r+oz/6Z/RFlNeVCesGARKuC6YymtcDrbC/I=
|
||||
github.com/cockroachdb/errors v1.11.3/go.mod h1:m4UIW4CDjx+R5cybPsNrRbreomiFqt8o1h1wUVazSd8=
|
||||
github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce h1:giXvy4KSc/6g/esnpM7Geqxka4WSqI1SZc7sMJFd3y4=
|
||||
github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce/go.mod h1:9/y3cnZ5GKakj/H4y9r9GTjCvAFta7KLgSHPJJYc52M=
|
||||
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE=
|
||||
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs=
|
||||
github.com/cockroachdb/pebble v1.1.2 h1:CUh2IPtR4swHlEj48Rhfzw6l/d0qA31fItcIszQVIsA=
|
||||
github.com/cockroachdb/pebble v1.1.2/go.mod h1:4exszw1r40423ZsmkG/09AFEG83I0uDgfujJdbL6kYU=
|
||||
github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30=
|
||||
github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg=
|
||||
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo=
|
||||
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ=
|
||||
github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ=
|
||||
github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI=
|
||||
github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M=
|
||||
@ -67,7 +59,6 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/deckarep/golang-set/v2 v2.6.0 h1:XfcQbWM1LlMB8BsJ8N9vW5ehnnPVIw0je80NsVHagjM=
|
||||
github.com/deckarep/golang-set/v2 v2.6.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4=
|
||||
github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0=
|
||||
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc=
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc=
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
|
||||
@ -79,25 +70,11 @@ github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 h1:8NfxH2iXvJ
|
||||
github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9/go.mod h1:M3b90YRnzqKyyzBEWJGqj8Qff4IDeXnzFw0P9bFw3uk=
|
||||
github.com/fxamacker/cbor/v2 v2.4.0 h1:ri0ArlOR+5XunOP8CRUowT0pSJOwhW098ZCUyskZD88=
|
||||
github.com/fxamacker/cbor/v2 v2.4.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo=
|
||||
github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps=
|
||||
github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY=
|
||||
github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
|
||||
github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
|
||||
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
|
||||
github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw=
|
||||
github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU=
|
||||
github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA=
|
||||
github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
||||
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
|
||||
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk=
|
||||
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
|
||||
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
|
||||
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
|
||||
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
@ -105,16 +82,18 @@ github.com/grassrootseconomics/eth-custodial v1.3.0-beta h1:twrMBhl89GqDUL9PlkzQ
|
||||
github.com/grassrootseconomics/eth-custodial v1.3.0-beta/go.mod h1:7uhRcdnJplX4t6GKCEFkbeDhhjlcaGJeJqevbcvGLZo=
|
||||
github.com/grassrootseconomics/ethutils v1.3.1 h1:LlQO90HjJkl7ejC8fv6jP7RJUrAm1j4VMMCYfsoIrhU=
|
||||
github.com/grassrootseconomics/ethutils v1.3.1/go.mod h1:Wuv1VEZrkLIXqTSEYI3Nh9HG/ZHOUQ+U+xvWJ8QtjgQ=
|
||||
github.com/grassrootseconomics/ussd-data-service v1.5.0-beta h1:BSSQL/yPEvTVku9ja/ENZyZdwZkEaiTzzOUfg72bTy4=
|
||||
github.com/grassrootseconomics/ussd-data-service v1.5.0-beta/go.mod h1:9sGnorpKaK76FmOGXoh/xv7x5siSFNYdXxQo9BKW4DI=
|
||||
github.com/grassrootseconomics/ussd-data-service v1.6.0-beta h1:pY6zns6ifXyClRxP+JJaWrged3oRE7tTS2xaftF9clA=
|
||||
github.com/grassrootseconomics/ussd-data-service v1.6.0-beta/go.mod h1:9sGnorpKaK76FmOGXoh/xv7x5siSFNYdXxQo9BKW4DI=
|
||||
github.com/grassrootseconomics/ussd-data-service v1.2.0-beta h1:fn1gwbWIwHVEBtUC2zi5OqTlfI/5gU1SMk0fgGixIXk=
|
||||
github.com/grassrootseconomics/ussd-data-service v1.2.0-beta/go.mod h1:omfI0QtUwIdpu9gMcUqLMCG8O1XWjqJGBx1qUMiGWC0=
|
||||
github.com/grassrootseconomics/ussd-data-service v1.4.0-beta h1:4fMd/3h2ZIhRg4GdHQmRw5FfD3MpJvFNNJQo+Q27f5M=
|
||||
github.com/grassrootseconomics/ussd-data-service v1.4.0-beta/go.mod h1:9sGnorpKaK76FmOGXoh/xv7x5siSFNYdXxQo9BKW4DI=
|
||||
github.com/grassrootseconomics/ussd-data-service v1.4.4-beta h1:turlyo0i3OLj29mWpWNoB/3Qao8qEngT/5d1jDWTZE4=
|
||||
github.com/grassrootseconomics/ussd-data-service v1.4.4-beta/go.mod h1:9sGnorpKaK76FmOGXoh/xv7x5siSFNYdXxQo9BKW4DI=
|
||||
github.com/grassrootseconomics/ussd-data-service v1.4.7-beta h1:yAe1YaOBsdxW2m20jnVU4F0kLmFr+mK/gHCWEdHmE90=
|
||||
github.com/grassrootseconomics/ussd-data-service v1.4.7-beta/go.mod h1:9sGnorpKaK76FmOGXoh/xv7x5siSFNYdXxQo9BKW4DI=
|
||||
github.com/graygnuorg/go-gdbm v0.0.0-20220711140707-71387d66dce4 h1:U4kkNYryi/qfbBF8gh7Vsbuz+cVmhf5kt6pE9bYYyLo=
|
||||
github.com/graygnuorg/go-gdbm v0.0.0-20220711140707-71387d66dce4/go.mod h1:zpZDgZFzeq9s0MIeB1P50NIEWDFFHSFBohI/NbaTD/Y=
|
||||
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
|
||||
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
|
||||
github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao=
|
||||
github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA=
|
||||
github.com/holiman/uint256 v1.3.1 h1:JfTzmih28bittyHM8z360dCjIA9dbPIBlcTI6lmctQs=
|
||||
github.com/holiman/uint256 v1.3.1/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E=
|
||||
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
||||
@ -127,48 +106,24 @@ github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo
|
||||
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||
github.com/klauspost/compress v1.17.2 h1:RlWWUY/Dr4fL8qk9YG7DTZ7PDgME2V4csBXA8L/ixi4=
|
||||
github.com/klauspost/compress v1.17.2/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
||||
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
||||
github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c=
|
||||
github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8=
|
||||
github.com/lmittmann/w3 v0.17.1 h1:zdXIimmNmYfqOFur+Jqc9Yqwtq6jwnsQufbTOnSAtW4=
|
||||
github.com/lmittmann/w3 v0.17.1/go.mod h1:WVUGMbL83WYBu4Sge3SVlW3qIG4VaHe+S8+UUnwz9Eg=
|
||||
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
|
||||
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/mattn/kinako v0.0.0-20170717041458-332c0a7e205a h1:0Q3H0YXzMHiciXtRcM+j0jiCe8WKPQHoRgQiRTnfcLY=
|
||||
github.com/mattn/kinako v0.0.0-20170717041458-332c0a7e205a/go.mod h1:CdTTBOYzS5E4mWS1N8NWP6AHI19MP0A2B18n3hLzRMk=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
|
||||
github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY=
|
||||
github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU=
|
||||
github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU=
|
||||
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
|
||||
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
|
||||
github.com/pashagolub/pgxmock/v4 v4.3.0 h1:DqT7fk0OCK6H0GvqtcMsLpv8cIwWqdxWgfZNLeHCb/s=
|
||||
github.com/pashagolub/pgxmock/v4 v4.3.0/go.mod h1:9VoVHXwS3XR/yPtKGzwQvwZX1kzGB9sM8SviDcHDa3A=
|
||||
github.com/peteole/testdata-loader v0.3.0 h1:8jckE9KcyNHgyv/VPoaljvKZE0Rqr8+dPVYH6rfNr9I=
|
||||
github.com/peteole/testdata-loader v0.3.0/go.mod h1:Mt0ZbRtb56u8SLJpNP+BnQbENljMorYBpqlvt3cS83U=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_golang v1.12.0 h1:C+UIj/QWtmqY13Arb8kwMt5j34/0Z2iKamrJ+ryC0Gg=
|
||||
github.com/prometheus/client_golang v1.12.0/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY=
|
||||
github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a h1:CmF68hwI0XsOQ5UwlBopMi2Ow4Pbg32akc4KIVCOm+Y=
|
||||
github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w=
|
||||
github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4=
|
||||
github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls=
|
||||
github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU=
|
||||
github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
|
||||
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
|
||||
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
|
||||
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU=
|
||||
@ -182,8 +137,6 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4=
|
||||
github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
|
||||
github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU=
|
||||
github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI=
|
||||
github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk=
|
||||
@ -208,15 +161,11 @@ golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
|
||||
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
||||
golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ=
|
||||
golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
|
||||
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/leonelquinteros/gotext.v1 v1.3.1 h1:8d9/fdTG0kn/B7NNGV1BsEyvektXFAbkMsTZS2sFSCc=
|
||||
gopkg.in/leonelquinteros/gotext.v1 v1.3.1/go.mod h1:X1WlGDeAFIYsW6GjgMm4VwUwZ2XjI7Zan2InxSUQWrU=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
@ -1082,7 +1082,6 @@ func (h *MenuHandlers) GetCurrentProfileInfo(ctx context.Context, sym string, in
|
||||
parts := strings.SplitN(sm, "_", 2)
|
||||
filename := parts[1]
|
||||
dbKeyStr := "DATA_" + strings.ToUpper(filename)
|
||||
logg.InfoCtxf(ctx, "GetCurrentProfileInfo", "filename", filename, "dbKeyStr:", dbKeyStr)
|
||||
dbKey, err := storedb.StringToDataTyp(dbKeyStr)
|
||||
|
||||
if err != nil {
|
||||
@ -1830,12 +1829,12 @@ func (h *MenuHandlers) ValidateAmount(ctx context.Context, sym string, input []b
|
||||
return res, fmt.Errorf("missing session")
|
||||
}
|
||||
flag_invalid_amount, _ := h.flagManager.GetFlag("flag_invalid_amount")
|
||||
userStore := h.userdataStore
|
||||
store := h.userdataStore
|
||||
|
||||
var balanceValue float64
|
||||
|
||||
// retrieve the active balance
|
||||
activeBal, err := userStore.ReadEntry(ctx, sessionId, storedb.DATA_ACTIVE_BAL)
|
||||
activeBal, err := store.ReadEntry(ctx, sessionId, storedb.DATA_ACTIVE_BAL)
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to read activeBal entry with", "key", storedb.DATA_ACTIVE_BAL, "error", err)
|
||||
return res, err
|
||||
@ -1861,15 +1860,9 @@ func (h *MenuHandlers) ValidateAmount(ctx context.Context, sym string, input []b
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// Format the amount to 2 decimal places before saving (truncated)
|
||||
formattedAmount, err := store.TruncateDecimalString(amountStr, 2)
|
||||
if err != nil {
|
||||
res.FlagSet = append(res.FlagSet, flag_invalid_amount)
|
||||
res.Content = amountStr
|
||||
return res, nil
|
||||
}
|
||||
|
||||
err = userStore.WriteEntry(ctx, sessionId, storedb.DATA_AMOUNT, []byte(formattedAmount))
|
||||
// Format the amount with 2 decimal places before saving
|
||||
formattedAmount := fmt.Sprintf("%.2f", inputAmount)
|
||||
err = store.WriteEntry(ctx, sessionId, storedb.DATA_AMOUNT, []byte(formattedAmount))
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to write amount entry with", "key", storedb.DATA_AMOUNT, "value", formattedAmount, "error", err)
|
||||
return res, err
|
||||
@ -2050,7 +2043,7 @@ func (h *MenuHandlers) ManageVouchers(ctx context.Context, sym string, input []b
|
||||
defaultSym := firstVoucher.TokenSymbol
|
||||
defaultBal := firstVoucher.Balance
|
||||
defaultDec := firstVoucher.TokenDecimals
|
||||
defaultAddr := firstVoucher.TokenAddress
|
||||
defaultAddr := firstVoucher.ContractAddress
|
||||
|
||||
// Scale down the balance
|
||||
scaledBalance := store.ScaleDownBalance(defaultBal, defaultDec)
|
||||
@ -2272,8 +2265,8 @@ func (h *MenuHandlers) GetDefaultPool(ctx context.Context, sym string, input []b
|
||||
logg.ErrorCtxf(ctx, "failed to read the activePoolSym entry with", "key", storedb.DATA_ACTIVE_POOL_SYM, "error", err)
|
||||
return res, err
|
||||
}
|
||||
|
||||
res.Content = string(activePoolSym)
|
||||
|
||||
res.Content = string(activePoolSym)
|
||||
|
||||
return res, nil
|
||||
}
|
||||
@ -2827,7 +2820,7 @@ func (h *MenuHandlers) LoadSwapToList(ctx context.Context, sym string, input []b
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// Get active pool address and symbol or fall back to default
|
||||
// Get active pool address or fall back to default
|
||||
var activePoolAddress []byte
|
||||
activePoolAddress, err = userStore.ReadEntry(ctx, sessionId, storedb.DATA_ACTIVE_POOL_ADDRESS)
|
||||
if err != nil {
|
||||
@ -2846,24 +2839,6 @@ func (h *MenuHandlers) LoadSwapToList(ctx context.Context, sym string, input []b
|
||||
}
|
||||
}
|
||||
|
||||
var activePoolSymbol []byte
|
||||
activePoolSymbol, err = userStore.ReadEntry(ctx, sessionId, storedb.DATA_ACTIVE_POOL_SYM)
|
||||
if err != nil {
|
||||
if db.IsNotFound(err) {
|
||||
defaultPoolSym := config.DefaultPoolName()
|
||||
// store the default as the active pool symbol
|
||||
err = userStore.WriteEntry(ctx, sessionId, storedb.DATA_ACTIVE_POOL_SYM, []byte(defaultPoolSym))
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to write default Pool Symbol", "key", storedb.DATA_ACTIVE_POOL_SYM, "value", defaultPoolSym, "error", err)
|
||||
return res, err
|
||||
}
|
||||
activePoolSymbol = []byte(defaultPoolSym)
|
||||
} else {
|
||||
logg.ErrorCtxf(ctx, "failed to read active Pool symbol", "key", storedb.DATA_ACTIVE_POOL_SYM, "error", err)
|
||||
return res, err
|
||||
}
|
||||
}
|
||||
|
||||
// call the api using the ActivePoolAddress and ActiveVoucherAddress to check if it is part of the pool
|
||||
r, err := h.accountService.CheckTokenInPool(ctx, string(activePoolAddress), string(activeAddress))
|
||||
if err != nil {
|
||||
@ -2872,14 +2847,14 @@ func (h *MenuHandlers) LoadSwapToList(ctx context.Context, sym string, input []b
|
||||
return res, err
|
||||
}
|
||||
|
||||
logg.InfoCtxf(ctx, "CheckTokenInPool", "response", r, "active_pool_address", string(activePoolAddress), "active_symbol_address", string(activeAddress))
|
||||
logg.InfoCtxf(ctx, "CheckTokenInPool", "response", r, "active_pool_address", activePoolAddress, "address", activeAddress)
|
||||
|
||||
if !r.CanSwapFrom {
|
||||
res.FlagSet = append(res.FlagSet, flag_incorrect_voucher)
|
||||
res.Content = l.Get(
|
||||
"%s is not in %s. Please update your voucher and try again.",
|
||||
activeSym,
|
||||
activePoolSymbol,
|
||||
config.DefaultPoolName(),
|
||||
)
|
||||
return res, nil
|
||||
}
|
||||
@ -2894,16 +2869,12 @@ func (h *MenuHandlers) LoadSwapToList(ctx context.Context, sym string, input []b
|
||||
return res, err
|
||||
}
|
||||
|
||||
logg.InfoCtxf(ctx, "GetPoolSwappableVouchers", "swapToList", swapToList)
|
||||
|
||||
// Return if there are no vouchers
|
||||
if len(swapToList) == 0 {
|
||||
return res, nil
|
||||
}
|
||||
|
||||
data := store.ProcessVouchers(swapToList)
|
||||
|
||||
logg.InfoCtxf(ctx, "ProcessVouchers", "data", data)
|
||||
data := store.ProcessTokens(swapToList)
|
||||
|
||||
// Store all swap_to tokens data
|
||||
dataMap := map[storedb.DataTyp]string{
|
||||
@ -2955,8 +2926,6 @@ func (h *MenuHandlers) SwapMaxLimit(ctx context.Context, sym string, input []byt
|
||||
return res, nil
|
||||
}
|
||||
|
||||
logg.InfoCtxf(ctx, "Metadata from GetSwapToVoucherData:", "metadata", metadata)
|
||||
|
||||
// Store the active swap_to data
|
||||
if err := store.UpdateSwapToVoucherData(ctx, userStore, sessionId, metadata); err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed on UpdateSwapToVoucherData", "error", err)
|
||||
@ -2969,11 +2938,10 @@ func (h *MenuHandlers) SwapMaxLimit(ctx context.Context, sym string, input []byt
|
||||
}
|
||||
|
||||
// call the api using the ActivePoolAddress, ActiveSwapFromAddress, ActiveSwapToAddress and PublicKey to get the swap max limit
|
||||
logg.InfoCtxf(ctx, "Call GetSwapFromTokenMaxLimit with:", "ActivePoolAddress", swapData.ActivePoolAddress, "ActiveSwapFromAddress", swapData.ActiveSwapFromAddress, "ActiveSwapToAddress", swapData.ActiveSwapToAddress, "publicKey", swapData.PublicKey)
|
||||
r, err := h.accountService.GetSwapFromTokenMaxLimit(ctx, swapData.ActivePoolAddress, swapData.ActiveSwapFromAddress, swapData.ActiveSwapToAddress, swapData.PublicKey)
|
||||
if err != nil {
|
||||
res.FlagSet = append(res.FlagSet, flag_api_error)
|
||||
logg.ErrorCtxf(ctx, "failed on GetSwapFromTokenMaxLimit", "error", err)
|
||||
logg.ErrorCtxf(ctx, "failed on FetchTransactions", "error", err)
|
||||
return res, err
|
||||
}
|
||||
|
||||
@ -3052,15 +3020,7 @@ func (h *MenuHandlers) SwapPreview(ctx context.Context, sym string, input []byte
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// Format the amount to 2 decimal places
|
||||
formattedAmount, err := store.TruncateDecimalString(inputStr, 2)
|
||||
if err != nil {
|
||||
res.FlagSet = append(res.FlagSet, flag_invalid_amount)
|
||||
res.Content = inputStr
|
||||
return res, nil
|
||||
}
|
||||
|
||||
finalAmountStr, err := store.ParseAndScaleAmount(formattedAmount, swapData.ActiveSwapFromDecimal)
|
||||
finalAmountStr, err := store.ParseAndScaleAmount(inputStr, swapData.ActiveSwapFromDecimal)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
|
@ -1678,22 +1678,6 @@ func TestValidateAmount(t *testing.T) {
|
||||
Content: "0.02ms",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Test with valid decimal amount",
|
||||
input: []byte("0.149"),
|
||||
activeBal: []byte("5"),
|
||||
expectedResult: resource.Result{
|
||||
Content: "0.14",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Test with valid large decimal amount",
|
||||
input: []byte("1.8599999999"),
|
||||
activeBal: []byte("5"),
|
||||
expectedResult: resource.Result{
|
||||
Content: "1.85",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
@ -2123,10 +2107,10 @@ func TestManageVouchers(t *testing.T) {
|
||||
name: "Set default voucher when no active voucher is set",
|
||||
vouchersResp: []dataserviceapi.TokenHoldings{
|
||||
{
|
||||
TokenAddress: "0x123",
|
||||
TokenSymbol: "TOKEN1",
|
||||
TokenDecimals: "18",
|
||||
Balance: "100",
|
||||
ContractAddress: "0x123",
|
||||
TokenSymbol: "TOKEN1",
|
||||
TokenDecimals: "18",
|
||||
Balance: "100",
|
||||
},
|
||||
},
|
||||
expectedVoucherSymbols: []byte("1:TOKEN1"),
|
||||
@ -2138,8 +2122,8 @@ func TestManageVouchers(t *testing.T) {
|
||||
{
|
||||
name: "Check and update active voucher balance",
|
||||
vouchersResp: []dataserviceapi.TokenHoldings{
|
||||
{TokenAddress: "0xd4c288865Ce", TokenSymbol: "SRF", TokenDecimals: "6", Balance: "100"},
|
||||
{TokenAddress: "0x41c188d63Qa", TokenSymbol: "MILO", TokenDecimals: "4", Balance: "200"},
|
||||
{ContractAddress: "0xd4c288865Ce", TokenSymbol: "SRF", TokenDecimals: "6", Balance: "100"},
|
||||
{ContractAddress: "0x41c188d63Qa", TokenSymbol: "MILO", TokenDecimals: "4", Balance: "200"},
|
||||
},
|
||||
storedActiveVoucher: "SRF",
|
||||
expectedVoucherSymbols: []byte("1:SRF\n2:MILO"),
|
||||
@ -2271,13 +2255,13 @@ func TestSetVoucher(t *testing.T) {
|
||||
|
||||
// Define the temporary voucher data
|
||||
tempData := &dataserviceapi.TokenHoldings{
|
||||
TokenSymbol: "SRF",
|
||||
Balance: "200",
|
||||
TokenDecimals: "6",
|
||||
TokenAddress: "0xd4c288865Ce0985a481Eef3be02443dF5E2e4Ea9",
|
||||
TokenSymbol: "SRF",
|
||||
Balance: "200",
|
||||
TokenDecimals: "6",
|
||||
ContractAddress: "0xd4c288865Ce0985a481Eef3be02443dF5E2e4Ea9",
|
||||
}
|
||||
|
||||
expectedData := fmt.Sprintf("%s,%s,%s,%s", tempData.TokenSymbol, tempData.Balance, tempData.TokenDecimals, tempData.TokenAddress)
|
||||
expectedData := fmt.Sprintf("%s,%s,%s,%s", tempData.TokenSymbol, tempData.Balance, tempData.TokenDecimals, tempData.ContractAddress)
|
||||
|
||||
// store the expectedData
|
||||
if err := store.WriteEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE, []byte(expectedData)); err != nil {
|
||||
|
@ -11,7 +11,7 @@
|
||||
},
|
||||
{
|
||||
"input": "1",
|
||||
"expectedContent": "Do you agree to terms and conditions?\nhttps://grassecon.org/tos\n\n1:Yes\n2:No"
|
||||
"expectedContent": "Do you agree to terms and conditions?\nhttps://grassecon.org/pages/terms-and-conditions\n\n1:Yes\n2:No"
|
||||
},
|
||||
{
|
||||
"input": "1",
|
||||
@ -31,7 +31,7 @@
|
||||
},
|
||||
{
|
||||
"input": "1234",
|
||||
"expectedContent": "Your account is being created. Thank you for using Sarafu. Goodbye!"
|
||||
"expectedContent": "Your account is being created...Thank you for using Sarafu. Goodbye!"
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -44,7 +44,7 @@
|
||||
},
|
||||
{
|
||||
"input": "1",
|
||||
"expectedContent": "Do you agree to terms and conditions?\nhttps://grassecon.org/tos\n\n1:Yes\n2:No"
|
||||
"expectedContent": "Do you agree to terms and conditions?\nhttps://grassecon.org/pages/terms-and-conditions\n\n1:Yes\n2:No"
|
||||
},
|
||||
{
|
||||
"input": "2",
|
||||
|
@ -1 +1 @@
|
||||
Your account is being created.
|
||||
Your account is being created...
|
@ -1,2 +1,2 @@
|
||||
Do you agree to terms and conditions?
|
||||
https://grassecon.org/tos
|
||||
https://grassecon.org/pages/terms-and-conditions
|
||||
|
@ -1,2 +1,2 @@
|
||||
Kwa kutumia hii huduma umekubali sheria na masharti?
|
||||
https://grassecon.org/tos
|
||||
https://grassecon.org/pages/terms-and-conditions
|
||||
|
@ -123,7 +123,7 @@ func GetTemporaryPoolData(ctx context.Context, store DataStore, sessionId string
|
||||
|
||||
// UpdatePoolData updates the active pool data in the DataStore.
|
||||
func UpdatePoolData(ctx context.Context, store DataStore, sessionId string, data *dataserviceapi.PoolDetails) error {
|
||||
logg.InfoCtxf(ctx, "UpdatePoolData", "data", data)
|
||||
logg.TraceCtxf(ctx, "dtal", "data", data)
|
||||
// Active pool data entry
|
||||
activeEntries := map[storedb.DataTyp][]byte{
|
||||
storedb.DATA_ACTIVE_POOL_NAME: []byte(data.PoolName),
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strconv"
|
||||
|
||||
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
|
||||
dataserviceapi "github.com/grassrootseconomics/ussd-data-service/pkg/api"
|
||||
@ -124,15 +125,15 @@ func GetSwapFromVoucherData(ctx context.Context, store DataStore, sessionId stri
|
||||
}
|
||||
|
||||
return &dataserviceapi.TokenHoldings{
|
||||
TokenSymbol: string(symbol),
|
||||
Balance: string(balance),
|
||||
TokenDecimals: string(decimal),
|
||||
TokenAddress: string(address),
|
||||
TokenSymbol: string(symbol),
|
||||
Balance: string(balance),
|
||||
TokenDecimals: string(decimal),
|
||||
ContractAddress: string(address),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// GetSwapToVoucherData retrieves and matches token data
|
||||
func GetSwapToVoucherData(ctx context.Context, store DataStore, sessionId string, input string) (*dataserviceapi.TokenHoldings, error) {
|
||||
func GetSwapToVoucherData(ctx context.Context, store DataStore, sessionId string, input string) (*dataserviceapi.TokenDetails, error) {
|
||||
keys := []storedb.DataTyp{
|
||||
storedb.DATA_POOL_TO_SYMBOLS,
|
||||
storedb.DATA_POOL_TO_BALANCES,
|
||||
@ -149,7 +150,7 @@ func GetSwapToVoucherData(ctx context.Context, store DataStore, sessionId string
|
||||
data[key] = string(value)
|
||||
}
|
||||
|
||||
symbol, balance, decimal, address := MatchVoucher(input,
|
||||
symbol, _, decimal, address := MatchVoucher(input,
|
||||
data[storedb.DATA_POOL_TO_SYMBOLS],
|
||||
data[storedb.DATA_POOL_TO_BALANCES],
|
||||
data[storedb.DATA_POOL_TO_DECIMALS],
|
||||
@ -160,21 +161,30 @@ func GetSwapToVoucherData(ctx context.Context, store DataStore, sessionId string
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return &dataserviceapi.TokenHoldings{
|
||||
decimalInt, err := strconv.ParseUint(decimal, 0, 64)
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "Failed to parse decimal to Uint:", "sessionId", sessionId, "decimal", decimal, "error", err)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return &dataserviceapi.TokenDetails{
|
||||
TokenSymbol: string(symbol),
|
||||
Balance: string(balance),
|
||||
TokenDecimals: string(decimal),
|
||||
TokenDecimals: uint8(decimalInt),
|
||||
TokenAddress: string(address),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// UpdateSwapToVoucherData updates the active swap to voucher data in the DataStore.
|
||||
func UpdateSwapToVoucherData(ctx context.Context, store DataStore, sessionId string, data *dataserviceapi.TokenHoldings) error {
|
||||
logg.InfoCtxf(ctx, "UpdateSwapToVoucherData", "data", data)
|
||||
func UpdateSwapToVoucherData(ctx context.Context, store DataStore, sessionId string, data *dataserviceapi.TokenDetails) error {
|
||||
logg.TraceCtxf(ctx, "UpdateSwapToVoucherData", "data", data)
|
||||
|
||||
// Convert TokenDecimals (uint8) to string
|
||||
tokenDecimalsStr := strconv.FormatUint(uint64(data.TokenDecimals), 10)
|
||||
|
||||
// Active swap to voucher data entries
|
||||
activeEntries := map[storedb.DataTyp][]byte{
|
||||
storedb.DATA_ACTIVE_SWAP_TO_SYM: []byte(data.TokenSymbol),
|
||||
storedb.DATA_ACTIVE_SWAP_TO_DECIMAL: []byte(data.TokenDecimals),
|
||||
storedb.DATA_ACTIVE_SWAP_TO_DECIMAL: []byte(tokenDecimalsStr),
|
||||
storedb.DATA_ACTIVE_SWAP_TO_ADDRESS: []byte(data.TokenAddress),
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ func TestGetSwapFromVoucherData(t *testing.T) {
|
||||
assert.Equal(t, "AMANI", result.TokenSymbol)
|
||||
assert.Equal(t, "", result.Balance)
|
||||
assert.Equal(t, "6", result.TokenDecimals)
|
||||
assert.Equal(t, "0xc7B78Ac9ACB9E025C8234621FC515bC58179dEAe", result.TokenAddress)
|
||||
assert.Equal(t, "0xc7B78Ac9ACB9E025C8234621FC515bC58179dEAe", result.ContractAddress)
|
||||
}
|
||||
|
||||
func TestGetSwapToVoucherData(t *testing.T) {
|
||||
@ -142,5 +142,5 @@ func TestGetSwapToVoucherData(t *testing.T) {
|
||||
assert.Equal(t, "cUSD", result.TokenSymbol)
|
||||
assert.Equal(t, "", result.Balance)
|
||||
assert.Equal(t, "6", result.TokenDecimals)
|
||||
assert.Equal(t, "0xc7B78Ac9ACB9E025C8234621", result.TokenAddress)
|
||||
assert.Equal(t, "0xc7B78Ac9ACB9E025C8234621", result.ContractAddress)
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package store
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"reflect"
|
||||
"strconv"
|
||||
@ -21,27 +20,6 @@ type TransactionData struct {
|
||||
ActiveAddress string
|
||||
}
|
||||
|
||||
// TruncateDecimalString safely truncates the input amount to the specified decimal places
|
||||
func TruncateDecimalString(input string, decimalPlaces int) (string, error) {
|
||||
num, ok := new(big.Float).SetString(input)
|
||||
if !ok {
|
||||
return "", fmt.Errorf("invalid input")
|
||||
}
|
||||
|
||||
// Multiply by 10^decimalPlaces
|
||||
scale := new(big.Float).SetInt(new(big.Int).Exp(big.NewInt(10), big.NewInt(int64(decimalPlaces)), nil))
|
||||
scaled := new(big.Float).Mul(num, scale)
|
||||
|
||||
// Truncate by converting to int (chops off decimals)
|
||||
intPart, _ := scaled.Int(nil)
|
||||
|
||||
// Divide back to get truncated float
|
||||
truncated := new(big.Float).Quo(new(big.Float).SetInt(intPart), scale)
|
||||
|
||||
// Format with fixed decimals
|
||||
return truncated.Text('f', decimalPlaces), nil
|
||||
}
|
||||
|
||||
func ParseAndScaleAmount(storedAmount, activeDecimal string) (string, error) {
|
||||
// Parse token decimal
|
||||
tokenDecimal, err := strconv.Atoi(activeDecimal)
|
||||
@ -60,8 +38,11 @@ func ParseAndScaleAmount(storedAmount, activeDecimal string) (string, error) {
|
||||
multiplier := new(big.Float).SetInt(new(big.Int).Exp(big.NewInt(10), big.NewInt(int64(tokenDecimal)), nil))
|
||||
finalAmount := new(big.Float).Mul(amount, multiplier)
|
||||
|
||||
// Return finalAmount as a string with 0 decimal places (rounded)
|
||||
return finalAmount.Text('f', 0), nil
|
||||
// Convert finalAmount to a string
|
||||
finalAmountStr := new(big.Int)
|
||||
finalAmount.Int(finalAmountStr)
|
||||
|
||||
return finalAmountStr.String(), nil
|
||||
}
|
||||
|
||||
func ReadTransactionData(ctx context.Context, store DataStore, sessionId string) (TransactionData, error) {
|
||||
|
@ -7,109 +7,6 @@ import (
|
||||
"github.com/alecthomas/assert/v2"
|
||||
)
|
||||
|
||||
func TestTruncateDecimalString(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
input string
|
||||
decimalPlaces int
|
||||
want string
|
||||
expectError bool
|
||||
}{
|
||||
{
|
||||
name: "whole number",
|
||||
input: "4",
|
||||
decimalPlaces: 2,
|
||||
want: "4.00",
|
||||
expectError: false,
|
||||
},
|
||||
{
|
||||
name: "single decimal",
|
||||
input: "4.1",
|
||||
decimalPlaces: 2,
|
||||
want: "4.10",
|
||||
expectError: false,
|
||||
},
|
||||
{
|
||||
name: "one decimal place",
|
||||
input: "4.19",
|
||||
decimalPlaces: 1,
|
||||
want: "4.1",
|
||||
expectError: false,
|
||||
},
|
||||
{
|
||||
name: "truncates to 2 dp",
|
||||
input: "0.149",
|
||||
decimalPlaces: 2,
|
||||
want: "0.14",
|
||||
expectError: false,
|
||||
},
|
||||
{
|
||||
name: "does not round",
|
||||
input: "1.8599999999",
|
||||
decimalPlaces: 2,
|
||||
want: "1.85",
|
||||
expectError: false,
|
||||
},
|
||||
{
|
||||
name: "high precision input",
|
||||
input: "123.456789",
|
||||
decimalPlaces: 4,
|
||||
want: "123.4567",
|
||||
expectError: false,
|
||||
},
|
||||
{
|
||||
name: "zero",
|
||||
input: "0",
|
||||
decimalPlaces: 2,
|
||||
want: "0.00",
|
||||
expectError: false,
|
||||
},
|
||||
{
|
||||
name: "invalid input string",
|
||||
input: "abc",
|
||||
decimalPlaces: 2,
|
||||
want: "",
|
||||
expectError: true,
|
||||
},
|
||||
{
|
||||
name: "edge rounding case",
|
||||
input: "4.99999999",
|
||||
decimalPlaces: 2,
|
||||
want: "4.99",
|
||||
expectError: false,
|
||||
},
|
||||
{
|
||||
name: "small value",
|
||||
input: "0.0001",
|
||||
decimalPlaces: 2,
|
||||
want: "0.00",
|
||||
expectError: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got, err := TruncateDecimalString(tt.input, tt.decimalPlaces)
|
||||
|
||||
if tt.expectError {
|
||||
if err == nil {
|
||||
t.Errorf("TruncateDecimalString(%q, %d) expected error, got nil", tt.input, tt.decimalPlaces)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("TruncateDecimalString(%q, %d) unexpected error: %v", tt.input, tt.decimalPlaces, err)
|
||||
return
|
||||
}
|
||||
|
||||
if got != tt.want {
|
||||
t.Errorf("TruncateDecimalString(%q, %d) = %q, want %q", tt.input, tt.decimalPlaces, got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseAndScaleAmount(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
@ -167,20 +64,6 @@ func TestParseAndScaleAmount(t *testing.T) {
|
||||
want: "0",
|
||||
expectError: false,
|
||||
},
|
||||
{
|
||||
name: "high decimals",
|
||||
amount: "1.85",
|
||||
decimals: "18",
|
||||
want: "1850000000000000000",
|
||||
expectError: false,
|
||||
},
|
||||
{
|
||||
name: "6 d.p",
|
||||
amount: "2.32",
|
||||
decimals: "6",
|
||||
want: "2320000",
|
||||
expectError: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
@ -36,7 +36,7 @@ func ProcessVouchers(holdings []dataserviceapi.TokenHoldings) VoucherMetadata {
|
||||
|
||||
balances = append(balances, fmt.Sprintf("%d:%s", i+1, scaledBalance))
|
||||
decimals = append(decimals, fmt.Sprintf("%d:%s", i+1, h.TokenDecimals))
|
||||
addresses = append(addresses, fmt.Sprintf("%d:%s", i+1, h.TokenAddress))
|
||||
addresses = append(addresses, fmt.Sprintf("%d:%s", i+1, h.ContractAddress))
|
||||
}
|
||||
|
||||
data.Symbols = strings.Join(symbols, "\n")
|
||||
@ -47,6 +47,24 @@ func ProcessVouchers(holdings []dataserviceapi.TokenHoldings) VoucherMetadata {
|
||||
return data
|
||||
}
|
||||
|
||||
// ProcessTokens converts swappable tokens into formatted strings
|
||||
func ProcessTokens(holdings []dataserviceapi.TokenDetails) VoucherMetadata {
|
||||
var data VoucherMetadata
|
||||
var symbols, decimals, addresses []string
|
||||
|
||||
for i, h := range holdings {
|
||||
symbols = append(symbols, fmt.Sprintf("%d:%s", i+1, h.TokenSymbol))
|
||||
decimals = append(decimals, fmt.Sprintf("%d:%d", i+1, h.TokenDecimals))
|
||||
addresses = append(addresses, fmt.Sprintf("%d:%s", i+1, h.TokenAddress))
|
||||
}
|
||||
|
||||
data.Symbols = strings.Join(symbols, "\n")
|
||||
data.Decimals = strings.Join(decimals, "\n")
|
||||
data.Addresses = strings.Join(addresses, "\n")
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
func ScaleDownBalance(balance, decimals string) string {
|
||||
// Convert balance and decimals to big.Float
|
||||
bal := new(big.Float)
|
||||
@ -97,10 +115,10 @@ func GetVoucherData(ctx context.Context, store DataStore, sessionId string, inpu
|
||||
}
|
||||
|
||||
return &dataserviceapi.TokenHoldings{
|
||||
TokenSymbol: string(symbol),
|
||||
Balance: string(balance),
|
||||
TokenDecimals: string(decimal),
|
||||
TokenAddress: string(address),
|
||||
TokenSymbol: string(symbol),
|
||||
Balance: string(balance),
|
||||
TokenDecimals: string(decimal),
|
||||
ContractAddress: string(address),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -134,7 +152,7 @@ func MatchVoucher(input, symbols, balances, decimals, addresses string) (symbol,
|
||||
|
||||
// StoreTemporaryVoucher saves voucher metadata as temporary entries in the DataStore.
|
||||
func StoreTemporaryVoucher(ctx context.Context, store DataStore, sessionId string, data *dataserviceapi.TokenHoldings) error {
|
||||
tempData := fmt.Sprintf("%s,%s,%s,%s", data.TokenSymbol, data.Balance, data.TokenDecimals, data.TokenAddress)
|
||||
tempData := fmt.Sprintf("%s,%s,%s,%s", data.TokenSymbol, data.Balance, data.TokenDecimals, data.ContractAddress)
|
||||
|
||||
if err := store.WriteEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE, []byte(tempData)); err != nil {
|
||||
return err
|
||||
@ -157,7 +175,7 @@ func GetTemporaryVoucherData(ctx context.Context, store DataStore, sessionId str
|
||||
data.TokenSymbol = values[0]
|
||||
data.Balance = values[1]
|
||||
data.TokenDecimals = values[2]
|
||||
data.TokenAddress = values[3]
|
||||
data.ContractAddress = values[3]
|
||||
|
||||
return data, nil
|
||||
}
|
||||
@ -170,7 +188,7 @@ func UpdateVoucherData(ctx context.Context, store DataStore, sessionId string, d
|
||||
storedb.DATA_ACTIVE_SYM: []byte(data.TokenSymbol),
|
||||
storedb.DATA_ACTIVE_BAL: []byte(data.Balance),
|
||||
storedb.DATA_ACTIVE_DECIMAL: []byte(data.TokenDecimals),
|
||||
storedb.DATA_ACTIVE_ADDRESS: []byte(data.TokenAddress),
|
||||
storedb.DATA_ACTIVE_ADDRESS: []byte(data.ContractAddress),
|
||||
}
|
||||
|
||||
// Write active data
|
||||
|
@ -59,8 +59,8 @@ func TestMatchVoucher(t *testing.T) {
|
||||
|
||||
func TestProcessVouchers(t *testing.T) {
|
||||
holdings := []dataserviceapi.TokenHoldings{
|
||||
{TokenAddress: "0xd4c288865Ce", TokenSymbol: "SRF", TokenDecimals: "6", Balance: "100000000"},
|
||||
{TokenAddress: "0x41c188d63Qa", TokenSymbol: "MILO", TokenDecimals: "4", Balance: "200000000"},
|
||||
{ContractAddress: "0xd4c288865Ce", TokenSymbol: "SRF", TokenDecimals: "6", Balance: "100000000"},
|
||||
{ContractAddress: "0x41c188d63Qa", TokenSymbol: "MILO", TokenDecimals: "4", Balance: "200000000"},
|
||||
}
|
||||
|
||||
expectedResult := VoucherMetadata{
|
||||
@ -101,7 +101,7 @@ func TestGetVoucherData(t *testing.T) {
|
||||
assert.Equal(t, "SRF", result.TokenSymbol)
|
||||
assert.Equal(t, "100", result.Balance)
|
||||
assert.Equal(t, "6", result.TokenDecimals)
|
||||
assert.Equal(t, "0xd4c288865Ce", result.TokenAddress)
|
||||
assert.Equal(t, "0xd4c288865Ce", result.ContractAddress)
|
||||
}
|
||||
|
||||
func TestStoreTemporaryVoucher(t *testing.T) {
|
||||
@ -110,10 +110,10 @@ func TestStoreTemporaryVoucher(t *testing.T) {
|
||||
|
||||
// Test data
|
||||
voucherData := &dataserviceapi.TokenHoldings{
|
||||
TokenSymbol: "SRF",
|
||||
Balance: "200",
|
||||
TokenDecimals: "6",
|
||||
TokenAddress: "0xd4c288865Ce0985a481Eef3be02443dF5E2e4Ea9",
|
||||
TokenSymbol: "SRF",
|
||||
Balance: "200",
|
||||
TokenDecimals: "6",
|
||||
ContractAddress: "0xd4c288865Ce0985a481Eef3be02443dF5E2e4Ea9",
|
||||
}
|
||||
|
||||
// Execute the function being tested
|
||||
@ -134,10 +134,10 @@ func TestGetTemporaryVoucherData(t *testing.T) {
|
||||
|
||||
// Test voucher data
|
||||
tempData := &dataserviceapi.TokenHoldings{
|
||||
TokenSymbol: "SRF",
|
||||
Balance: "200",
|
||||
TokenDecimals: "6",
|
||||
TokenAddress: "0xd4c288865Ce0985a481Eef3be02443dF5E2e4Ea9",
|
||||
TokenSymbol: "SRF",
|
||||
Balance: "200",
|
||||
TokenDecimals: "6",
|
||||
ContractAddress: "0xd4c288865Ce0985a481Eef3be02443dF5E2e4Ea9",
|
||||
}
|
||||
|
||||
// Store the data
|
||||
@ -156,18 +156,18 @@ func TestUpdateVoucherData(t *testing.T) {
|
||||
|
||||
// New voucher data
|
||||
newData := &dataserviceapi.TokenHoldings{
|
||||
TokenSymbol: "SRF",
|
||||
Balance: "200",
|
||||
TokenDecimals: "6",
|
||||
TokenAddress: "0xd4c288865Ce0985a481Eef3be02443dF5E2e4Ea9",
|
||||
TokenSymbol: "SRF",
|
||||
Balance: "200",
|
||||
TokenDecimals: "6",
|
||||
ContractAddress: "0xd4c288865Ce0985a481Eef3be02443dF5E2e4Ea9",
|
||||
}
|
||||
|
||||
// Old temporary data
|
||||
tempData := &dataserviceapi.TokenHoldings{
|
||||
TokenSymbol: "OLD",
|
||||
Balance: "100",
|
||||
TokenDecimals: "8",
|
||||
TokenAddress: "0xold",
|
||||
TokenSymbol: "OLD",
|
||||
Balance: "100",
|
||||
TokenDecimals: "8",
|
||||
ContractAddress: "0xold",
|
||||
}
|
||||
require.NoError(t, StoreTemporaryVoucher(ctx, store, sessionId, tempData))
|
||||
|
||||
@ -180,7 +180,7 @@ func TestUpdateVoucherData(t *testing.T) {
|
||||
storedb.DATA_ACTIVE_SYM: []byte(newData.TokenSymbol),
|
||||
storedb.DATA_ACTIVE_BAL: []byte(newData.Balance),
|
||||
storedb.DATA_ACTIVE_DECIMAL: []byte(newData.TokenDecimals),
|
||||
storedb.DATA_ACTIVE_ADDRESS: []byte(newData.TokenAddress),
|
||||
storedb.DATA_ACTIVE_ADDRESS: []byte(newData.ContractAddress),
|
||||
}
|
||||
|
||||
for key, expectedValue := range activeEntries {
|
||||
|
Loading…
Reference in New Issue
Block a user