NethermindEth/starknet.go

Improve SNIP-12 with validation function

Ouverte

#770 ouverte le 10 juil. 2025

 (5 commentaires) (0 réaction) (1 personne assignée)Go (140 forks)auto 404
help wanted

Métriques du dépôt

Stars
 (177 étoiles)
Métriques de merge PR
 (Métriques PR en attente)

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" }
    ]
  }
}

Guide contributeur