mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-07-02 21:19:44 +00:00
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.
246 lines
4.9 KiB
JSON
246 lines
4.9 KiB
JSON
{
|
|
"version": "0.1.0",
|
|
"name": "ata",
|
|
"instructions": [
|
|
{
|
|
"name": "create",
|
|
"accounts": [
|
|
{
|
|
"name": "owner",
|
|
"writable": true,
|
|
"signer": false,
|
|
"init": false
|
|
},
|
|
{
|
|
"name": "token_definition",
|
|
"writable": false,
|
|
"signer": false,
|
|
"init": false
|
|
},
|
|
{
|
|
"name": "ata_account",
|
|
"writable": true,
|
|
"signer": false,
|
|
"init": false
|
|
}
|
|
],
|
|
"args": [
|
|
{
|
|
"name": "token_program_id",
|
|
"type": "program_id"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "transfer",
|
|
"accounts": [
|
|
{
|
|
"name": "owner",
|
|
"writable": false,
|
|
"signer": true,
|
|
"init": false
|
|
},
|
|
{
|
|
"name": "sender_ata",
|
|
"writable": true,
|
|
"signer": false,
|
|
"init": false
|
|
},
|
|
{
|
|
"name": "recipient",
|
|
"writable": true,
|
|
"signer": false,
|
|
"init": false
|
|
}
|
|
],
|
|
"args": [
|
|
{
|
|
"name": "token_program_id",
|
|
"type": "program_id"
|
|
},
|
|
{
|
|
"name": "amount",
|
|
"type": "u128"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "burn",
|
|
"accounts": [
|
|
{
|
|
"name": "owner",
|
|
"writable": false,
|
|
"signer": true,
|
|
"init": false
|
|
},
|
|
{
|
|
"name": "holder_ata",
|
|
"writable": true,
|
|
"signer": false,
|
|
"init": false
|
|
},
|
|
{
|
|
"name": "token_definition",
|
|
"writable": true,
|
|
"signer": false,
|
|
"init": false
|
|
}
|
|
],
|
|
"args": [
|
|
{
|
|
"name": "token_program_id",
|
|
"type": "program_id"
|
|
},
|
|
{
|
|
"name": "amount",
|
|
"type": "u128"
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"accounts": [
|
|
{
|
|
"name": "TokenDefinition",
|
|
"type": {
|
|
"kind": "enum",
|
|
"variants": [
|
|
{
|
|
"name": "Fungible",
|
|
"fields": [
|
|
{
|
|
"name": "name",
|
|
"type": "string"
|
|
},
|
|
{
|
|
"name": "total_supply",
|
|
"type": "u128"
|
|
},
|
|
{
|
|
"name": "metadata_id",
|
|
"type": {
|
|
"option": "account_id"
|
|
}
|
|
},
|
|
{
|
|
"name": "authority",
|
|
"type": {
|
|
"option": "account_id"
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "NonFungible",
|
|
"fields": [
|
|
{
|
|
"name": "name",
|
|
"type": "string"
|
|
},
|
|
{
|
|
"name": "printable_supply",
|
|
"type": "u128"
|
|
},
|
|
{
|
|
"name": "metadata_id",
|
|
"type": "account_id"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"name": "TokenHolding",
|
|
"type": {
|
|
"kind": "enum",
|
|
"variants": [
|
|
{
|
|
"name": "Fungible",
|
|
"fields": [
|
|
{
|
|
"name": "definition_id",
|
|
"type": "account_id"
|
|
},
|
|
{
|
|
"name": "balance",
|
|
"type": "u128"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "NftMaster",
|
|
"fields": [
|
|
{
|
|
"name": "definition_id",
|
|
"type": "account_id"
|
|
},
|
|
{
|
|
"name": "print_balance",
|
|
"type": "u128"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "NftPrintedCopy",
|
|
"fields": [
|
|
{
|
|
"name": "definition_id",
|
|
"type": "account_id"
|
|
},
|
|
{
|
|
"name": "owned",
|
|
"type": "bool"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"name": "TokenMetadata",
|
|
"type": {
|
|
"kind": "struct",
|
|
"fields": [
|
|
{
|
|
"name": "definition_id",
|
|
"type": "account_id"
|
|
},
|
|
{
|
|
"name": "standard",
|
|
"type": {
|
|
"defined": "MetadataStandard"
|
|
}
|
|
},
|
|
{
|
|
"name": "uri",
|
|
"type": "string"
|
|
},
|
|
{
|
|
"name": "creators",
|
|
"type": "string"
|
|
},
|
|
{
|
|
"name": "primary_sale_date",
|
|
"type": "u64"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
],
|
|
"types": [
|
|
{
|
|
"name": "MetadataStandard",
|
|
"kind": "enum",
|
|
"variants": [
|
|
{
|
|
"name": "Simple"
|
|
},
|
|
{
|
|
"name": "Expanded"
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"instruction_type": "ata_core::Instruction"
|
|
}
|