The function of the axon is to transmit information to different neurons - Wikipedia
Axon is a multi-user, multi-neuron management canister.
This repo is a fork of the original Axon project, created and sponsored by ICDevs.org.
- An Axon canister controls one or more neurons
- Axons can have one or more owners
- An approval policy can be set, eg. 3 out of 5 owners required to approve an action
- Requests like
ManageNeuron
are sent to Axon, which queues them for approval - A snapshot of owners and current policy is stored with each request
- Once the policy conditions are met, the request is forwarded to all controlled neurons
- Axons can be public and expose all neuron data
Only Admins can create new Axons. The Admin role can be granted to or removed from principals only by the Master Admin. The Master Admin is the principle that deploys the parent Axon dapp canister.
You may want to add your wallet principal:
dfx canister --network ic call Axon add_admin '(principal "k3gvh-4fgvt-etjfk-dfpfc-we5bp-cguw5-6rrao-65iwb-ttim7-tt3bc-6qe")'
(Principal of deploying identity becomes Master Admin)
Deploy an Axon dapp :
cd src/axon-ui
Follow the instructions to add the Psycadelic context as a github package registry: https://github.com/Psychedelic/plug-inpage-provider#-installation
npm i npm run build
```sh
npm run export
cd ../..
dfx deploy --network ic
(must be an Admin)
Deploy an Axon canister:
dfx deploy Axon --argument 'record {owner= (principal "your-principal-here"); visibility= variant{Public}}'
(Principal of deploying identity becomes Master Admin)
Deploy an Axon dapp :
cd src/axon-ui
Follow the instructions to add the Psycadelic context as a github package registry: https://github.com/Psychedelic/plug-inpage-provider#-installation
npm i npm run build_local
```sh
npm run export_local
cd ../..
dfx deploy --network local
Currently, canisters cannot control neurons. It is only possible to add the Axon canister as a hot key for neurons, so only commands like Follow
and RegisterVote
will succeed.
Checks if the specified principal is an admin on the axon head canister.
p
(type:Principal
): The principal to check.
- (type:
async Bool
): Returnstrue
if the principal is an admin, otherwisefalse
.
Returns a list of all the admins.
- (type:
async Array<Principal>
): An array containing all the admins.
Retrieves the number of axons.
- (type:
async Nat
): The count of axons.
Retrieves the top axons based on their total stake.
- (type:
async Array<AxonPublic>
): An array of axons sorted by total stake in descending order.
Retrieves the public information of an axon by ID.
id
(type:Nat
): The ID of the axon.
- (type:
async AxonPublic
): The public information of the axon.
Retrieves the public information of an axon by wallet address. You can use this if you know your Axon Proxy and want to find the axon id that controls that proxy.
id
(type:Principal
): The wallet principal of the axon.
- (type:
async ?AxonPublic
): The public information of the axon, or null if not found.
Retrieves the status of an axon by ID.
id
(type:Nat
): The ID of the axon.
- (type:
async CanisterStatusResult
): The status of the axon.
Retrieves the neuron IDs associated with an axon.
id
(type:Nat
): The ID of the axon.
- (type:
async Array<Nat64>
): An array of neuron IDs.
Retrieves the balance for a principal on a given axon for a specific principal or caller.
id
(type:Nat
): The ID of the axon.principal
(type:?Principal
): Optional. The principal for which to retrieve the balance. If null, the caller's balance is retrieved.
- (type:
async Nat
): The balance of the axon for the specified principal or caller. This is the snap shot blance. "Source of truth" balances should be checked on the axon proxy using icrc1_balance_of
Retrieves the ledger entries of an axon by ID.
id
(type:Nat
): The ID of the axon.
- (type:
async Array<LedgerEntry>
): An array of ledger entries sorted in descending order by balance. This is a shapshot of the holders of the Axon token. It should not be used as a source of truth.
Retrieves the axons where the caller has a non-zero balance.
- (type:
async Array<AxonPublic>
): An array of axons where the caller has a balance.
Retrieves the neurons associated with an axon.
id
(type:Nat
): The ID of the axon.
- (type:
async NeuronsResult
): The result containing the neurons associated with the axon.
Retrieves a single proposal by ID.
axonId
(type:Nat
): The ID of the axon.proposalId
(type:Nat
): The ID of the proposal.
- (type:
async Result<AxonProposalPublic>
): The result containing the public information of the proposal.
Retrieves all active proposals of an axon.
id
(type:Nat
): The ID of the axon.
- (type:
async ProposalResult
): The result containing the public information of the active proposals.
Retrieves the last 100 proposals of an axon, optionally before the specified ID.
id
(type:Nat
): The ID of the axon.before
(type:?Nat
): Optional. The ID of the proposal to retrieve proposals before.
- (type:
async ProposalResult
): The result containing the public information of the proposals.
Retrieves all motion proposals of an axon.
id
(type:Nat
): The ID of the axon.
- (type:
async ProposalResult
): The result containing the public information of the motion proposals.
Adds the specified principal as an admin.
p
(type:Principal
): The principal to add as an admin.
Retrieves the current balance of cycles.
- (type:
async Nat
): The current balance of cycles.
Updates the controller of an axon. This is needed for deletion purposes.
canisterId
(type:Principal
): The canister ID of the axon.manager
(type:Principal
): The new manager's principal.
Changes the master.
p
(type:Principal
): The new master's principal.
Removes the specified principal as an admin.
p
(type:Principal
): The principal to remove as an admin.
private _mint(caller: Principal, axonId: Nat, p: Principal, a: Nat): async* Result<AxonCommandExecution>
Mints a specified amount of tokens for a recipient. Creates the equivalent of an mint proposal and executes it. You must have a minting privileges. A message will be sent to the proxy wallet to actually mint the tokens and then the proxy will update the balance on the Axon head.
caller
(type:Principal
): The caller's principal.axonId
(type:Nat
): The ID of the axon.p
(type:Principal
): The recipient's principal.a
(type:Nat
): The amount of tokens to mint.
- (type:
async* Result<AxonCommandExecution>
): The result of the axon command execution.
Mints a specified amount of tokens for a recipient. Must be the minting canister or principal
axonId
(type:Nat
): The ID of the axon.p
(type:Principal
): The recipient's principal.a
(type:Nat
): The amount of tokens to mint.
- (type:
async Result<AxonCommandExecution>
): The result * of the axon command execution.
mint_batch(request: Array<[Nat, Principal, Nat]>): async Array<[(Nat, Principal, Nat), Result<AxonCommandExecution>]>
Mints a batch of tokens for multiple recipients.
request
(type:Array<[Nat, Principal, Nat]>
): An array of tuples, each containing the axon ID, recipient's principal, and amount of tokens to mint.
- (type:
async Array<[(Nat, Principal, Nat), Result<AxonCommandExecution>]>
): An array of tuples, each containing the request details and the result of the axon command execution.
Burns a specified amount of tokens owned by a recipient. Burns must be allowed. A message will be sent to the proxy to burn the tokens. Balance will be updated by the proxy wallet if the burn is allowed.
axonId
(type:Nat
): The ID of the axon.p
(type:Principal
): The owner's principal.a
(type:Nat
): The amount of tokens to burn.
- (type:
async Result<AxonCommandExecution>
): The result of the axon command execution.
burn_batch(request: Array<[Nat, Principal, Nat]>): async Array<[(Nat, Principal, Nat), Result<AxonCommandExecution>]>
Burns a batch of tokens owned by multiple recipients.
request
(type:Array<[Nat, Principal, Nat]>
): An array of tuples, each containing the axon ID, owner's principal, and amount of tokens to burn.
- (type:
async Array<[(Nat, Principal, Nat), Result<AxonCommandExecution>]>
): An array of tuples, each containing the request details and the result of the axon command execution.
Upgrades a proxy to the new actor type. This should be called once for each upgrade to upgrade all the proxy canisters one by one to the new actor.
- (type:
async Array<Result<Bool, Text>>
): An array of results indicating the success or failure of the upgrade process for each axon.
Accepts cycles to the wallet.
- (type:
async Nat
): The amount of accepted cycles.
Accepts cycles and recycles them for an axon.
axonId
(type:Nat
): The ID of the axon.floor
(type:Nat
): The floor value.
- (type:
async Nat
): The amount of accepted cycles.
Transfers tokens from one axon to another.
id
(type:Nat
): The ID of the axon.dest
(type:Principal
): The destination principal.amount
(type:Nat
): The amount of tokens to transfer.
- (type:
async Result<()>
): The result of the token transfer operation.
Creates a new axon.
init
(type:Initialization
): The initialization parameters for the axon.
- (type:
async Result<AxonPublic>
): The result containing the public information of the created axon.
Submits a new proposal for an axon.
request
(type:NewProposal
): The new proposal request.
- (type:
async Result<AxonProposalPublic>
): The result containing the public information of the created proposal.
Votes on an active proposal.
request
(type:VoteRequest
): The vote request.
- (type:
async Result<()>
): The result of the vote operation.
Cancels an active proposal created by the caller.
axonId
(type:Nat
): The ID of the axon.proposalId
(type:Nat
): The ID of the proposal.
- (type:
async Result<AxonProposalPublic>
): The result containing the public information of the canceled proposal.
Queues a proposal for execution.
axonId
(type:Nat
): The ID of the axon.proposalId
(type:Nat
): The ID of the proposal.
- (type:
async Result<AxonProposalPublic>
): The result containing the public information of the queued proposal.
Calls list_neurons()
and saves the list of neurons controlled by the axon's proxy.
id
(type:Nat
): The ID of the axon.
- (type:
async NeuronsResult
): The result containing the list of neurons and the timestamp.
refreshBalances(axonId: Nat, accounts: Array<{account: Principal, balance: Nat}>): async [Result<Bool>]
Refreshes the balances of the specified accounts in the axon's ledger. This can only be called by the proxy wallet and is used to keep the axon head in sync with the proxy.
axonId
(type:Nat
): The ID of the axon.- `
accounts(type:
Array<{account: Principal, balance: Nat}>`): The accounts and their updated balances.
- (type:
async [Result<Bool>]
): The results of the balance refresh operation.
Updates the proposal statuses and moves them from active to all if needed. Called by the sync
function.
axonId
(type:Nat
): The ID of the axon.
- (type:
async Result<()>
): The result of the cleanup operation.
Executes an accepted proposal.
axonId
(type:Nat
): The ID of the axon.proposal
(type:AxonProposal
): The proposal to execute.
- (type:
async AxonProposalPublic
): The public information of the executed proposal.
Returns true if the policy of an axon allows token transfers by members.
Returns true if the principal holds a balance in the ledger or if it's this canister.
Returns the neuron IDs from the stored neuron infos.
Returns the public information of the axon with its own balance.
Converts seconds to nanoseconds.
Clamps a number within a specified range.
Creates an error object from an error.
The Proxy wallet contract is responsible for managing an ICRC1 token implementation and providing various functionalities for interacting with the token. If also allows the users to make requests for call_raw calls so that the Axon Proxy Wallet can call other services.
Retrieves the metrics of the Proxy wallet contract.
Recycles cycles from the Proxy wallet contract.
Calls the list_neurons() function and saves the list of neurons that this canister controls.
Manages a neuron by calling the manage_neuron() function.
call_raw(canister: Principal, functionName: Text, argumentBinary: Blob, cycles: Nat): Result.Result<Blob, Text>
Calls a canister function with raw parameters.
icrc1_name() : async Text
: Retrieves the name of the ICRC1 token in the Proxy wallet contract.icrc1_symbol() : async Text
: Retrieves the symbol of the ICRC1 token in the Proxy wallet contract.icrc1_decimals() : async Nat8
: Retrieves the decimals of the ICRC1 token in the Proxy wallet contract.icrc1_fee() : async ICRC1.Balance
: Retrieves the fee of the ICRC1 token in the Proxy wallet contract.icrc1_metadata() : async [ICRC1.MetaDatum]
: Retrieves the metadata of the ICRC1 token in the Proxy wallet contract.icrc1_total_supply() : async ICRC1.Balance
: Retrieves the total supply of the ICRC1 token in the Proxy wallet contract.icrc1_minting_account() : async ?ICRC1.Account
: Retrieves the minting account of the ICRC1 token in the Proxy wallet contract.icrc1_balance_of(args : ICRC1.Account) : async ICRC1.Balance
: Retrieves the balance of an ICRC1 account in the Proxy wallet contract.icrc1_supported_standards() : async [ICRC1.SupportedStandard]
: Retrieves the supported standards of the ICRC1 token in the Proxy wallet contract.icrc1_transfer(args : ICRC1.TransferArgs) : async ICRC1.TransferResult
: Transfers ICRC1 tokens in the Proxy wallet contract.
-
mint(args : ICRC1.Mint) : async ICRC1.TransferResult
: Mints new ICRC1 tokens in the Proxy wallet contract. -
burn(args : ICRC1.Burn) : async ICRC1.TransferResult
: Burns ICRC1 tokens in the Proxy wallet contract. -
get_transactions(req: ICRC1.GetTransactionsRequest): async ICRC1.GetTransactionsResponse
Retrieves transactions of the ICRC1 token in the Proxy wallet contract.
-
get_transaction(i: ICRC1.TxIndex): async ?ICRC1.Transaction
Retrieves a transaction of the ICRC1 token in the Proxy wallet contract.
-
deposit_cycles(): async
Deposits cycles into the Proxy wallet contract.
-
sync_policy(): async Result.Result<Bool, Text>
Synchronizes the policies from the axon.
-
seed_balance(): async Result.Result<Bool, Text>
Seeds the balance from the axon but only once.
-
redenominate(from: Nat, to: Nat): async Result.Result<Bool, Text>
Redenominates the token balance.
-
update_token(request: Object): async Result.Result<Bool, Text>
Updates the token information.
-
force_refresh_balance(request: Array<Principal>): async Result.Result<Bool, Text
>Forces a refresh of balance for specified accounts.
- added a #Balance Batch command arg that will move the balance of a user to particular amount without both a burn and mint command. Also checks for equivalence to not clutter the ledger
- added vote delegation
- allowed minters to manage delegation
- removed mint_batch and burn_batch and replaced with mint_burn_batch
- removed treasury's right to vote
- converted ballots to a Map for performance
- added #BurnAll and #Mint_Burn_Batch. UI has not been completed for this.
- added JSON view of neurons to Proxy at /neurons.
- Fixed bug where anyone could mint or burn
- moved system of record for balances to Proxy canister
- added ICRC-1 to Proxy Canister
- added mint_batch and burn_batch to axon for large scale burning/minting - warning - will be processed in series with awaits between each burn/mint batch of 10 - return order not guaranteed
- fixed voting bug
- fixed admin bug
- fixed UI bug
- Fixed Bug that would not allow execution if not immediate.
- Allowed step on percentage up to .000001
- Fixed a bug where anyone could update the canister settings of a child axon.
- Added a note and cycles to Canister calls
- Added the ability to upgrade proxies via upgrade pathway.
- Added migration framework