This module allows you to create and manage a MakeOS repository. It can be accessed from the global variable repo
.
repo.create(txObject, [signingKey | payloadOnly | [signingKey, payloadOnly]])
Send a transaction to create a repository.
txObject
- Object
: The transaction object
name
- String
: The unique name of the repository.
value
- String
: (optional) The amount of coins to transfer to the new repository.
nonce
- Number|String
: The signing account’s next nonce.
fee
- String
: The network fee to be paid by the signing account.
timestamp
- String
: (optional) The Unix timestamp of the transaction.
config
- Object
: (optional) The repository configuration
sig
- String
: (optional) The transaction signature. If not provided, the transaction will be signed using the signingKey
.
signingKey
- String
: (optional) The private key to use to sign the transaction.
payloadOnly
- Boolean
: (optional) When true, the transaction payload is returned instead of being sent to the network.
Object
- The result object
hash
- String
: A 32 bytes transaction hash.
address
- String
: The full address of the repository.
Create a transaction to create a repository named myrepo
.
accounts[0]
returns the address of a key at index 0 on the keystore.
You will be prompted to enter the passphrase.
repo.create({name: "myrepo",fee: "0.1",value: "15.5"}, user.getKey(accounts[0]))
{"address": "r/myrepo","hash": "0x59e77af29938528284b69f8114a3ece38493e83725c3354ed840e2b8c86b39e3"}
Get the signed payload instead of creating and then sending the transaction.
var payload = repo.create({name: "myrepo",fee: "0.1",value: "15.5"}, user.getKey(accounts[0]), true)
{"config": {},"fee": "1","name": "myrepo","nonce": 1,"senderPubKey": [121,172,241,123,81,102,72,134,112,163,3,245,128,196,144,219,42,147,70,184,226,63,26,28,135,151,128,139,16,82,174,4],"sig": [184,29,52,29,244,75,118,183,214,245,205,15,170,131,69,60,15,110,172,211,11,122,96,199,175,70,5,79,127,189,23,199,13,87,77,37,8,219,206,101,109,82,123,150,202,101,78,142,22,202,46,1,165,25,229,31,112,102,58,184,121,20,221,3],"timestamp": 1606173977,"type": 6,"value": "0"}
repo.upsertOwner(txObject, [signingKey | payloadOnly | [signingKey, payloadOnly]])
Create a proposal to add or update an owner of a repository.
txObject
- Object
: The transaction object
id
- String
: A unique, numeric proposal ID. Must not exceed 16 characters.
name
- String
: The unique name of the repository.
value
- String
: (optional) The proposal deposit fee, if required.
addresses
- Array<String>
: A list of addresses to add as owners.
veto
- Boolean
: Grant veto right to owners.
nonce
- Number|String
: The signing account’s next nonce.
fee
- String
: The network fee to be paid by the signing account.
timestamp
- String
: (optional) The unix timestamp of the transaction.
sig
- String
: (optional) The transaction signature. If not provided, the transaction will be signed using the signingKey
.
signingKey
- String
: (optional) The private key to use to sign the transaction.
payloadOnly
- Boolean
: (optional) When true, the transaction payload is returned instead of being sent to the network.
Object
- The result object
hash
- String
: A 32 bytes transaction hash.
Create a transaction that adds a new address as an owner with veto power.
repo.upsertOwner({id: "1",name:"myrepo",veto: true,addresses: ["os1858effdlfecl30hgq0dvpesygp2daf97malemz"],fee: "1",}, user.getKey(accounts[0]))
repo.vote(txObject, [signingKey | payloadOnly | [signingKey, payloadOnly]])
Create a transaction that votes on a repository proposal.
txObject
- Object
: The transaction object
id
- String
: The ID of the proposal.
name
- String
: The name of the repository.
vote
- Number
: The vote choice:
0: No
,
1: Yes
2: NoWithVeto
3: Abstain
nonce
- Number|String
: The signing account’s next nonce.
fee
- String
: The network fee to be paid by the signing account.
timestamp
- String
: (optional) The Unix timestamp of the transaction.
sig
- String
: (optional) The transaction signature. If not provided, the transaction will be signed using the signingKey
.
signingKey
- String
: (optional) The private key to use to sign the transaction.
payloadOnly
- Boolean
: (optional) When true, the transaction payload is returned instead of being sent to the network.
Object
- The result object
hash
- String
: A 32 bytes transaction hash.
Create a transaction that will vote Yes
on a proposal with ID = 1
.
repo.vote({name: "myrepo",id: "1",vote: 1,fee: "1"}, user.getKey(accounts[0]))
repo.get(name, queryopts)
Create a transaction that votes on a repository proposal.
name
- String
: The name of the repository.
queryopts
- Object
: The query options
height
- Number|String
: (Optional) The chain height to search for repository. Defaults to the latest block height.
noProps
- Boolean
: If true, proposals will not be returned.
Returns
Object
- The result object
balance
- String
: The coin balance of the repository.
config
- RepoConfig
: The repository configuration.
contributors
- {PushKey: [RepoContributor](#)}
: The repository contributors.
owners
- {Address: [RepoOwner](#)}
- The owners of the repository.
proposals
- {ID: [RepoProposal](#)}
- The proposals created on the repository.
references
- {Reference: [RepoReference](#)}
- The git references of the repository.
repo.get("myrepo")
{"balance": "0","config": {RepoConfig},"contributors": {"pk1..": RepoContributor},"owners": {"os1..": RepoOwner},"proposals": {"1": RepoProposal},"references": {"refs/heads/master": RepoReference}}
repo.update(txObject, [signingKey | payloadOnly | [signingKey, payloadOnly]])
Create a proposal to update a repository.
txObject
- Object
: The transaction object
id
- String
: A unique, numeric proposal ID. Must not exceed 16 characters.
name
- String
: The unique name of the repository.
value
- String
: (optional) The proposal deposit fee, if required.
config
- Object
: The config update to merge into the existing configuration.
nonce
- Number|String
: The signing account’s next nonce.
fee
- String
: The network fee to be paid by the signing account.
timestamp
- String
: (optional) The Unix timestamp of the transaction.
sig
- String
: (optional) The transaction signature. If not provided, the transaction will be signed using the signingKey
.
signingKey
- String
: (optional) The private key to use to sign the transaction.
payloadOnly
- Boolean
: (optional) When true, the transaction payload is returned instead of being sent to the network.
Object
- The result object
hash
- String
: A 32 bytes transaction hash.
repo.update({name: "myrepo",id: "1",fee: "1",config: {governance: { propQuorum: 35 }}}, user.getKey(accounts[0]))
repo.depositPropFee(txObject, [signingKey | payloadOnly | [signingKey, payloadOnly]])
Creates a transaction that deposits the native coins to pay the proposal fee. Anyone can create this transaction. Depending on the repository's proposal fee configuration, the proposal fee may be returned after the proposal is finalized.
txObject
- Object
: The transaction object
id
- String
: A target proposal ID that will receive the deposit.
name
- String
: The unique name of the repository.
value
- String
: The amount to deposit as proposal fee.
nonce
- Number|String
: The signing account’s next nonce.
fee
- String
: The network fee to be paid by the signing account.
timestamp
- String
: (optional) The unix timestamp of the transaction.
sig
- String
: (optional) The transaction signature. If not provided, the transaction will be signed using the signingKey
.
signingKey
- String
: (optional) The private key to use to sign the transaction.
payloadOnly
- Boolean
: (optional) When true, the transaction payload is returned instead of being sent to the network.
Object
- The result object
hash
- String
: A 32 bytes transaction hash.
Create a transaction that will deposit 50 coins to a proposal with ID = 1
.
repo.depositPropFee({id: "1",name: "myrepo",fee: "1",value: "50",}, user.getKey(accounts[0],"marvel"))
repo.addContributor(txObject, [signingKey | payloadOnly | [signingKey, payloadOnly]])
Creates a proposal that adds contributors to a repository.
txObject
- Object
: The transaction object
id
- String
: A unique, numeric proposal ID. Must not exceed 16 characters.
name
- String
: The unique name of the repository.
value
- String
: (optional) The proposal deposit fee, if required.
keys
- Array<String>
: A list of push keys to add as contributors
policies
- Array<[ContributorPolicy](#)>
: A list of access policies to apply to the contributors.
feeMode
- Number
: The fee mode determines who pays the fees whenever a contributor performs a push operation. There are 3 fee mode options:
0: Contributor pays for their fees.
1: Repository pays for contributors fees.
2: Repository pays a capped amount of contributors fees.
feeCap
- Number
: The maximum amount of fees payable by the repository if feeMode
is 2
.
namespace
- String
: Adds the push keys as namespace-level contributors. Note: The repository must own the namespace.
namespaceOnly
- String
: Adds the push keys only as namespace-level contributors. They will not be added as contributors to the repository itself. Note: The repository must own the namespace.
nonce
- Number|String
: The signing account’s next nonce.
fee
- String
: The network fee to be paid by the signing account.
timestamp
- String
: (optional) The unix timestamp of the transaction.
sig
- String
: (optional) The transaction signature. If not provided, the transaction will be signed using the signingKey
.
signingKey
- String
: (optional) The private key to use to sign the transaction.
payloadOnly
- Boolean
: (optional) When true, the transaction payload is returned instead of being sent to the network.
Object
- The result object
hash
- String
: A 32 bytes transaction hash.
repo.addContributor({id: "1",name: "myrepo",keys: ["pk1wfx7vp8qfyv98cctvamqwec5xjrj48tpkfwme7"],fee: "1"}, user.getKey(accounts[0]))
repo.track(names, [height])
Track one or more repositories. If a repository is added to the tracklist, only the repository's push updates will be synchronized and stored on the node. You can track as many repositories as you want.
names
- String
: A comma separated list of repository names.
height
- String|Number
: (Optional) The block height to begin synchronization from.
Track a repo named my_repo
.
repo.track('my_repo')
Track repositories named my_repo
and someones_repo
repo.track('my_repo,someones_repo')
repo.untrack(names)
Untrack one or more repositories.
names
- String
: A comma-separated list of repository names.
Untrack a repo named my_repo
.
repo.untrack('my_repo')
Untrack repositories named my_repo
and someones_repo
.
repo.untrack('my_repo,someones_repo')
repo.tracked()
Get all tracked repositories.
Object
- The result object
interface Result {[repoName: String]: {updatedAt: String}}
repo.tracked()
{"my-repo": {"updatedAt": "1005"}}