Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added producer protocol feature support
- Loading branch information
Showing
3 changed files
with
141 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
package system | ||
|
||
import ( | ||
"github.com/eoscanada/eos-go" | ||
"github.com/eoscanada/eos-go/ecc" | ||
) | ||
|
||
func NewNewAccount(creator, newAccount eos.AccountName, publicKey ecc.PublicKey) *eos.Action { | ||
return &eos.Action{ | ||
Account: AN("eosio"), | ||
Name: ActN("newaccount"), | ||
Authorization: []eos.PermissionLevel{ | ||
{Actor: creator, Permission: PN("active")}, | ||
}, | ||
ActionData: eos.NewActionData(NewAccount{ | ||
Creator: creator, | ||
Name: newAccount, | ||
Owner: eos.Authority{ | ||
Threshold: 1, | ||
Keys: []eos.KeyWeight{ | ||
{ | ||
PublicKey: publicKey, | ||
Weight: 1, | ||
}, | ||
}, | ||
Accounts: []eos.PermissionLevelWeight{}, | ||
}, | ||
Active: eos.Authority{ | ||
Threshold: 1, | ||
Keys: []eos.KeyWeight{ | ||
{ | ||
PublicKey: publicKey, | ||
Weight: 1, | ||
}, | ||
}, | ||
Accounts: []eos.PermissionLevelWeight{}, | ||
}, | ||
}), | ||
} | ||
} | ||
|
||
// NewDelegatedNewAccount returns a `newaccount` action that lives on the | ||
// `eosio.system` contract. It is filled with an authority structure that | ||
// delegates full control of the new account to an already existing account. | ||
func NewDelegatedNewAccount(creator, newAccount eos.AccountName, delegatedTo eos.AccountName) *eos.Action { | ||
return &eos.Action{ | ||
Account: AN("eosio"), | ||
Name: ActN("newaccount"), | ||
Authorization: []eos.PermissionLevel{ | ||
{Actor: creator, Permission: PN("active")}, | ||
}, | ||
ActionData: eos.NewActionData(NewAccount{ | ||
Creator: creator, | ||
Name: newAccount, | ||
Owner: eos.Authority{ | ||
Threshold: 1, | ||
Keys: []eos.KeyWeight{}, | ||
Accounts: []eos.PermissionLevelWeight{ | ||
eos.PermissionLevelWeight{ | ||
Permission: eos.PermissionLevel{ | ||
Actor: delegatedTo, | ||
Permission: PN("active"), | ||
}, | ||
Weight: 1, | ||
}, | ||
}, | ||
}, | ||
Active: eos.Authority{ | ||
Threshold: 1, | ||
Keys: []eos.KeyWeight{}, | ||
Accounts: []eos.PermissionLevelWeight{ | ||
eos.PermissionLevelWeight{ | ||
Permission: eos.PermissionLevel{ | ||
Actor: delegatedTo, | ||
Permission: PN("active"), | ||
}, | ||
Weight: 1, | ||
}, | ||
}, | ||
}, | ||
}), | ||
} | ||
} | ||
|
||
// NewCustomNewAccount returns a `newaccount` action that lives on the | ||
// `eosio.system` contract. You can specify your own `owner` and | ||
// `active` permissions. | ||
func NewCustomNewAccount(creator, newAccount eos.AccountName, owner, active eos.Authority) *eos.Action { | ||
return &eos.Action{ | ||
Account: AN("eosio"), | ||
Name: ActN("newaccount"), | ||
Authorization: []eos.PermissionLevel{ | ||
{Actor: creator, Permission: PN("active")}, | ||
}, | ||
ActionData: eos.NewActionData(NewAccount{ | ||
Creator: creator, | ||
Name: newAccount, | ||
Owner: owner, | ||
Active: active, | ||
}), | ||
} | ||
} | ||
|
||
// NewAccount represents a `newaccount` action on the `eosio.system` | ||
// contract. It is one of the rare ones to be hard-coded into the | ||
// blockchain. | ||
type NewAccount struct { | ||
Creator eos.AccountName `json:"creator"` | ||
Name eos.AccountName `json:"name"` | ||
Owner eos.Authority `json:"owner"` | ||
Active eos.Authority `json:"active"` | ||
} |