feat(token): add mint authority model to token program

Add an optional mint authority to fungible tokens for controlled supply:
create with a designated minter, mint additional supply, rotate the
authority to a new key, or permanently revoke it to fix the supply.

The authority is stored inline on `TokenDefinition::Fungible` as
`authority: Option<AccountId>` (`Some(id)` = mintable by `id`, `None` =
fixed supply). Keeping it a plain `Option<AccountId>` rather than a custom
wrapper type leaves account state decodable by `spel inspect`; the
require/rotate/revoke guard logic lives inline in the handlers.

LEZ rejects a transaction that lists the same account id twice, so one
instruction cannot statically express both "the definition account is the
authority and signs" (self/PDA authority) and "a distinct rotated account
signs" (external authority) — they need opposite signer markers. Each
privileged operation is therefore split into a self and an external
variant:

- `Mint` / `SetAuthority` — the definition account is the signer.
- `MintWithAuthority` / `SetAuthorityWithAuthority` — a distinct authority
  account is the signer; the definition account does not sign.

Creation via `NewFungibleDefinition { mint_authority, .. }`; an all-zero
authority id is rejected. The AMM's LP token uses self/PDA authority — its
stored authority is the LP definition PDA, minted only by the pool via
chained calls.

Covered by token unit tests and zkVM integration tests: creation with and
without an authority, self- and external-authority mint, rotation, and
external rotate/revoke. IDLs regenerated.
This commit is contained in:
bristinWild
2026-07-02 19:19:23 +02:00
committed by r4bbit
parent 751d4ac530
commit fe4c7a96da
22 changed files with 1448 additions and 353 deletions
+6
View File
@@ -666,6 +666,12 @@
"type": {
"option": "account_id"
}
},
{
"name": "authority",
"type": {
"option": "account_id"
}
}
]
},
+6
View File
@@ -120,6 +120,12 @@
"type": {
"option": "account_id"
}
},
{
"name": "authority",
"type": {
"option": "account_id"
}
}
]
},
+6
View File
@@ -160,6 +160,12 @@
"type": {
"option": "account_id"
}
},
{
"name": "authority",
"type": {
"option": "account_id"
}
}
]
},
+85
View File
@@ -49,6 +49,12 @@
{
"name": "total_supply",
"type": "u128"
},
{
"name": "mint_authority",
"type": {
"option": "account_id"
}
}
]
},
@@ -153,6 +159,79 @@
}
]
},
{
"name": "mint_with_authority",
"accounts": [
{
"name": "definition_account",
"writable": true,
"signer": false,
"init": false
},
{
"name": "user_holding_account",
"writable": true,
"signer": false,
"init": false
},
{
"name": "authority_account",
"writable": false,
"signer": true,
"init": false
}
],
"args": [
{
"name": "amount_to_mint",
"type": "u128"
}
]
},
{
"name": "set_authority",
"accounts": [
{
"name": "definition_account",
"writable": true,
"signer": true,
"init": false
}
],
"args": [
{
"name": "new_authority",
"type": {
"option": "account_id"
}
}
]
},
{
"name": "set_authority_with_authority",
"accounts": [
{
"name": "definition_account",
"writable": true,
"signer": false,
"init": false
},
{
"name": "authority_account",
"writable": false,
"signer": true,
"init": false
}
],
"args": [
{
"name": "new_authority",
"type": {
"option": "account_id"
}
}
]
},
{
"name": "print_nft",
"accounts": [
@@ -194,6 +273,12 @@
"type": {
"option": "account_id"
}
},
{
"name": "authority",
"type": {
"option": "account_id"
}
}
]
},