NethermindEth/starknet.go

Improve SNIP-12 with validation function

Aberta

#770 aberto em 10 de jul. de 2025

 (5 comentários) (0 reação) (1 responsável)Go (140 forks)auto 404
help wanted

Métricas do repositório

Stars
 (177 estrelas)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

We could have a validation for the typedData json file to avoid mistakes.

For example, this typed data has an error, but it's considered valid. The amount field value contains an object instead of a u128. A validation would be good for the UX.

SNIP-12 spec: https://github.com/starknet-io/SNIPs/blob/main/SNIPS/snip-12.md

{
  "domain": {
    "name": "Permit2",
    "version": "v1",
    "chainId": "0x0",
    "revision": "1"
  },
  "primaryType": "PermitSingle",
  "message": {
    "details": {
      "token": "0x1234",
      "amount": { "low": "0x123", "high": "0x0" },
      "expiration": "1234",
      "nonce": "1"
    },
    "spender": "0x1234",
    "sigDeadline": {
      "low": "1234567890",
      "high": "0x0"
    }
  },
  "types": {
    "StarknetDomain": [
      { "name": "name", "type": "shortstring" },
      { "name": "version", "type": "shortstring" },
      { "name": "chainId", "type": "shortstring" },
      { "name": "revision", "type": "shortstring" } 
    ],
    "PermitDetails": [
      { "name": "token", "type": "felt" },
      { "name": "amount", "type": "u128" },
      { "name": "expiration", "type": "u128" },
      { "name": "nonce", "type": "u128" }
    ],
    "PermitSingle": [
      { "name": "details", "type": "PermitDetails" },
      { "name": "spender", "type": "felt" },
      { "name": "sigDeadline", "type": "u256" }
    ]
  }
}

Guia do colaborador