mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-08-26 22:51:14 +00:00
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:
@@ -666,6 +666,12 @@
|
||||
"type": {
|
||||
"option": "account_id"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "authority",
|
||||
"type": {
|
||||
"option": "account_id"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -120,6 +120,12 @@
|
||||
"type": {
|
||||
"option": "account_id"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "authority",
|
||||
"type": {
|
||||
"option": "account_id"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -160,6 +160,12 @@
|
||||
"type": {
|
||||
"option": "account_id"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "authority",
|
||||
"type": {
|
||||
"option": "account_id"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user