Repository navigation
Add create code routes - #537
Conversation
| Cfg.AudiusdChainID = core_config.StageAcdcChainID | ||
| Cfg.AudiusdEntityManagerAddress = core_config.StageAcdcAddress | ||
| Cfg.AudiusAppUrl = "https://staging.audius.co" | ||
| Cfg.RewardCodeAuthorizedKeys = []string{"9XeZbswbSSUU4AHVArQbTQjAEjAPhVweGU5cogBVkvh4"} |
There was a problem hiding this comment.
might have missed discussion on this but should these not be dynamic and on a per-mint basis?
There was a problem hiding this comment.
yeah, figured it can be a future change. it needs more machinery, probably another column somewhere. for now ok like this
| }) | ||
| } | ||
|
|
||
| func TestVerifySignature(t *testing.T) { |
There was a problem hiding this comment.
could test that wallets in positions other than the first also work
There was a problem hiding this comment.
will add later in next PR
| type CreateRewardCodeRequest struct { | ||
| Signature string `json:"signature" validate:"required"` | ||
| Mint string `json:"mint" validate:"required"` | ||
| Amount int64 `json:"amount" validate:"required,min=1"` |
There was a problem hiding this comment.
could add a max? configurable?
There was a problem hiding this comment.
probably but idk what it should be yet
| type: string | ||
| description: The coin mint address | ||
| example: "9LzCMqDgTKYz9Drzqnpgee3SGa89up3a247ypMj2xrqM" | ||
| amount: |
There was a problem hiding this comment.
What's the plan for creating a set of codes? Hit this endpoint N times?
Or should we have an optional count/number of codes to generate field?
| properties: | ||
| signature: | ||
| type: string | ||
| description: Base64-encoded Solana Ed25519 signature of the string "code" |
There was a problem hiding this comment.
What's the secret code?!
.
.
.
.
..."code"
| charsLen := big.NewInt(int64(len(codeChars))) | ||
|
|
||
| for i := 0; i < codeLength; i++ { | ||
| num, err := rand.Int(rand.Reader, charsLen) |
There was a problem hiding this comment.
I am surprised there is not a crypto function that does this already. Any concerns with randomness/seed here?
| ) | ||
|
|
||
| const ( | ||
| signedMessage = "code" |
There was a problem hiding this comment.
nit: variable name here is a tad generic, I had to jump and forth a few times to figure out how it was used :-)
There was a problem hiding this comment.
will change in next PR
| return fiber.NewError(fiber.StatusInternalServerError, "Database error: "+err.Error()) | ||
| } | ||
|
|
||
| response, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[CreateRewardCodeResponse]) |
There was a problem hiding this comment.
Assuming we would get an error of some sort in this section if we collide. Just have the user try again in that case?
There was a problem hiding this comment.
yeah AI originally made this try a few times... too complicated. probablity low
| Cfg.AudiusdChainID = core_config.ProdAcdcChainID | ||
| Cfg.AudiusdEntityManagerAddress = core_config.ProdAcdcAddress | ||
| Cfg.AudiusAppUrl = "https://audius.co" | ||
| Cfg.RewardCodeAuthorizedKeys = []string{"DDT15s6MMNxE4jkyGN46wNYqrgLWofT6WAvWtjYYrCUq"} |
There was a problem hiding this comment.
- Was kind of hoping we might DB this, but I guess this is a little more intention on adding new keys.
- Miiiiight want to map authorized keys to the mints they are allowed to generate codes for.
There was a problem hiding this comment.
- db in future. not now! i think this probably should be indexed because the data will be available on various pools
- only 1 mint we care abt atm
Does not create the
corereward type just yet, that will be a subsequent PR